Skip to content

Commit b5bdcef

Browse files
authored
ci: Unify workflows into singular pipeline (#4520)
* ci: Remove duplicate build & test job in CI * ci: Wait for filter * ci: Missing `runs-on` * junk: REVERT ME - To trigger CI * ci: Fix action name & format * ci: Fix wrong job name * junk: REVERT ME - Fixes workflow test * ci: Further refactor into singular pipeline * ci: Better name for filter * ci: Fix workflow name * ci: Clean up
1 parent ad3bc3b commit b5bdcef

File tree

5 files changed

+86
-70
lines changed

5 files changed

+86
-70
lines changed

.github/workflows/benchmarks.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,12 @@ name: Benchmarks
22

33
on:
44
workflow_dispatch:
5-
pull_request:
6-
branches:
7-
- '**'
8-
paths:
9-
- '**/src/**.js'
10-
push:
11-
branches:
12-
- main
13-
- v11
14-
paths:
15-
- '**/src/**.js'
5+
workflow_call:
166

177
jobs:
18-
build_test:
19-
name: Build & Test
20-
uses: ./.github/workflows/ci.yml
21-
228
prepare:
239
name: Prepare environment
2410
runs-on: ubuntu-latest
25-
needs: build_test
2611
timeout-minutes: 5
2712
steps:
2813
- name: Download locally built preact package
@@ -34,7 +19,7 @@ jobs:
3419
uses: andrewiggins/download-base-artifact@v3
3520
with:
3621
artifact: npm-package
37-
workflow: ci.yml
22+
workflow: build-test.yml
3823
required: false
3924
- run: mv preact.tgz preact-main.tgz
4025
- name: Upload locally build & base preact package

.github/workflows/build-test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build & Test
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
ref:
8+
description: 'Branch or tag ref to check out'
9+
type: string
10+
required: false
11+
default: ''
12+
artifact_name:
13+
description: 'Name of the artifact to upload'
14+
type: string
15+
required: false
16+
default: 'npm-package'
17+
18+
jobs:
19+
build_test:
20+
name: Build & Test
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ inputs.ref || '' }}
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version-file: 'package.json'
29+
cache: 'npm'
30+
cache-dependency-path: '**/package-lock.json'
31+
- run: npm ci
32+
- name: test
33+
env:
34+
CI: true
35+
COVERAGE: true
36+
FLAKEY: false
37+
# Not using `npm test` since it rebuilds source which npm ci has already done
38+
run: |
39+
npm run lint
40+
npm run test:unit
41+
- name: Coveralls GitHub Action
42+
uses: coverallsapp/github-action@v2.3.0
43+
timeout-minutes: 2
44+
with:
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
- name: Package
47+
# Use --ignore-scripts here to avoid re-building again before pack
48+
run: |
49+
npm pack --ignore-scripts
50+
mv preact-*.tgz preact.tgz
51+
- name: Upload npm package
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: ${{ inputs.artifact_name || 'npm-package' }}
55+
path: preact.tgz

.github/workflows/ci.yml

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,41 @@ name: CI
22

33
on:
44
workflow_dispatch:
5-
workflow_call:
6-
inputs:
7-
ref:
8-
description: 'Branch or tag ref to check out'
9-
type: string
10-
required: false
11-
default: ''
12-
artifact_name:
13-
description: 'Name of the artifact to upload'
14-
type: string
15-
required: false
16-
default: 'npm-package'
175
pull_request:
186
branches:
197
- '**'
208
push:
219
branches:
2210
- main
2311
- restructure
12+
- v11
2413

2514
jobs:
26-
build_test:
27-
name: Build & Test
15+
filter_jobs:
16+
name: Filter jobs
2817
runs-on: ubuntu-latest
18+
outputs:
19+
jsChanged: ${{ steps.filter.outputs.jsChanged }}
2920
steps:
30-
- uses: actions/checkout@v4
31-
with:
32-
ref: ${{ inputs.ref || '' }}
33-
- uses: actions/setup-node@v4
34-
with:
35-
node-version-file: 'package.json'
36-
cache: 'npm'
37-
cache-dependency-path: '**/package-lock.json'
38-
- run: npm ci
39-
- name: test
40-
env:
41-
CI: true
42-
COVERAGE: true
43-
FLAKEY: false
44-
# Not using `npm test` since it rebuilds source which npm ci has already done
45-
run: |
46-
npm run lint
47-
npm run test:unit
48-
- name: Coveralls GitHub Action
49-
uses: coverallsapp/github-action@v2.3.0
50-
timeout-minutes: 2
51-
with:
52-
github-token: ${{ secrets.GITHUB_TOKEN }}
53-
- name: Package
54-
# Use --ignore-scripts here to avoid re-building again before pack
55-
run: |
56-
npm pack --ignore-scripts
57-
mv preact-*.tgz preact.tgz
58-
- name: Upload npm package
59-
uses: actions/upload-artifact@v4
21+
- uses: dorny/paths-filter@v3
22+
id: filter
6023
with:
61-
name: ${{ inputs.artifact_name || 'npm-package' }}
62-
path: preact.tgz
24+
filters: |
25+
jsChanged: '**/src/**.js'
26+
27+
compressed_size:
28+
name: Compressed Size
29+
needs: filter_jobs
30+
if: ${{ needs.filter_jobs.outputs.jsChanged == 'true' }}
31+
uses: ./.github/workflows/size.yml
32+
33+
build_test:
34+
name: Build & Test
35+
needs: filter_jobs
36+
uses: ./.github/workflows/build-test.yml
37+
38+
benchmarks:
39+
name: Benchmarks
40+
needs: build_test
41+
if: ${{ needs.filter_jobs.outputs.jsChanged == 'true' }}
42+
uses: ./.github/workflows/benchmarks.yml

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: create
44
jobs:
55
build:
66
if: github.ref_type == 'tag'
7-
uses: preactjs/preact/.github/workflows/ci.yml@main
7+
uses: preactjs/preact/.github/workflows/build-test.yml@main
88

99
release:
1010
runs-on: ubuntu-latest

.github/workflows/size.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
name: Compressed Size
22

33
on:
4-
pull_request:
5-
branches:
6-
- '**'
7-
paths:
8-
- '**/src/**.js'
4+
workflow_call:
95

106
jobs:
117
build:
@@ -22,4 +18,4 @@ jobs:
2218
repo-token: '${{ secrets.GITHUB_TOKEN }}'
2319
# Our `prepare` script already builds the app post-install,
2420
# building it again would be redundant
25-
build-script: 'npm run --if-present noop'
21+
build-script: 'npm run --if-present noop'

0 commit comments

Comments
 (0)