Skip to content

Commit

Permalink
fix(CI): Run CI based on conditional changes
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
Anurag Rajawat committed May 22, 2024
1 parent b6dd9b6 commit 189d5d2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
name: PR checks

on:
push:
branches:
- fix-ci
- main
pull_request:
types: [ opened, reopened, synchronize, ready_for_review ]
paths-ignore:
Expand All @@ -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

Expand All @@ -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/[email protected]
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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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" ]
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 189d5d2

Please sign in to comment.