-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: skip tests if unaffected TASK-1316 (#5295)
### 💭 Notes Trigger PR workflows based on files affected. The lists of path matchers corresponding to pytest, npm-test, darker are in .github/filters.yml. For a given CI run, the "Detect changed files" step shows a list of files changed and which filters were matched by them. You can inspect this on GitHub: -> Click "Details" on a PR step -> Click the "changes" job -> Expand the "Detect Changed Files" step -> Expand individual logs to see: - list of files changed - list of filters triggered Ideally, these filters always match whenever a PR has any chance of affecting a job's pass/fail result. ### 👀 Preview steps 1. 🟢 See the "Checks" section of this PR, or screenshots in the description 2. 🟢 Notice the addition of the "ci / changes" job, which runs first and may cause pytest, npm-test, or darker to be skipped if no relevant files are changed
- Loading branch information
Showing
5 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Path filters. Used by workflows/ci.yml to decide which jobs to run. | ||
|
||
# If any file changed matches any of the filters in a list, the output for that | ||
# list is set to the string 'true'. | ||
|
||
darker: | ||
- '{kpi,kobo,hub}/**/*.py' # .py | ||
- 'pyproject.toml' # rules | ||
- '.github/workflows/darker.yml' # ci | ||
|
||
pytest: | ||
- '{kpi,kobo,hub}/**/*.!(md)' # backend | ||
- 'dependencies/**/*.!(md)' # pip | ||
- 'pyproject.toml' # (can affect build/tests) | ||
- '.github/workflows/pytest.yml' # ci | ||
|
||
npm-test: | ||
- '{jsapp,test,webpack,static,scripts}/**/*.!(md|py|sh|bash)' # frontend | ||
- '{package*.json,patches/*.patch,scripts/copy_fonts.py}' # npm + postinstall | ||
- '{tsconfig.json,.swcrc,.babelrc*,.browserslistrc}' # compilers | ||
- '{.editorconfig,.prettier*,.stylelint*,.eslint*,coffeelint*}' # linters | ||
- '.gitignore' # (can affect tools) | ||
- '.github/workflows/npm-test.yml' # ci |
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: ci | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
permissions: { pull-requests: read } | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: filter | ||
uses: dorny/paths-filter@v3 | ||
name: Detect changed files | ||
with: { filters: .github/filters.yml } | ||
outputs: | ||
darker: ${{ steps.filter.outputs.darker }} | ||
pytest: ${{ steps.filter.outputs.pytest }} | ||
npm-test: ${{ steps.filter.outputs.npm-test }} | ||
|
||
darker: | ||
needs: changes | ||
uses: ./.github/workflows/darker.yml | ||
if: needs.changes.outputs.darker == 'true' | ||
|
||
pytest: | ||
needs: changes | ||
uses: ./.github/workflows/pytest.yml | ||
if: needs.changes.outputs.pytest == 'true' | ||
|
||
npm-test: | ||
needs: changes | ||
uses: ./.github/workflows/npm-test.yml | ||
if: needs.changes.outputs.npm-test == 'true' |
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Python linter (Darker) | ||
|
||
on: [pull_request] | ||
on: workflow_call | ||
jobs: | ||
darker: | ||
runs-on: ubuntu-latest | ||
|
This file contains 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: npm-test | |
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
|
This file contains 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ name: pytest | |
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
|