Skip to content

Commit

Permalink
chore: enhance GitHub workflows with path filtering for builds and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Karia committed Nov 24, 2024
1 parent 632cfd7 commit 4208f09
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,34 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
changes:
runs-on: ubuntu-latest
outputs:
root: ${{ steps.filter.outputs.root }}
playground: ${{ steps.filter.outputs.playground }}
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
root:
- '!{playground,docs}/**'
- '*.{ts,tsx,js,jsx,json}'
- 'package.json'
- 'tsconfig.json'
playground:
- 'playground/**'
docs:
- 'docs/**'
build-root:
if: github.workspace == '.'
needs: changes
if: ${{ needs.changes.outputs.root == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -18,9 +42,10 @@ jobs:
cache: 'npm'
- run: npm ci
- run: npm run build

build-playground:
if: contains(github.event.head_commit.modified, 'playground/') || contains(github.event.pull_request.changed_files, 'playground/')
needs: changes
if: ${{ needs.changes.outputs.playground == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -36,7 +61,8 @@ jobs:
- run: npm run build

build-docs:
if: contains(github.event.head_commit.modified, 'docs/') || contains(github.event.pull_request.changed_files, 'docs/')
needs: changes
if: ${{ needs.changes.outputs.docs == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
test:
if: github.workspace == '.'
changes:
runs-on: ubuntu-latest
outputs:
root: ${{ steps.filter.outputs.root }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
root:
- '!{playground,docs}/**'
- '*.{ts,tsx,js,jsx,json}'
- 'package.json'
- 'tsconfig.json'
test-root:
needs: changes
if: ${{ needs.changes.outputs.root == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -17,4 +35,4 @@ jobs:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run test
- run: npm test

0 comments on commit 4208f09

Please sign in to comment.