Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimize run conditions for conditional unit tests #15583

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 75 additions & 6 deletions .github/workflows/ci-core-partial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }})
Expand All @@ -53,39 +110,49 @@ 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
if: ${{ matrix.type.should-run }}
uses: actions/[email protected]

- name: Setup NodeJS
if: ${{ matrix.type.should-run }}
uses: ./.github/actions/setup-nodejs
with:
prod: "true"

- name: Setup Go
if: ${{ matrix.type.should-run }}
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 }}
uses: ./.github/actions/setup-solana

- name: Setup wasmd
if: ${{ matrix.type.should-run }}
uses: ./.github/actions/setup-wasmd

- name: Setup Postgres
if: ${{ matrix.type.should-run }}
uses: ./.github/actions/setup-postgres

- name: Setup CI Core Environment
if: ${{ matrix.type.should-run }}
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 }}
uses: smartcontractkit/.github/apps/go-conditional-tests@37882e110590e636627a26371bdbd56ddfcce821 # [email protected]
timeout-minutes: 10
with:
Expand All @@ -98,6 +165,7 @@ jobs:
build-flags: ${{ matrix.type.build-flags }}

- name: Run Tests
if: ${{ matrix.type.should-run }}
uses: smartcontractkit/.github/apps/go-conditional-tests@37882e110590e636627a26371bdbd56ddfcce821 # [email protected]
timeout-minutes: 15
env:
Expand All @@ -112,6 +180,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Update Test Index
if: ${{ matrix.type.should-run }}
uses: smartcontractkit/.github/apps/go-conditional-tests@37882e110590e636627a26371bdbd56ddfcce821 # [email protected]
with:
pipeline-step: "update"
Expand All @@ -120,7 +189,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Print postgres logs
if: ${{ always() }}
if: ${{ always() && matrix.type.should-run }}
run: docker compose logs postgres | tee ../../../postgres_logs.txt
working-directory: ./.github/actions/setup-postgres

Expand Down
Loading