-
-
Notifications
You must be signed in to change notification settings - Fork 103
310 lines (270 loc) · 9.31 KB
/
integration-test.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
name: Integration Tests
on:
pull_request:
paths:
- 'packages/**/package.json'
- 'packages/**/*-lock.yaml'
- 'packages/**/*.ts'
- 'integration-tests/**'
- '!integration-tests/perf/**'
- 'package.json'
- '*-lock.yaml'
- '.github/workflows/integration-test.yml'
- '!docs/**'
push:
branches:
- main
paths:
- 'packages/**/package.json'
- 'packages/**/*-lock.yaml'
- 'packages/**/*.ts'
- 'packages/**/*.mts'
- 'integration-tests/**'
- '!integration-tests/perf/**'
- 'package.json'
- '*-lock.yaml'
- '.github/workflows/integration-test.yml'
- '!docs/**'
# Run on demand
workflow_dispatch:
inputs:
ref:
description: Optional Branch or hash
required: false
permissions:
contents: read
env:
RUNS_ON: ubuntu-latest
NODE_VERSION: '22.x'
NPM_VERSION: '9'
jobs:
pre-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pre-build and cache
id: build-and-cache
uses: ./.github/actions/build-for-integrations
with:
show-summary: true
use-setup: true
prepare:
runs-on: ubuntu-latest
env:
REF_BRANCH: ${{ github.event.inputs.ref || github.ref }}
outputs:
ref: ${{ env.REF_BRANCH }}
runs_on: ${{ env.RUNS_ON }}
node_version: ${{ env.NODE_VERSION }}
repos: ${{ steps.load-integrations.outputs.repos }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.REF_BRANCH }}
- name: Start Prepare
uses: ./.github/actions/summary
with:
text: |
# Prepare Integration
- ref: "${{ env.REF_BRANCH }}"
- runs_on: "${{ env.RUNS_ON }}"
- node_version: ${{ env.NODE_VERSION }}
- name: load-integrations
id: load-integrations
uses: ./.github/actions/list-integration-repos
- name: Refs
uses: ./.github/actions/summary
with:
text: |
## Integrations
```json
${{ steps.load-integrations.outputs.repos }}
```
- name: Pre-build and cache
uses: ./.github/actions/build-for-integrations
with:
show-summary: true
node-version: ${{ env.NODE_VERSION }}
use-setup: true
integration-tests:
needs:
- prepare
- pre-build
runs-on: ${{ matrix.os }}
outputs:
repos: ${{ matrix.repo }}
env:
REF_BRANCH: ${{ needs.prepare.outputs.ref }}
strategy:
# the integration tests are independent, so we want to run them all.
fail-fast: false
matrix:
node-version:
- ${{ needs.prepare.outputs.node_version }}
os:
- ${{ needs.prepare.outputs.runs_on }}
# List of repositories to check.
# Use `repo-list.sh` in `integration-tests` to generate.
repo: ${{ fromJSON(needs.prepare.outputs.repos) }}
# repo:
# - prettier/prettier
# - typescript-eslint/typescript-eslint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Normalize Repo Name
id: step-normalize-repo-name
env:
REPO: ${{ matrix.repo }}
REPLACE: '/'
REPLACE_WITH: '__'
run: |
echo "REPO_NAME=${REPO//${REPLACE}/${REPLACE_WITH}}" >> $GITHUB_OUTPUT
- id: repo-hash
uses: streetsidesoftware/actions/public/output@v1
with:
value: >-
${{ hashFiles(
'.github/workflows/integration-test.yml',
'integration-tests/tsconfig.json',
'integration-tests/config/repositories/${{matrix.repo}}/**',
'integration-tests/snapshots/${{ matrix.repo }}/*',
'integration-tests/repositories/*',
'integration-tests/src/**/*.ts',
'integration-tests/src/**/*.mts',
'integration-tests/tsconfig.json',
'packages/*/src/**/*.ts',
'packages/*/src/**/*.mts',
'packages/*/tsconfig.json',
'packages/*/*.ts',
'packages/*/*.mts',
'tools/perf-chart/lib/app.cjs',
'*-lock.yaml'
) }}
- name: Repo Info
id: step-repo-info
run: |
echo "repo-info=$(jq -c '.repositories[] | select(.path == "${{ matrix.repo }}")' integration-tests/config/config.json)" >> $GITHUB_OUTPUT
- uses: ./.github/actions/echo
with:
value: |
step.repo-hash: "${{ steps.repo-hash.outputs.value }}"
env.repo-info: ${{ steps.step-repo-info.outputs.repo-info }}
$repo-hash
- name: Cache Integration Run
id: step-cache-run
uses: actions/[email protected]
with:
key: integration-run--${{ env.REF_BRANCH }}-${{ steps.repo-hash.outputs.value }}-${{ fromJSON(steps.step-repo-info.outputs.repo-info).commit }}-1
# Store the patch files to update the integration perf data
path: |
integration-tests/perf/perf-run-*.csv
- uses: ./.github/actions/echo
with:
value: |
Run Cache: ${{ steps.step-cache-run.outputs == 'true' && 'Hit' || 'Miss' }}
- name: Setup Env
if: ${{ steps.step-cache-run.outputs.cache-hit != 'true' }}
uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node-version }}
- id: step-cache-build
if: ${{ steps.step-cache-run.outputs.cache-hit != 'true' }}
uses: ./.github/actions/build-for-integrations
- uses: ./.github/actions/echo
if: ${{ steps.step-cache-run.outputs.cache-hit != 'true' }}
with:
value: |
Run Cache: ${{ steps.step-cache-run.outputs.cache-hit == 'true' && 'Hit' || 'Miss' }}
- name: Cache Integration Test Repository Files
if: ${{ steps.step-cache-run.outputs.cache-hit != 'true' }}
uses: actions/[email protected]
with:
key: int-repo-temp-files-${{ matrix.repo }}-${{ fromJSON(steps.step-repo-info.outputs.repo-info).commit }}
path: |
integration-tests/repositories/temp/${{ matrix.repo }}
- name: Run Integration Tests ${{ matrix.repo }}
if: ${{ steps.step-cache-run.outputs.cache-hit != 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
cd integration-tests
&& pnpm i
&& pnpm run integration-tests -- ${{ matrix.repo }}
- name: store perf run
if: ${{ steps.step-cache-run.outputs.cache-hit != 'true' }}
uses: actions/upload-artifact@v4
with:
name: perf-repo-${{ steps.step-normalize-repo-name.outputs.REPO_NAME }}
path: integration-tests/perf/perf-run-*.csv
retention-days: 1
integration-tests-summary:
permissions:
pull-requests: write
needs:
- integration-tests
- prepare
- pre-build
runs-on: ubuntu-latest
# We do not want to fail the build if the user does not have permissions to comment on the PR.
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create the temp directory
run: |
mkdir -p temp/perf
- name: restore repos perf
uses: actions/download-artifact@v4
with:
pattern: perf-*
merge-multiple: true
path: temp/perf
- name: show downloaded
run: ls -alF temp/perf
- name: append the runs
run: |
touch temp/perf/perf-run-empty.csv
cat temp/perf/perf-run-*.csv | sort >> integration-tests/perf/perf.csv
./tools/perf-chart/bin.js ./integration-tests/perf/perf.csv > perf-report.md
- name: Gen Report
id: report
run: |
echo 'report<<@@REPORT@@' >> $GITHUB_OUTPUT
./tools/perf-chart/bin.js ./integration-tests/perf/perf.csv >> $GITHUB_OUTPUT
echo '@@REPORT@@' >> $GITHUB_OUTPUT
- name: PR Body
id: pr-body
uses: streetsidesoftware/actions/public/pr-body@v1
with:
title: 'Update Integration Test Performance Data'
message: |
## Integration Tests Summary
- ref: "${{ needs.prepare.outputs.ref }}"
- runs_on: "${{ needs.prepare.outputs.runs_on }}"
- node_version: ${{ needs.prepare.outputs.node_version }}
- branch: ${{ github.ref_name }}
${{ steps.report.outputs.report }}
- name: Show PR in Summary
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
${{ steps.pr-body.outputs.body }}
- name: Add comment to PR
continue-on-error: true
uses: mshick/add-pr-comment@v2
with:
message: ${{ steps.report.outputs.report }}
- name: Create PR
if: github.ref_name == 'main'
uses: streetsidesoftware/actions/.github/actions/pr@v1
with:
commit-message: 'chore: ${{ steps.pr-body.outputs.title }}'
branch: update-perf-main
base: main
title: 'chore: ${{ steps.pr-body.outputs.title }}'
body: ${{ steps.pr-body.outputs.body }}
app_id: ${{ secrets.AUTOMATION_APP_ID }}
app_private_key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}