diff --git a/.github/actions/golangci-lint/action.yml b/.github/actions/golangci-lint/action.yml index 20ad2689deb..d81555d974b 100644 --- a/.github/actions/golangci-lint/action.yml +++ b/.github/actions/golangci-lint/action.yml @@ -42,10 +42,6 @@ runs: - name: Touching core/web/assets/index.html shell: bash run: mkdir -p core/web/assets && touch core/web/assets/index.html - - name: Build binary - working-directory: ${{ inputs.go-directory }} - shell: bash - run: go build ./... - name: Set golangci-lint working directory shell: bash id: set-working-directory diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index c38ecd918ae..824c1654164 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -33,6 +33,7 @@ jobs: permissions: pull-requests: read outputs: + affected-packages: ${{ steps.filter.outputs.changes }} deployment-changes: ${{ steps.match-some.outputs.deployment == 'true' }} should-run-ci-core: ${{ steps.match-some.outputs.core-ci == 'true' || steps.match-every.outputs.non-ignored == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }} should-run-golangci: ${{ steps.match-some.outputs.golang-ci == 'true' || steps.match-every.outputs.non-ignored == 'true' || github.event_name == 'workflow_dispatch' }} @@ -47,7 +48,7 @@ jobs: 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 to files in `deployments/` + # deployment - any changes to files in the `deployments/` # core-ci - any changes that could affect this workflow definition # golang-ci - any changes that could affect the linting result filters: | @@ -75,6 +76,7 @@ jobs: non-ignored: - '**' - '!docs/**' + - '!fuzz/**' - '!integration-tests/**' - '!tools/secrets/**' - '!tools/goreleaser-config/**' @@ -91,11 +93,64 @@ jobs: - '!nix-darwin-shell-hook.sh' - '!LICENSE' - '!.github/**' - + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + id: filtered-packages + with: + filters: | + changes: + - '**' + - 'ccip/**' + - 'common/**' + - 'core/**' + - 'dashboard-lib/**' + - 'deployment/**' + - '!contracts/**' + - '!docs/**' + - '!fuzz/**' + - '!tools/**' + - '!integration-tests/**' + - '!integration-tests-v2/**' + - '!internal/**' + - '!testdata/**' + - '!**/README.md' + - '!**/CHANGELOG.md' + - '!.goreleaser.develop.yaml' + - '!.goreleaser.devspace.yaml' + - '!.goreleaser.production.yaml' + - '!*.nix' + - '!sonar-project.properties' + - '!nix.conf' + - '!nix-darwin-shell-hook.sh' + - '!LICENSE' + - '!.github/**' + + + # # Golangci-lint needs path to each module to run in monorepo, + # # so we resolve the modules first + # resolve-modules: + # name: Resolve Modules for GolangCI Lint + # # We don't directly merge dependabot PRs, so let's not waste the resources + # if: ${{ (github.event_name == 'pull_request' || github.event_name == 'schedule') && github.actor != 'dependabot[bot]' }} + # needs: [filter, run-frequency] + # runs-on: ubuntu-latest + # outputs: + # matrix: ${{ steps.set-modules.outputs.matrix }} + # steps: + # - name: Checkout + # uses: actions/checkout@v4.2.1 + # - name: Set Modules for GolangCI Lint + # id: set-modules + # if: ${{ needs.filter.outputs.should-run-golangci == 'true' }} + # run: | + # PATHS_TO_GO_MOD=$(find . -type f -name go.mod | awk -F'/go.mod' '{if ($1 == ".") print "./"; else print $1}') + # PATHS_TO_GO_MOD_JSON=$(echo "$PATHS_TO_GO_MOD" | jq -R -s -c 'split("\n")[:-1]') + # echo "matrix=${PATHS_TO_GO_MOD_JSON}" >> $GITHUB_OUTPUT + golangci: + name: lint # We don't directly merge dependabot PRs, so let's not waste the resources if: ${{ (github.event_name == 'pull_request' || github.event_name == 'schedule') && github.actor != 'dependabot[bot]' }} - name: lint + needs: [filter, run-frequency] permissions: # For golangci-lint-actions to annotate code in the PR. checks: write @@ -103,12 +158,17 @@ jobs: # For golangci-lint-action's `only-new-issues` option. pull-requests: read runs-on: ubuntu-24.04-8cores-32GB-ARM - needs: [filter, run-frequency] + strategy: + matrix: + modules: ${{ fromJson(needs.filter.outputs.changes) }} steps: - - uses: actions/checkout@v4.2.1 - - name: Golang Lint - uses: ./.github/actions/golangci-lint + - name: Checkout + uses: actions/checkout@v4.2.1 + - name: Golang Lint (${{ matrix.modules }}) if: ${{ needs.filter.outputs.should-run-golangci == 'true' }} + uses: ./.github/actions/golangci-lint + with: + go-directory: ${{ matrix.modules }} - name: Notify Slack if: ${{ failure() && needs.run-frequency.outputs.one-per-day-frequency == 'true' }} uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0