Skip to content

feat: advanced triggers#1473

Open
erikburt wants to merge 9 commits intomainfrom
feat/advanced-triggers
Open

feat: advanced triggers#1473
erikburt wants to merge 9 commits intomainfrom
feat/advanced-triggers

Conversation

@erikburt
Copy link
Contributor

@erikburt erikburt commented Mar 20, 2026

Adds a new reusable typescript action advanced-triggers which can be used to replace a lot of the conditional triggers that we using dorny/paths-filter to rely on. This can essentially further process GHA events/triggers so you can make job run conditions more granular.

See the README.md for more detailed information on this.

Testing

I tested a lot of the functionality by migrating our complex conditions in ci-core - smartcontractkit/chainlink#21627.

Before

filter:
    name: Detect Changes
    permissions:
      pull-requests: read
    outputs:
      affected-modules: ${{ steps.changed-modules.outputs.modules-json }}
      # Runs on workflow changes, any deployment change, or any (non-ignored) core change
      should-run-deployment-tests: >-
        ${{
          steps.match-some.outputs.workflow == 'true' ||
          steps.match-some.outputs.deployment == 'true' ||
          steps.match-every.outputs.core-non-ignored == 'true' ||
          github.event_name == 'schedule' ||
          github.event_name == 'workflow_dispatch'
        }}
      # Runs on workflow changes, and any (non-ignored) core changes
      should-run-core-tests: >-
        ${{
          steps.match-some.outputs.workflow == 'true' ||
          steps.match-every.outputs.core-non-ignored == 'true' ||
          github.event_name == 'schedule' ||
          github.event_name == 'workflow_dispatch'
        }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repo
        uses: actions/checkout@v4
        with:
          persist-credentials: false
          repository: smartcontractkit/chainlink
      - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
        id: match-some
        with:
          # "if any changed file matches one or more of the conditions" (https://github.com/dorny/paths-filter/issues/225)
          predicate-quantifier: some
          # deployment - any changes in the deployment module
          # workflow - any changes that could affect this workflow definition
          #  - Assume any repository action changes affect this workflow
          filters: |
            deployment:
              - 'deployment/**'
            workflow:
              - '.github/workflows/ci-core.yml'
              - '.github/actions/**'
      - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
        id: match-every
        with:
          # "if any changed file match all of the conditions" (https://github.com/dorny/paths-filter/issues/225)
          #   - Enables listing of files matching each filter.
          #   - Paths to files will be available in `${FILTER_NAME}_files` output variable.
          #   - Paths will be formatted as JSON array
          predicate-quantifier: every
          # core-non-ignored - all changes except for paths which do not affect core module
          #  - This is opt-in on purpose. To be safe, new files are assumed to have an affect on core unless listed here specifically.
          #  - For example: core module does not depend on deployment or integration-tests module.
          # all - changes in any directory
          #  - This is used resolve all affected modules based on changed files
          list-files: json
          filters: |
            core-non-ignored:
              - '**'
              - '!deployment/**'
              - '!integration-tests/**'
              - '!tools/secrets/**'
              - '!tools/docker/**'
              - '!tools/benchmark/**'
              - '!**/README.md'
              - '!**/CHANGELOG.md'
              - '!*.nix'
              - '!sonar-project.properties'
              - '!nix.conf'
              - '!nix-darwin-shell-hook.sh'
              - '!LICENSE'
              - '!.github/**'
              - '!core/scripts/cre/environment/examples/workflows/**'
            all:
              - '**'

After

  filter:
    name: Detect Changes
    permissions:
      pull-requests: read
    outputs:
      affected-modules: ${{ steps.changed-modules.outputs.modules-json }}
      core-tests: ${{ steps.triggers.outputs.core-tests }}
      core-fuzz-tests: ${{ steps.triggers.outputs.core-fuzz-tests }}
      core-race-tests: ${{ steps.triggers.outputs.core-race-tests }}
      core-integ-tests: ${{ steps.triggers.outputs.core-integration-tests }}
      deployment-tests: ${{ steps.triggers.outputs.deployment-tests }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repo
        uses: actions/checkout@v6
        with:
          persist-credentials: false
          repository: smartcontractkit/chainlink

      - name: Advanced trigger filters
        id: triggers
        uses: smartcontractkit/.github/actions/advanced-filters@feat/advanced-triggers
        with:
          file-sets: |
            go-files:
              - "**/*.go"
              - "**/go.mod"
              - "**/go.sum"
            core-files:
              - "core/**"
            all-test-files:
              - "**/testdata/**"
              - "**/*_test.go"
            core-test-files:
              - "testdata/**.go"
              - "core/**/testdata/**"
              - "core/**_test.go"
            e2e-tests-files:
              - "system-tests/**"
              - "integration-tests/**"
            workflow-files:
              - ".github/workflows/ci-core.y*ml"
              - ".github/actions/**/*.y*ml"
            deployment-files:
              - "deployment/**"
          # Note:
          # - pull_request, merge_group, and push events will resolve to true if any changed files match the path/glob patterns
          #     - exclusion-sets/negations are applied first, and therefore filter all changed files before inclusion sets are applied
          # - by default these will resolve to true for schedule, and workflow_dispatch events
          triggers: |
            core-tests:
              exclusion-sets: [ e2e-tests-files, deployment-files ]
              inclusion-sets: [go-files, core-files, all-test-files, workflow-files ]
              paths:
                - "tools/bin/go_core_tests"
            core-fuzz-tests:
              exclusion-sets: [ e2e-tests-files, deployment-files ]
              inclusion-sets: [go-files, core-files, all-test-files, workflow-files ]
              paths:
                - "!**/testdata/**"
                - "**/fuzz/**"
                - "tools/bin/go_core_fuzz"
            core-race-tests:
              exclusion-sets: [ e2e-tests-files, deployment-files ]
              inclusion-sets: [go-files, core-files, all-test-files, workflow-files ]
              paths:
                - "tools/bin/go_core_race_tests"
            core-integration-tests:
              exclusion-sets: [ e2e-tests-files, deployment-files ]
              inclusion-sets: [go-files, core-files, all-test-files, workflow-files ]
              paths:
                - "tools/bin/go_core_tests_integration"
            deployment-tests:
              exclusion-sets: [ e2e-tests-files, core-test-files ]
              inclusion-sets: [ go-files, core-files, deployment-files, workflow-files ]
              paths:
                - "tools/bin/go_core_ccip_deployment_tests"

Note: it is about the same length in terms of overall lines here. However, the after is also more granular than the dorny/paths-filter one so we should be able to skip unnecessary jobs more often.

Unit tests

Second PR to follow this one that unit tests the complex parsing and filtering logic. That will also include a changeset for versioning.


DX-3534

@erikburt erikburt self-assigned this Mar 20, 2026
@erikburt erikburt marked this pull request as ready for review March 20, 2026 22:30
@erikburt erikburt requested a review from a team as a code owner March 20, 2026 22:30
@erikburt erikburt requested a review from Copilot March 20, 2026 22:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new reusable TypeScript GitHub Action (actions/advanced-triggers) that evaluates workflow/job “triggers” based on changed files (with explicit exclusion semantics) and event types, intended to replace many dorny/paths-filter conditional patterns.

Changes:

  • Added the advanced-triggers action implementation (event parsing, changed-file detection via GitHub API or git diff, YAML-driven trigger evaluation, and outputs).
  • Added action documentation and local testing artifacts (README + scripts + sample YAML/payload).
  • Updated pnpm-lock.yaml for the new action’s dependencies.

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds dependency graph entries for the new actions/advanced-triggers workspace package.
actions/advanced-triggers/action.yml Defines action inputs/outputs and node runtime entrypoint.
actions/advanced-triggers/package.json Declares dependencies for the new action package.
actions/advanced-triggers/project.json Adds Nx build/typecheck/test targets for the action.
actions/advanced-triggers/tsconfig.json TypeScript config for the action.
actions/advanced-triggers/tsconfig.spec.json TypeScript config for tests.
actions/advanced-triggers/src/index.ts Entrypoint that invokes the action runtime.
actions/advanced-triggers/src/run.ts Orchestrates input parsing, changed-file detection, trigger evaluation, and output emission.
actions/advanced-triggers/src/run-inputs.ts Implements input + invoke-context parsing (including local debug mode mapping).
actions/advanced-triggers/src/event.ts Extracts normalized event data for supported GitHub event types.
actions/advanced-triggers/src/filters.ts Parses YAML configs and applies exclusion-first + positive match trigger semantics.
actions/advanced-triggers/src/git.ts Computes changed files via git diff (currently with a git pull retry path).
actions/advanced-triggers/src/github.ts Retrieves PR changed files via the GitHub API (paginate listFiles).
actions/advanced-triggers/src/tests/index.test.ts Adds a placeholder test scaffold.
actions/advanced-triggers/scripts/test.sh Local script for building/running the action with a simulated event payload.
actions/advanced-triggers/scripts/payload.json Sample event payload for local testing.
actions/advanced-triggers/scripts/file-sets.yml Example file-set definitions used by the local test script.
actions/advanced-triggers/scripts/triggers.yml Example trigger definitions used by the local test script.
actions/advanced-triggers/README.md User-facing documentation for configuration, semantics, and local testing.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@chainchad chainchad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG! Might as well upgrade the node version though.

@@ -0,0 +1,41 @@
# Trigger using inclusion-sets and exclusion-sets.
# always-trigger-on defaults to [schedule, workflow_dispatch].
ccip:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these triggers specific to the /chainlink repo? If so, I might move this file there and pass in a path to that file as input to this action to make this more generic?

description: "JSON array of trigger names that did not match"

runs:
using: "node20"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using: "node20"
using: "node24"

v20 goes EOL next month

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants