-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (125 loc) · 4.26 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
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build & Test
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
checks: write
statuses: write
jobs:
configure:
name: Configure the build
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"
- uses: actions/checkout@v4
with:
fetch-depth: 1
sparse-checkout: |
.github
- name: Construct build matrix
id: construct_matrix
shell: bash
run: |
set -x
jq --compact-output --raw-output '."build-and-test" | tostring | "matrix_packages=" + .' .github/ci.json | tee -a "$GITHUB_OUTPUT"
outputs:
matrix_packages: ${{ steps.construct_matrix.outputs.matrix_packages }}
test:
name: Test ${{ matrix.package }} for Node ${{ matrix.node-version }}
needs: [configure]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
node-version: [20.x, 21.x]
package: ${{ fromJson(needs.configure.outputs.matrix_packages) }}
env:
IMGLY_PACKAGE_DIR: ${{ matrix.package == '.' && github.workspace || format('{0}/packages/{1}', github.workspace, matrix.package) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
lfs: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install workspace dependencies
shell: bash
run: yarn install
- name: Install dependencies
working-directory: ${{ env.IMGLY_PACKAGE_DIR }}
shell: bash
run: yarn install
- name: Run checks
working-directory: ${{ env.IMGLY_PACKAGE_DIR }}
shell: bash
run: yarn run check:all
- name: Build
working-directory: ${{ env.IMGLY_PACKAGE_DIR }}
shell: bash
run: yarn run build
- name: Test
working-directory: ${{ env.IMGLY_PACKAGE_DIR }}
shell: bash
run: yarn run test
- name: Package
if: success() || failure()
working-directory: ${{ env.IMGLY_PACKAGE_DIR }}
shell: bash
run: yarn pack
- name: Upload
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}-ci-node${{ matrix.node-version }}.tgz.zip
path: '${{ env.IMGLY_PACKAGE_DIR }}/*.tgz'
if-no-files-found: ignore
overwrite: true
summary:
name: Summary test status
needs: [test]
if: success() || failure()
runs-on: ubuntu-24.04
steps:
- name: Update 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: ${{ 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"