-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (113 loc) · 3.96 KB
/
check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Build & Test
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
checks: write
statuses: write
jobs:
setup:
name: Setup
runs-on: ubuntu-24.04
steps:
- name: Create the commit status check
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
STATUS_REPO: ${{ github.repository }}
STATUS_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
STATUS_STATE: pending
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -x
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${STATUS_REPO}/statuses/${STATUS_SHA}" \
-f "state=${STATUS_STATE}" \
-f "target_url=${STATUS_URL}" \
-f "description=PR Check Workflow" \
-f "context=IMG.LY"
test:
name: Test Node ${{ matrix.node-version }}
needs: [setup]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
node-version:
- '18.x'
- '20.x'
- '22.x'
env:
CI_NODE_VERSION: ${{ matrix.node-version }}
CI_IS_PR: ${{ github.event_name == 'pull_request' }}
# In PRs, rebuild the changed packages, their dependents and dependencies only, unless the ci:build-all label is applied.
CI_PNPM_FILTER: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci:build-all')) && '...[origin/main]...' || '*' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ env.CI_NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.CI_NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm recursive install --filter "$CI_PNPM_FILTER" --frozen-lockfile
- name: Build
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" build
- name: Run checks
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" check:all
- name: Test
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" test
- name: Package
if: success() || failure()
shell: bash
run: |
mkdir -p _ci_packs
pnpm recursive --filter "$CI_PNPM_FILTER" exec pnpm pack "--pack-destination=$PWD/_ci_packs"
- name: Upload packages
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-npm-packages-node${{ env.CI_NODE_VERSION }}.zip
path: '_ci_packs/*.tgz'
if-no-files-found: ignore
overwrite: true
summary:
name: Summary test status
needs: [test]
if: always()
runs-on: ubuntu-24.04
steps:
- name: Update the commit status check
if: always()
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
STATUS_REPO: ${{ github.repository }}
STATUS_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
STATUS_STATE: ${{ needs.test.result == 'success' && 'success' || 'failure' }}
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -x
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${STATUS_REPO}/statuses/${STATUS_SHA}" \
-f "state=${STATUS_STATE}" \
-f "target_url=${STATUS_URL}" \
-f "description=PR Check Workflow" \
-f "context=IMG.LY"