-
Notifications
You must be signed in to change notification settings - Fork 904
refactor(ci): conditionally run jobs based on file changes #4242
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9ded224
refactor(ci): only run ts jobs on ts changes
jsjoeio b67296c
refactor(ci): only run lint-shellcheck on sh changes
jsjoeio bebfe7e
refactor(ci): only run go jobs on go changes
jsjoeio 6479ff7
refactor(ci): only run style-fmt when needed
jsjoeio bdea460
refactor(ci): run e2e on go, ts or tf changes
jsjoeio d0a5ba1
refactor(ci): run gen on gen changes
jsjoeio 22cd63b
refactor(ci): delete old comments
jsjoeio 38dd1f3
fixup: try moving if step inside test-go job
jsjoeio bc24aea
fixup: try if all steps
jsjoeio 22758e7
fixup!: refactor(ci): run gen on gen changes
jsjoeio 15d2e8c
Revert "refactor(ci): run gen on gen changes"
jsjoeio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,12 @@ jobs: | |
- '**' | ||
docs: | ||
- 'docs/**' | ||
# For testing: | ||
# - '.github/**' | ||
sh: | ||
- "**.sh" | ||
go: | ||
- "**.go" | ||
tf: | ||
- "**.tf" | ||
ts: | ||
- 'site/**' | ||
k8s: | ||
|
@@ -92,6 +94,8 @@ jobs: | |
name: style/lint/golangci | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
if: needs.changes.outputs.go == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
|
@@ -115,6 +119,8 @@ jobs: | |
name: style/lint/shellcheck | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
if: needs.changes.outputs.sh == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run ShellCheck | ||
|
@@ -128,6 +134,8 @@ jobs: | |
name: "style/lint/typescript" | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
if: needs.changes.outputs.ts == 'true' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
@@ -247,6 +255,8 @@ jobs: | |
name: "style/fmt" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
needs: changes | ||
if: needs.changes.outputs.sh == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.tf == 'true' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
@@ -280,6 +290,7 @@ jobs: | |
name: "test/go" | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 20 | ||
needs: changes | ||
strategy: | ||
matrix: | ||
os: | ||
|
@@ -288,30 +299,36 @@ jobs: | |
- windows-2022 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
if: needs.changes.outputs.go == 'true' | ||
|
||
- uses: actions/setup-go@v3 | ||
if: needs.changes.outputs.go == 'true' | ||
with: | ||
go-version: "~1.19" | ||
|
||
- name: Echo Go Cache Paths | ||
if: needs.changes.outputs.go == 'true' | ||
id: go-cache-paths | ||
run: | | ||
echo "::set-output name=go-build::$(go env GOCACHE)" | ||
echo "::set-output name=go-mod::$(go env GOMODCACHE)" | ||
|
||
- name: Go Build Cache | ||
if: needs.changes.outputs.go == 'true' | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.go-cache-paths.outputs.go-build }} | ||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }} | ||
|
||
- name: Go Mod Cache | ||
if: needs.changes.outputs.go == 'true' | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.go-cache-paths.outputs.go-mod }} | ||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Install gotestsum | ||
if: needs.changes.outputs.go == 'true' | ||
uses: jaxxstorm/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -320,11 +337,13 @@ jobs: | |
tag: v1.7.0 | ||
|
||
- uses: hashicorp/setup-terraform@v2 | ||
if: needs.changes.outputs.go == 'true' | ||
with: | ||
terraform_version: 1.1.9 | ||
terraform_wrapper: false | ||
|
||
- name: Test with Mock Database | ||
if: needs.changes.outputs.go == 'true' | ||
id: test | ||
shell: bash | ||
run: | | ||
|
@@ -350,7 +369,7 @@ jobs: | |
# that is no guarantee, see: | ||
# https://github.com/codecov/codecov-action/issues/788 | ||
continue-on-error: true | ||
if: steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork | ||
if: steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && needs.changes.outputs.go == 'true' | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./gotests.coverage | ||
|
@@ -364,6 +383,8 @@ jobs: | |
# goroutines. Setting this to the timeout +5m should work quite well | ||
# even if some of the preceding steps are slow. | ||
timeout-minutes: 25 | ||
needs: changes | ||
if: needs.changes.outputs.go == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
|
@@ -517,6 +538,8 @@ jobs: | |
name: "test/js" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
needs: changes | ||
if: needs.changes.outputs.ts == 'true' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
|
@@ -555,9 +578,8 @@ jobs: | |
|
||
test-e2e: | ||
name: "test/e2e/${{ matrix.os }}" | ||
needs: | ||
- changes | ||
if: needs.changes.outputs.docs-only == 'false' | ||
needs: changes | ||
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.tf == 'true' | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 20 | ||
strategy: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, because this job is required, we can't use this
if
at the top or the PR status will never show Success. Alternative approach linked in PR discussion which involves creating a generic workflow with same name and running it for the opposition condition (i.e. no Go changes). I like this approach better but could be swayed the other way.