Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: only run jobs when relevant files have been changed #12006

Merged
merged 25 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 118 additions & 4 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,99 @@ permissions:
contents: read

jobs:
changed-files:
name: Get changed files
outputs:
# reference: https://github.com/tj-actions/changed-files#outputs-
tests: ${{ steps.changed-files.outputs.tests_any_modified == 'true' }}
e2e-tests: ${{ steps.changed-files.outputs.e2e-tests_any_modified == 'true' }}
codegen: ${{ steps.changed-files.outputs.codegen_any_modified == 'true' }}
lint: ${{ steps.changed-files.outputs.lint_any_modified == 'true' }}
ui: ${{ steps.changed-files.outputs.ui_any_modified == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50 # assume PRs are less than 50 commits
- name: Get relevant files changed per group
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
id: changed-files
uses: tj-actions/changed-files@v39
with:
files_yaml: |
common: &common
- .github/workflows/ci-build.yaml
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
- Makefile
- tasks.yaml
tests: &tests
- *common
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned in the PR description, tj-actions/changed-files supports a YAML variant that has array anchors & aliases

- cmd/**
- config/**
- errors/**
- persist/**
- pkg/**
- server/**
- test/**
- util/**
- workflow/**
- go.mod
- go.sum
e2e-tests:
- *tests
# plus manifests and SDKs that are used in E2E tests
- manifests/**
- sdks/**
codegen:
- *common
# generated files
- api/**
- docs/fields.md
- docs/executor_swagger.md
- docs/cli/**
- pkg/**
- sdks/java/**
- sdks/python/**
# files that generation is based off
- pkg/**
- cmd/**
- examples/** # examples are used within the fields lists
# generation scripts
- hack/cli/**
- hack/jsonschema/**
- hack/swagger/**
- hack/auto-gen-msg.sh
- hack/crdgen.sh
- hack/crds.go
- hack/docgen.go
- hack/parse_examples.go
- hack/swaggify.sh
- .clang-format
lint:
- *tests
# plus lint config
- .golangci.yml
# docs files below
- docs/**
# generated files are covered by codegen
- '!docs/fields.md'
- '!docs/executor_swagger.md'
- '!docs/cli/**'
# proposals live only on GH as pure markdown
- '!docs/proposals/**'
# docs scripts & tools from `make docs`
- hack/check-mkdocs.sh
- hack/check-env-doc.sh
- .markdownlint.yaml
- .mlc_config.json
- .spelling
- mkdocs.yml
ui:
- *common
- ui/**

tests:
name: Unit Tests
needs: [ changed-files ]
if: ${{ needs.changed-files.outputs.tests == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -59,7 +150,8 @@ jobs:

e2e-tests:
name: E2E Tests
needs: [ argoexec-image ]
needs: [ changed-files, argoexec-image ]
if: ${{ needs.changed-files.outputs.e2e-tests == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
env:
Expand Down Expand Up @@ -198,9 +290,28 @@ jobs:
if: ${{ failure() }}
run: kubectl logs -c wait -l workflows.argoproj.io/workflow --prefix

# 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/orgs/community/discussions/9141#discussioncomment-2296809 and https://github.com/orgs/community/discussions/26822#discussioncomment-3305794
e2e-tests-composite-result:
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
name: E2E Tests - Composite result
needs: [ e2e-tests ]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- run: |
result="${{ needs.e2e-tests.result }}"
# mark as successful even if skipped
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi

codegen:
name: Codegen
needs: [ tests ]
needs: [ changed-files ]
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ needs.changed-files.outputs.codegen == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 20
env:
Expand Down Expand Up @@ -236,9 +347,10 @@ jobs:

lint:
name: Lint
needs: [ tests, codegen ]
needs: [ changed-files ]
if: ${{ needs.changed-files.outputs.lint == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 15 # must be strictly greater than the timeout in .golancgi.yml
timeout-minutes: 15 # must be strictly greater than the timeout in .golangci.yml
env:
GOPATH: /home/runner/go
steps:
Expand All @@ -254,6 +366,8 @@ jobs:

ui:
name: UI
needs: [ changed-files ]
if: ${{ needs.changed-files.outputs.ui == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 6
env:
Expand Down