Skip to content

Commit

Permalink
chore(ci): run ci checks conditionally (argoproj#16982)
Browse files Browse the repository at this point in the history
* chore(ci): run ci checks conditionally

This should prevent docs changes from having the need to run e2e tests
etc, and prevent backend changes from needing to run ui tests, and vice
versa.

This is similar to previous attempts (see argoproj#16706 and argoproj#13507), with the
difference here that we add the if checks on each _step_ rather than
each _job_ - the reason being that most of these jobs are required, and
if we skip whole jobs any PR which does this will be left hanging
indefinitely, so Github forces us to do this on a step level instead.

Signed-off-by: Blake Pettersson <[email protected]>

* chore(ci): run ci checks conditionally

Try conditional jobs, according to https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks

Signed-off-by: Blake Pettersson <[email protected]>

* chore(ci): add composite test-e2e action

This is a workaround for the e2e tests which do not run yet report `pending` when they are actually skipped.

Signed-off-by: Blake Pettersson <[email protected]>

---------

Signed-off-by: Blake Pettersson <[email protected]>
Co-authored-by: Remington Breeze <[email protected]>
Co-authored-by: Ishita Sequeira <[email protected]>
Signed-off-by: Kevin Lyda <[email protected]>
  • Loading branch information
3 people authored and lyda committed Mar 28, 2024
1 parent 492f493 commit 38e1fa2
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,25 @@ permissions:
contents: read

jobs:
changes:
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2
id: filter
with:
filters: |
backend:
- '!(ui/**)'
- '!(**/*.md)'
frontend:
- 'ui/**'
check-go:
name: Ensure Go modules synchronicity
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand All @@ -43,6 +60,7 @@ jobs:
build-go:
name: Build & cache Go code
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand All @@ -67,6 +85,7 @@ jobs:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: Lint Go code
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand All @@ -83,6 +102,7 @@ jobs:

test-go:
name: Run unit tests for Go packages
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
needs:
- build-go
Expand Down Expand Up @@ -150,6 +170,7 @@ jobs:

test-go-race:
name: Run unit tests with -race for Go packages
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
needs:
- build-go
Expand Down Expand Up @@ -212,6 +233,7 @@ jobs:

codegen:
name: Check changes to generated code
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand Down Expand Up @@ -260,6 +282,7 @@ jobs:

build-ui:
name: Build, test & lint UI code
if: ${{ needs.changes.outputs.frontend == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand Down Expand Up @@ -292,6 +315,7 @@ jobs:

analyze:
name: Process & analyze test artifacts
if: ${{ needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' }}
runs-on: ubuntu-22.04
needs:
- test-go
Expand All @@ -315,7 +339,7 @@ jobs:
- name: Create test-results directory
run: |
mkdir -p test-results
- name: Get code coverage artifiact
- name: Get code coverage artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: code-coverage
Expand Down Expand Up @@ -358,6 +382,7 @@ jobs:

test-e2e:
name: Run end-to-end tests
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -462,3 +487,25 @@ jobs:
name: e2e-server-k8s${{ matrix.k3s-version }}.log
path: /tmp/e2e-server.log
if: ${{ failure() }}

# workaround for status checks -- check this one job instead of each individual E2E job in the matrix
# this allows us to skip the entire matrix when it doesn't need to run while still having accurate status checks
# see:
# https://github.com/argoproj/argo-workflows/pull/12006
# https://github.com/orgs/community/discussions/9141#discussioncomment-2296809
# https://github.com/orgs/community/discussions/26822#discussioncomment-3305794
test-e2e-composite-result:
name: E2E Tests - Composite result
if: ${{ always() }}
needs:
- test-e2e
runs-on: ubuntu-22.04
steps:
- run: |
result="${{ needs.test-e2e.result }}"
# mark as successful even if skipped
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi

0 comments on commit 38e1fa2

Please sign in to comment.