-
Notifications
You must be signed in to change notification settings - Fork 40
287 lines (263 loc) · 10.8 KB
/
nightly.yaml
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
name: Nightly
on:
schedule:
# Times in UTC (PST+8), this translates to running Mon-Fri at midnight/1am (depending on DST)
- cron: 0 8 * * 1-5
# Only enable on pull requests for testing
# pull_request:
# paths: [.github/workflows/nightly.yaml]
workflow_dispatch: {}
permissions:
actions: write
checks: write
contents: read
deployments: read
id-token: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: write
jobs:
# Run tests against all linters for snapshots and latest version as they exist on main
# This job is used to diagnose plugin config health in advance of a release
linter_tests_main:
name: Plugin Tests Main
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
linter-version: [Snapshots, Latest]
os: [ubuntu-latest, macOS, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Cache tool downloads
# ubuntu runner has persistent cache
if: matrix.os == 'windows-latest'
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: /tmp/plugins_testing_download_cache
# No need to key on trunk version unless we change how we store downloads.
key: trunk-${{ runner.os }}
- name: Delete cache
# For now, avoid deleting cache on pull request changes to nightly. This improves PR experience.
if: env.TRIGGER != 'pull_request'
run: |
if [ -d "/tmp/plugins_testing_download_cache" ]
then
tmp_dir=/tmp/${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ATTEMPT}
mv "/tmp/plugins_testing_download_cache" ${tmp_dir}
chmod -R u+w ${tmp_dir}
rm -rf ${tmp_dir}
fi
shell: bash
- name: Linter Tests
uses: ./.github/actions/linter_tests
with:
linter-version: ${{ matrix.linter-version }}
ref-type: main
sourcery-token: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
trunk-staging-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
trunk-prod-token: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}
# Run tests against all linters for snapshots and latest version as they exist in latest release
# This job is used to update the list of validated versions
linter_tests_release:
name: Plugin Tests Release
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
runs-on: ${{ matrix.os }}
timeout-minutes: 150
strategy:
fail-fast: false
matrix:
linter-version: [Snapshots, Latest]
os: [ubuntu-latest, macOS, windows-latest]
include:
# Normalize the filenames as inputs for ease of parsing
- os: ubuntu-latest
results-file: ubuntu-latest
- os: macOS
results-file: macos-latest
- os: windows-latest
results-file: windows-latest
outputs:
plugin-version: ${{ steps.get-release.outputs.tag }}
steps:
- name: Retrieve git history
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
# This assumes that any changes on main since the last release are backwards compatible
# in terms of allowing existing linter tests to run.
- name: Preserve test runner latest behavior
shell: bash
run: |
cp -r tests tests.bak
cp package.json package.json.bak
cp package-lock.json package-lock.json.bak
cp -r .github/actions .github/actions.bak
cp -r .trunk .trunk.bak
cp tsconfig.json tsconfig.json.bak
cp jest.config.json jest.config.json.bak
cp .gitattributes .gitattributes.bak
# Include any newly generated snapshots that have been marked release-ready
grep "// trunk-upgrade-validation:RELEASE" -r --include=*.shot -l | xargs -I {} cp {}{,.bak}
continue-on-error: true
- name: Get Latest Release
id: get-release
uses: WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce # v1.4.0
with:
# only use releases tagged v<semver>
prefix: v
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ steps.get-release.outputs.tag }}
clean: false
- name: Overwrite test runners with latest behavior
shell: bash
run: |
rm -rf tests
mv tests.bak tests
mv package.json.bak package.json
mv package-lock.json.bak package-lock.json
rm -rf .github/actions
mv .github/actions.bak .github/actions
rm -rf .trunk
mv .trunk.bak .trunk
mv tsconfig.json.bak tsconfig.json
mv jest.config.json.bak jest.config.json
mv .gitattributes.bak .gitattributes
# Include any newly generated snapshots that have been marked release-ready, but don't replace if present
grep "// trunk-upgrade-validation:RELEASE" -r --include=*.shot.bak -l | sed -e 's/.bak//' | xargs -I {} mv {}{.bak,}
continue-on-error: true
- name: Cache tool downloads
# ubuntu, mac runners have persistent cache
if: matrix.os == 'windows-latest'
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: /tmp/plugins_testing_download_cache
# No need to key on trunk version unless we change how we store downloads.
key: trunk-${{ runner.os }}
- name: Delete cache
# For now, avoid deleting cache on pull request changes to nightly. This improves PR experience.
run: |
if [ -d "${TMPDIR:-/tmp}/plugins_testing_download_cache" ]
then
tmp_dir=${TMPDIR:-/tmp}/${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ATTEMPT}
mv "${TMPDIR:-/tmp}/plugins_testing_download_cache" ${tmp_dir}
chmod -R u+w ${tmp_dir}
rm -rf ${tmp_dir}
fi
shell: bash
- name: Linter Tests ${{ matrix.os }}
# Use overwritten dependency action, rather than released version
uses: ./.github/actions/linter_tests
with:
linter-version: ${{ matrix.linter-version }}
append-args: linters -- --json --outputFile=${{ matrix.results-file }}-res.json
ref-type: release
sourcery-token: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
trunk-staging-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
trunk-prod-token: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}
- name: Upload Test Outputs for Upload Job
# Only upload results from latest. Always run, except when cancelled.
if: (failure() || success()) && matrix.linter-version == 'Latest'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ matrix.results-file }}-test-results
path: ${{ matrix.results-file }}-res.json
upload_linter_tests:
name: Upload Linter Test Results
needs: linter_tests_release
# Still run on test failure
if: always()
uses: ./.github/workflows/upload_results.reusable.yaml
secrets:
TRUNKBOT_SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
TRUNK_STAGING_API_TOKEN: ${{ secrets.TRUNK_STAGING_API_TOKEN }}
TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }}
TRUNK_OPEN_PR_APP_ID: ${{ secrets.TRUNK_OPEN_PR_APP_ID }}
TRUNK_OPEN_PR_APP_PRIVATE_KEY: ${{ secrets.TRUNK_OPEN_PR_APP_PRIVATE_KEY }}
TRUNK_SOURCERY_TOKEN: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
TRUNK_DEBUGGER_TOKEN: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
TRUNK_ORG_PROD_TOKEN: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}
with:
plugin-version: ${{ needs.linter_tests_release.outputs.plugin-version }}
upload-validated-versions: true
test-type: linter
test-ref: latest release
# Run tool tests only on main
tool_tests_main:
name: Tool Tests Main
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS, windows-latest]
include:
# Normalize the filenames as inputs for ease of parsing
- os: ubuntu-latest
results-file: ubuntu-latest
- os: macOS
results-file: macos-latest
- os: windows-latest
results-file: windows-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
# TODO(lauri): For now this just runs on the hardcoded versions. We should configure this
# akin to the linter_tests job.
- name: Tool Tests ${{ matrix.os }}
uses: ./.github/actions/tool_tests
with:
append-args: tools -- --json --outputFile=${{ matrix.results-file }}-res.json
trunk-staging-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
trunk-prod-token: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}
- name: Upload Test Outputs for Notification Job
# Always run, except when cancelled.
if: (failure() || success())
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: tools-${{ matrix.results-file }}-test-results
path: ${{ matrix.results-file }}-res.json
upload_tool_tests:
name: Upload Tool Test Results
needs: tool_tests_main
# Still run on test failure
if: always()
uses: ./.github/workflows/upload_results.reusable.yaml
secrets:
TRUNKBOT_SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
TRUNK_SOURCERY_TOKEN: ${{ secrets.TRUNK_SOURCERY_TOKEN }}
TRUNK_DEBUGGER_TOKEN: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
TRUNK_ORG_PROD_TOKEN: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}
with:
plugin-version: main
results-prefix: tools-
upload-validated-versions: false
test-type: tool
test-ref: main
# Run repo healthcheck tests
repo_tests:
name: Repo Tests
uses: ./.github/workflows/repo_tests.reusable.yaml
action_tests_main:
name: Action Tests Main
runs-on: [ubuntu-latest]
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Action Tests
uses: ./.github/actions/action_tests
with:
trunk-staging-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
trunk-prod-token: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}