-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize run conditions for conditional unit tests
- Loading branch information
Showing
1 changed file
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,27 +17,84 @@ env: | |
|
||
jobs: | ||
filter: | ||
name: Detect Changes | ||
name: Filter Changes | ||
permissions: | ||
pull-requests: read | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should-run-all-tests: ${{ steps.match-some.outputs.test-data == 'true' }} | ||
should-run-core-tests: > | ||
${{ | ||
steps.every.outputs.core-changes == 'true' || | ||
steps.some.outputs.workflow-changes == 'true' || | ||
github.event_name == 'schedule' || | ||
(github.event_name == 'push' && github.ref == 'refs/heads/develop') | ||
}} | ||
should-run-ccip-tests: > | ||
${{ | ||
steps.every.outputs.deployment-changes == 'true' || | ||
steps.some.outputs.workflow-changes == 'true' || | ||
github.event_name == 'schedule' || | ||
(github.event_name == 'push' && github.ref == 'refs/heads/develop') | ||
}} | ||
should-run-all-tests: > | ||
${{ | ||
steps.some.outputs.test-data-changes == 'true' || | ||
github.event_name == 'schedule' | ||
}} | ||
should-collect-coverage: ${{ github.event_name == 'schedule' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
repository: smartcontractkit/chainlink | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
id: match-some | ||
id: some | ||
with: | ||
# "if any changed file matches one or more of the conditions" (https://github.com/dorny/paths-filter/issues/225) | ||
predicate-quantifier: some | ||
# test-data - any changes to any testdata files/paths | ||
filters: | | ||
test-data: | ||
test-data-changes: | ||
- '**/testdata/**' | ||
workflow-changes: | ||
- '.github/workflows/ci-core-partial.yml' | ||
- '.github/actions/**' | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
id: every | ||
with: | ||
# "if any changed file matches all of the conditions" (https://github.com/dorny/paths-filter/issues/225) | ||
predicate-quantifier: every | ||
# Allows us to negate certain paths, allowing creating a list of opt-out paths. | ||
# - This is opt-out on purpose. To be safe, new paths are assumed to have an effect unless listed here specifically. | ||
filters: | | ||
ignored: &ignored | ||
- '!integration-tests/**' | ||
- '!tools/secrets/**' | ||
- '!tools/goreleaser-config/**' | ||
- '!tools/docker/**' | ||
- '!tools/benchmark/**' | ||
- '!**/README.md' | ||
- '!**/CHANGELOG.md' | ||
- '!LICENSE' | ||
- '!.goreleaser.develop.yaml' | ||
- '!.goreleaser.devspace.yaml' | ||
- '!.goreleaser.production.yaml' | ||
- '!sonar-project.properties' | ||
- '!*.nix' | ||
- '!nix.conf' | ||
- '!nix-darwin-shell-hook.sh' | ||
- '!.github/**' | ||
- '!.changeset/**' | ||
core-changes: | ||
- '**' | ||
- '!deployment/**' | ||
- *ignored | ||
deployment-changes: | ||
- '**' | ||
- *ignored | ||
run-unit-tests: | ||
name: Tests (${{ matrix.type.test-suite }}) | ||
|
@@ -53,39 +110,48 @@ jobs: | |
- test-suite: "core" | ||
module-directory: "./" | ||
build-flags: "-tags=integration" | ||
should-run: ${{ needs.filter.outputs.should-run-core-tests == 'true' }} | ||
- test-suite: "ccip-deployment" | ||
module-directory: "./deployment" | ||
should-run: ${{ needs.filter.outputs.should-run-ccip-tests == 'true' }} | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
|
||
- name: Setup NodeJS | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: ./.github/actions/setup-nodejs | ||
with: | ||
prod: "true" | ||
|
||
- name: Setup Go | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: ./.github/actions/setup-go | ||
with: | ||
build-cache-version: ${{ matrix.type.test-suite }} | ||
restore-build-cache-only: "false" | ||
|
||
- name: Setup Solana | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: ./.github/actions/setup-solana | ||
|
||
- name: Setup wasmd | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: ./.github/actions/setup-wasmd | ||
|
||
- name: Setup Postgres | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: ./.github/actions/setup-postgres | ||
|
||
- name: Setup CI Core Environment | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: ./.github/actions/setup-ci-core-tests | ||
with: | ||
db-url: ${{ env.DB_URL }} | ||
go-mod-download-directory: ${{ matrix.type.test-suite == 'ccip-deployment' && matrix.type.module-directory || '' }} | ||
|
||
- name: Build Tests | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: smartcontractkit/.github/apps/go-conditional-tests@37882e110590e636627a26371bdbd56ddfcce821 # [email protected] | ||
timeout-minutes: 10 | ||
with: | ||
|
@@ -98,6 +164,7 @@ jobs: | |
build-flags: ${{ matrix.type.build-flags }} | ||
|
||
- name: Run Tests | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: smartcontractkit/.github/apps/go-conditional-tests@37882e110590e636627a26371bdbd56ddfcce821 # [email protected] | ||
timeout-minutes: 15 | ||
env: | ||
|
@@ -112,6 +179,7 @@ jobs: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update Test Index | ||
if: ${{ matrix.type.should-run == 'true' }} | ||
uses: smartcontractkit/.github/apps/go-conditional-tests@37882e110590e636627a26371bdbd56ddfcce821 # [email protected] | ||
with: | ||
pipeline-step: "update" | ||
|