Skip to content

Commit 5596234

Browse files
authored
feat: conditionally run deployment unit tests (#16695)
1 parent 8592e56 commit 5596234

File tree

1 file changed

+55
-48
lines changed

1 file changed

+55
-48
lines changed

.github/workflows/ci-core.yml

+55-48
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,22 @@ jobs:
2323
pull-requests: read
2424
outputs:
2525
affected-modules: ${{ steps.resolved-modules.outputs.module_names }}
26-
deployment-changes: ${{ steps.match-some.outputs.deployment == 'true' }}
27-
should-run-ci-core: >-
26+
# Runs on workflow changes, any deployment change, or any (non-ignored) core change
27+
should-run-deployment-tests: >-
2828
${{
29-
steps.match-some.outputs.core-ci == 'true' ||
30-
steps.match-every.outputs.non-ignored == 'true' ||
29+
steps.match-some.outputs.workflow == 'true' ||
30+
steps.match-some.outputs.deployment == 'true' ||
31+
steps.match-every.outputs.core-non-ignored == 'true' ||
3132
github.event_name == 'schedule' ||
3233
github.event_name == 'workflow_dispatch'
3334
}}
34-
should-run-golangci: >-
35+
# Runs on workflow changes, and any (non-ignored) core changes
36+
should-run-core-tests: >-
3537
${{
36-
steps.match-some.outputs.golang-ci == 'true' ||
37-
steps.match-every.outputs.non-ignored == 'true'
38+
steps.match-some.outputs.workflow == 'true' ||
39+
steps.match-every.outputs.core-non-ignored == 'true' ||
40+
github.event_name == 'schedule' ||
41+
github.event_name == 'workflow_dispatch'
3842
}}
3943
runs-on: ubuntu-latest
4044
steps:
@@ -48,38 +52,33 @@ jobs:
4852
with:
4953
# "if any changed file matches one or more of the conditions" (https://github.com/dorny/paths-filter/issues/225)
5054
predicate-quantifier: some
51-
# deployment - any changes to files in the `deployments/`
52-
# core-ci - any changes that could affect this workflow definition
53-
# golang-ci - any changes that could affect the linting result
55+
# deployment - any changes in the deployment module
56+
# workflow - any changes that could affect this workflow definition
57+
# - Assume any repository action changes affect this workflow
5458
filters: |
5559
deployment:
5660
- 'deployment/**'
57-
core-ci:
58-
- '.github/workflows/ci-core.yml'
59-
- '.github/actions/**'
60-
golang-ci:
61-
- '.golangci.yml'
61+
workflow:
6262
- '.github/workflows/ci-core.yml'
6363
- '.github/actions/**'
6464
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
6565
id: match-every
6666
with:
6767
# "if any changed file match all of the conditions" (https://github.com/dorny/paths-filter/issues/225)
68+
# - Enables listing of files matching each filter.
69+
# - Paths to files will be available in `${FILTER_NAME}_files` output variable.
70+
# - Paths will be formatted as JSON array
6871
predicate-quantifier: every
69-
# non-integration-tests - only changes made outside of the `integration-tests` directory
70-
# non-ignored - only changes except for the negated ones
72+
# core-non-ignored - all changes except for paths which do not affect core module
73+
# - This is opt-in on purpose. To be safe, new files are assumed to have an affect on core unless listed here specifically.
74+
# - For example: core module does not depend on deployment or integration-tests module.
7175
# all - changes in any directory
72-
# - This is opt-in on purpose. To be safe, new files are assumed to have an affect on CI Core unless listed here specifically.
73-
# Enable listing of files matching each filter.
74-
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
75-
# Paths will be formatted as JSON array
76+
# - This is used resolve all affected modules based on changed files
7677
list-files: json
7778
filters: |
78-
non-integration-tests:
79-
- '**'
80-
- '!integration-tests/**'
81-
non-ignored:
79+
core-non-ignored:
8280
- '**'
81+
- '!deployment/**'
8382
- '!integration-tests/**'
8483
- '!tools/secrets/**'
8584
- '!tools/goreleaser-config/**'
@@ -176,19 +175,26 @@ jobs:
176175
type:
177176
- cmd: go_core_tests
178177
os: ubuntu22.04-32cores-128GB
179-
build-solana-artifacts: 'false'
178+
should-run: ${{ needs.filter.outputs.should-run-core-tests }}
179+
180180
- cmd: go_core_tests_integration
181181
os: ubuntu22.04-32cores-128GB
182-
build-solana-artifacts: 'false'
183-
- cmd: go_core_ccip_deployment_tests
184-
os: ubuntu22.04-32cores-128GB
182+
should-run: ${{ needs.filter.outputs.should-run-core-tests }}
183+
185184
- cmd: go_core_fuzz
186185
os: ubuntu22.04-8cores-32GB
187-
build-solana-artifacts: 'false'
186+
should-run: ${{ needs.filter.outputs.should-run-core-tests }}
187+
188188
- cmd: go_core_race_tests
189189
# use 64cores for certain scheduled runs only
190190
os: ${{ needs.run-frequency.outputs.two-per-day-frequency == 'true' && 'ubuntu-latest-64cores-256GB' || 'ubuntu-latest-32cores-128GB' }}
191-
build-solana-artifacts: 'false'
191+
should-run: ${{ needs.filter.outputs.should-run-core-tests }}
192+
193+
- cmd: go_core_ccip_deployment_tests
194+
os: ubuntu22.04-32cores-128GB
195+
build-solana-artifacts: 'true'
196+
should-run: ${{ needs.filter.outputs.should-run-deployment-tests }}
197+
192198
name: Core Tests (${{ matrix.type.cmd }})
193199
# We don't directly merge dependabot PRs, so let's not waste the resources
194200
if: ${{ github.actor != 'dependabot[bot]' }}
@@ -210,69 +216,70 @@ jobs:
210216
find . -type f,d -exec touch -r {} -d '1970-01-01T00:00:01' {} \; || true
211217
212218
- name: Setup NodeJS
213-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
219+
if: ${{ matrix.type.should-run == 'true' }}
214220
uses: ./.github/actions/setup-nodejs
215221
with:
216222
prod: "true"
217223

218224
- name: Install Foundry
225+
if: ${{ matrix.type.should-run == 'true' }}
219226
uses: ./.github/actions/install-solidity-foundry
220227

221228
- name: Setup Go
222-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
229+
if: ${{ matrix.type.should-run == 'true' }}
223230
uses: ./.github/actions/setup-go
224231
with:
225232
# race/fuzz tests don't benefit repeated caching, so restore from develop's build cache
226233
restore-build-cache-only: ${{ matrix.type.cmd == 'go_core_fuzz' }}
227234
build-cache-version: ${{ matrix.type.cmd }}
228235

229236
- name: Setup Solana
230-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
237+
if: ${{ matrix.type.should-run == 'true' }}
231238
uses: ./.github/actions/setup-solana
232239

233240
- name: Build Solana artifacts
234241
# do not build for core tests, core 'integration' tests, or fuzz tests
235-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' && matrix.type.build-solana-artifacts != 'false' }}
242+
if: ${{ matrix.type.should-run == 'true' && matrix.type.build-solana-artifacts == 'true' }}
236243
uses: ./.github/actions/setup-solana/build-contracts
237244
with:
238245
github-token: ${{ secrets.GITHUB_TOKEN }}
239246

240247
- name: Setup wasmd
241-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
248+
if: ${{ matrix.type.should-run == 'true' }}
242249
uses: ./.github/actions/setup-wasmd
243250

244251
- name: Setup Postgres
245-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
252+
if: ${{ matrix.type.should-run == 'true' }}
246253
uses: smartcontractkit/.github/actions/setup-postgres@7aa7ce23687ba493e9ba9c6ad47a063e60ae3433 # [email protected]
247254

248255
- name: Touching core/web/assets/index.html
249-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
256+
if: ${{ matrix.type.should-run == 'true' }}
250257
run: mkdir -p core/web/assets && touch core/web/assets/index.html
251258

252259
- name: Download Go vendor packages
253-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
260+
if: ${{ matrix.type.should-run == 'true' }}
254261
run: go mod download
255262

256263
- name: Setup DB
257-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
264+
if: ${{ matrix.type.should-run == 'true' }}
258265
run: go run ./core/store/cmd/preparetest
259266
env:
260267
CL_DATABASE_URL: ${{ env.DB_URL }}
261268

262269
- name: Install LOOP Plugins
263-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
270+
if: ${{ matrix.type.should-run == 'true' }}
264271
run: make install-plugins
265272

266273
- name: Increase Timeouts for Fuzz/Race
267274
# Increase timeouts for scheduled runs only
268-
if: ${{ github.event.schedule != '' && needs.filter.outputs.should-run-ci-core == 'true' }}
275+
if: ${{ github.event.schedule != '' && matrix.type.should-run == 'true' }}
269276
run: |
270277
echo "TIMEOUT=10m" >> $GITHUB_ENV
271278
echo "COUNT=50" >> $GITHUB_ENV
272279
echo "FUZZ_TIMEOUT_MINUTES=10">> $GITHUB_ENV
273280
274281
- name: Run tests
275-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
282+
if: ${{ matrix.type.should-run == 'true' }}
276283
id: run-tests
277284
env:
278285
OUTPUT_FILE: ./output.txt
@@ -284,7 +291,7 @@ jobs:
284291
285292
- name: Print Races
286293
id: print-races
287-
if: ${{ failure() && matrix.type.cmd == 'go_core_race_tests' && needs.filter.outputs.should-run-ci-core == 'true' }}
294+
if: ${{ failure() && matrix.type.cmd == 'go_core_race_tests' && matrix.type.should-run == 'true' }}
288295
env:
289296
GH_REPO: ${{ github.repository }}
290297
GH_RUN_ID: ${{ github.run_id }}
@@ -304,13 +311,13 @@ jobs:
304311
echo "github.ref: ${{ github.ref }}"
305312
306313
- name: Print postgres logs
307-
if: ${{ always() && needs.filter.outputs.should-run-ci-core == 'true' }}
314+
if: ${{ always() && matrix.type.should-run == 'true' }}
308315
uses: smartcontractkit/.github/actions/setup-postgres@7aa7ce23687ba493e9ba9c6ad47a063e60ae3433 # [email protected]
309316
with:
310317
print-logs: 'true'
311318

312319
- name: Store logs artifacts
313-
if: ${{ always() && needs.filter.outputs.should-run-ci-core == 'true' }}
320+
if: ${{ always() && matrix.type.should-run == 'true' }}
314321
uses: actions/upload-artifact@v4
315322
with:
316323
name: ${{ matrix.type.cmd }}_logs
@@ -328,7 +335,7 @@ jobs:
328335
matrix.type.cmd == 'go_core_race_tests' &&
329336
steps.print-races.outputs.post_to_slack == 'true' &&
330337
(github.event_name == 'merge_group' || github.ref == 'refs/heads/develop') &&
331-
needs.filter.outputs.should-run-ci-core == 'true'
338+
matrix.type.should-run == 'true'
332339
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
333340
with:
334341
method: chat.postMessage
@@ -341,7 +348,7 @@ jobs:
341348
name: test-scripts
342349
needs: [filter]
343350
runs-on: ubuntu-latest
344-
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }}
351+
if: ${{ needs.filter.outputs.should-run-core-tests == 'true' }}
345352
steps:
346353
- name: Checkout
347354
uses: actions/checkout@v4

0 commit comments

Comments
 (0)