From 189d5d2a26b99337a6e01071182963716f453e36 Mon Sep 17 00:00:00 2001 From: Anurag Rajawat Date: Wed, 22 May 2024 15:05:57 +0530 Subject: [PATCH] fix(CI): Run CI based on conditional changes Signed-off-by: Anurag Rajawat --- .github/workflows/pr-checks.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index dba82763..0ab2d386 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -4,6 +4,10 @@ name: PR checks on: + push: + branches: + - fix-ci + - main pull_request: types: [ opened, reopened, synchronize, ready_for_review ] paths-ignore: @@ -29,6 +33,9 @@ jobs: static-checks: name: Static checks runs-on: ubuntu-latest + outputs: + nimbus: ${{ steps.filter.outputs.nimbus}} + adapters: ${{ steps.filter.outputs.adapters }} steps: - uses: actions/checkout@v3 @@ -37,10 +44,29 @@ jobs: with: go-version: '1.22' + # Checks to see if any files in the PR match one of the listed file types. + # We can use this filter to decide whether to run linters, tests or build container image. + # You can check if a file with a listed file type is in the PR by doing: + # if: ${{ steps.filter.outputs.nimbus == 'true' }} + - name: Detect what files changed + uses: dorny/paths-filter@v3.0.2 + id: filter + with: + filters: | + nimbus: + - 'api/**' + - 'cmd/**' + - 'internal/**' + - 'pkg/processor/**' + adapters: + - 'pkg/adapter/**' + - name: go fmt + if: ${{ steps.filter.outputs.nimbus == 'true' || steps.filter.outputs.adapters == 'true' }} run: make fmt - name: Lint + if: ${{ steps.filter.outputs.nimbus == 'true' || steps.filter.outputs.adapters == 'true' }} id: lint uses: golangci/golangci-lint-action@v3 with: @@ -49,6 +75,7 @@ jobs: skip-cache: true # https://github.com/golangci/golangci-lint-action/issues/244#issuecomment-1052197778 go-sec: + if: ${{ steps.filter.outputs.nimbus == 'true' || steps.filter.outputs.adapters == 'true' }} runs-on: ubuntu-latest permissions: security-events: write @@ -70,6 +97,7 @@ jobs: sarif_file: results.sarif build-nimbus-image: + if: ${{ steps.filter.outputs.nimbus == 'true' }} name: Build Nimbus Operator image runs-on: ubuntu-latest timeout-minutes: 20 @@ -81,6 +109,7 @@ jobs: run: make docker-build build-adapters-image: + if: ${{ steps.filter.outputs.adapters == 'true' }} strategy: matrix: adapters: [ "nimbus-kubearmor", "nimbus-netpol", "nimbus-kyverno" ] @@ -96,6 +125,7 @@ jobs: run: make docker-build chainsaw-integration-tests: + if: ${{ steps.filter.outputs.nimbus == 'true' }} name: Integration-Test runs-on: ubuntu-latest steps: @@ -131,6 +161,7 @@ jobs: run: make integration-test chainsaw-e2e-tests: + if: ${{ steps.filter.outputs.nimbus == 'true' || steps.filter.outputs.adapters == 'true' }} name: E2E-Test runs-on: ubuntu-latest steps: