From 2439f6ffc5780e2c46f31215002e1b6ff7993f81 Mon Sep 17 00:00:00 2001 From: Erik Burton Date: Wed, 13 Nov 2024 13:23:39 -0800 Subject: [PATCH] fix: golangci lint cicd (#15161) --- .github/actions/golangci-lint/action.yml | 17 ++++++++++------- .github/workflows/ci-core.yml | 15 +++++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/actions/golangci-lint/action.yml b/.github/actions/golangci-lint/action.yml index ddfae02a895..20ad2689deb 100644 --- a/.github/actions/golangci-lint/action.yml +++ b/.github/actions/golangci-lint/action.yml @@ -1,10 +1,6 @@ name: CI lint for Golang description: Runs CI lint for Golang inputs: - # general inputs - name: - description: Name of the lint action - required: true go-directory: description: Go directory to run commands from default: "." @@ -25,10 +21,17 @@ inputs: runs: using: composite steps: - - uses: actions/checkout@v4.2.1 + - name: Checkout repo (full) + uses: actions/checkout@v4.2.1 + # Only do a full checkout on merge_groups + if: github.event_name == 'merge_group' with: - # We only need a full clone on merge_group events for golangci-lint. - fetch-depth: ${{ github.event_name == 'merge_group' && '0' || '1' }}" + fetch-depth: 0 + - name: Checkout repo + uses: actions/checkout@v4.2.1 + if: github.event_name != 'merge_group' + with: + fetch-depth: 1 - name: Setup Go uses: ./.github/actions/setup-go with: diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 3a32d7e12c7..23f4382f62a 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -34,8 +34,8 @@ jobs: pull-requests: read outputs: deployment-changes: ${{ steps.match-some.outputs.deployment == 'true' }} - should-run-ci-core: ${{ steps.match-every.outputs.non-ignored == 'true' || steps.match-some.outputs.core-ci == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }} - should-run-golangci: ${{ steps.match-every.outputs.non-integration-tests == 'true' || github.event_name == 'workflow_dispatch' }} + 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' }} runs-on: ubuntu-latest steps: - name: Checkout the repo @@ -48,19 +48,25 @@ jobs: # "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/` + # core-ci - any changes that could affect this workflow definition + # golang-ci - any changes that could affect the linting result filters: | deployment: - 'deployment/**' core-ci: - '.github/workflows/ci-core.yml' - '.github/actions/**' + golang-ci: + - '.golangci.yml' + - '.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) predicate-quantifier: every # non-integration-tests - only changes made outside of the `integration-tests` directory - # everything-except-ignored - only changes except for the negated ones + # non-ignored - only changes except for the negated ones # - This is opt-in on purpose. To be safe, new files are assumed to have an affect on CI Core unless listed here specifically. filters: | non-integration-tests: @@ -103,9 +109,6 @@ jobs: - name: Golang Lint uses: ./.github/actions/golangci-lint if: ${{ needs.filter.outputs.should-run-golangci == 'true' }} - with: - id: core - name: lint - name: Notify Slack if: ${{ failure() && needs.run-frequency.outputs.one-per-day-frequency == 'true' }} uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0