Skip to content

Commit

Permalink
call workflows from 'ci.yml' to consolidate list
Browse files Browse the repository at this point in the history
  • Loading branch information
p2edwards committed Dec 1, 2024
1 parent f212d1f commit e546e36
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 78 deletions.
8 changes: 4 additions & 4 deletions .github/filters.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Used by workflows

should-run-npm-test:
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
Expand All @@ -13,22 +13,22 @@ should-run-npm-test:
# in a skip if the rule was already established
# - '.github/workflows/npm-test.yml' # ci

should-run-pytest:
pytest:
- '{kpi,kobo,hub}/**/*.!(md)' # backend
- 'dependencies/**/*.!(md)' # pip
- 'pyproject.toml' # (can affect build/tests)

# WIP
# - '.github/workflows/pytest.yml' # ci

should-run-darker:
darker:
- '{kpi,kobo,hub}/**/*.py' # .py
- 'pyproject.toml' # rules

# WIP
# - '.github/workflows/darker.yml' # ci

new-files-at-root-level:
unknown:
# New and unrecognized files can affect CI test results.
# - We usually want to err on the side of running tests
# instead of skipping them.
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

# 🗨️🖼️ to keep output tidy and legible, this workflow triggers most of the other ones. hence, the simple, generic name (which will show up as prefix to most others)
# 🗨️ hat tip to enketo-core - converged towards this solution and found out they did the same thing. looks good
name: ci

on:
push:
branches: [ main ]
pull_request:

jobs:
changes:
runs-on: ubuntu-latest
permissions: { pull-requests: read }
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with: { filters: .github/filters.yml }
outputs:
npm-test: ${{ steps.filter.outputs.npm-test }}
pytest: ${{ steps.filter.outputs.pytest }}
darker: ${{ steps.filter.outputs.darker }}
unknown: ${{ steps.filter.outputs.unknown }}

npm-test:
needs: changes
uses: ./.github/workflows/npm-test.yml
if: |
needs.changes.outputs.npm-test == 'true' ||
needs.changes.outputs.unknown == 'true' ||
github.event_name == 'push'
pytest:
needs: changes
uses: ./.github/workflows/pytest.yml
if: |
needs.changes.outputs.pytest == 'true' ||
needs.changes.outputs.unknown == 'true' ||
github.event_name == 'push'
darker:
needs: changes
uses: ./.github/workflows/darker.yml
if: |
needs.changes.outputs.darker == 'true' &&
github.event_name == 'pull_request'
20 changes: 3 additions & 17 deletions .github/workflows/darker.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
name: Python linter (Darker)

on: [pull_request]
jobs:
changes:
name: skip-if-unchanged
runs-on: ubuntu-22.04
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with: { filters: .github/filters.yml }
outputs:
darker: ${{ steps.filter.outputs.should-run-darker }}
on:
workflow_call:

jobs:
darker:
needs: changes
if: ${{ needs.changes.outputs.darker == 'true' }}

runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
32 changes: 3 additions & 29 deletions .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
name: Frontend
name: npm-test

on:
push:
branches: [ main ]
pull_request:
workflow_call:

jobs:

changes:
name: skip-if-unchanged
runs-on: ubuntu-22.04
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with: { filters: .github/filters.yml }
- if: ${{ steps.filter.outputs.should-run-npm-test == 'true' }}
run: echo 'frontend files changed'
- if: ${{ steps.filter.outputs.new-files-at-root-level == 'true' }}
run: echo 'unlisted files changed'
outputs:
npm-test: ${{ steps.filter.outputs.should-run-npm-test }}
new-unknown-files: ${{ steps.filter.outputs.new-files-at-root-level }}
npm-test:
if: |
github.event_name == 'push'
|| needs.changes.outputs.npm-test == 'true'
|| needs.changes.outputs.new-unknown-files == 'true'
needs: changes

build:
runs-on: ubuntu-20.04
strategy:
matrix:
Expand Down
30 changes: 2 additions & 28 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Backend
name: pytest

on:
push:
branches: [ main ]
pull_request:
workflow_call:

jobs:
changes:
name: skip-if-unchanged
runs-on: ubuntu-22.04
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with: { filters: .github/filters.yml }
- if: ${{ steps.filter.outputs.should-run-pytest == 'true' }}
run: echo 'backend files changed'
- if: ${{ steps.filter.outputs.new-files-at-root-level == 'true' }}
run: echo 'unlisted files changed'
outputs:
pytest: ${{ steps.filter.outputs.should-run-pytest }}
new-unknown-files: ${{ steps.filter.outputs.new-files-at-root-level }}
build-and-pytest:
needs: changes
if: |
github.event_name == 'push'
|| needs.changes.outputs.pytest == 'true'
|| needs.changes.outputs.new-unknown-files == 'true'
runs-on: ubuntu-20.04
env:
DATABASE_URL: postgis://kobo:kobo@localhost:5432/kpi_test
Expand Down

0 comments on commit e546e36

Please sign in to comment.