Skip to content

Commit 4e42e8e

Browse files
committed
rework ci path filters
1 parent 0b95361 commit 4e42e8e

File tree

4 files changed

+109
-60
lines changed

4 files changed

+109
-60
lines changed

.github/workflows/api-ci.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
name: API CI
22

33
on:
4-
push:
5-
tags:
6-
- prod-*
7-
branches:
8-
- main
9-
- staging
10-
paths:
11-
- 'apps/codecov-api/**'
12-
- 'apps/codecov-api'
13-
- 'libs/**'
14-
pull_request:
15-
paths:
16-
- 'apps/codecov-api/**'
17-
- 'apps/codecov-api'
18-
- 'libs/**'
19-
merge_group:
20-
paths:
21-
- 'apps/codecov-api/**'
22-
- 'apps/codecov-api'
23-
- 'libs/**'
4+
workflow_call:
5+
inputs:
6+
skip:
7+
- type: boolean
8+
default: false
249

2510
permissions:
2611
contents: "read"
@@ -35,18 +20,21 @@ concurrency:
3520
jobs:
3621
api-lint:
3722
name: Run Lint (API)
23+
if: ${{ inputs.skip == false }}
3824
uses: codecov/gha-workflows/.github/workflows/[email protected]
3925
with:
4026
working_directory: apps/codecov-api
4127

4228
api-mypy:
4329
name: Patch typing (API)
30+
if: ${{ inputs.skip == false }}
4431
uses: codecov/gha-workflows/.github/workflows/[email protected]
4532
with:
4633
working_directory: apps/codecov-api
4734

4835
api-build:
4936
name: Build App (API)
37+
if: ${{ inputs.skip == false }}
5038
uses: codecov/gha-workflows/.github/workflows/[email protected]
5139
secrets: inherit
5240
with:
@@ -56,6 +44,7 @@ jobs:
5644
# Runs create-commit, create-report
5745
api-codecovstartup:
5846
name: Codecov Startup (API)
47+
if: ${{ inputs.skip == false }}
5948
needs: api-build
6049
uses: codecov/gha-workflows/.github/workflows/[email protected]
6150
secrets: inherit
@@ -64,6 +53,7 @@ jobs:
6453

6554
api-test:
6655
name: Test (API)
56+
if: ${{ inputs.skip == false }}
6757
needs: [api-build, api-codecovstartup]
6858
uses: codecov/gha-workflows/.github/workflows/[email protected]
6959
secrets: inherit
@@ -75,6 +65,7 @@ jobs:
7565

7666
api-build-self-hosted:
7767
name: Build Self Hosted (API)
68+
if: ${{ inputs.skip == false }}
7869
needs: [api-build, api-test]
7970
uses: codecov/gha-workflows/.github/workflows/[email protected]
8071
secrets: inherit
@@ -85,7 +76,7 @@ jobs:
8576
api-staging:
8677
name: Push Staging Image (API)
8778
needs: [api-build, api-test]
88-
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/staging' && github.repository_owner == 'codecov' }}
79+
if: ${{ inputs.skip == false && github.event_name == 'push' && github.event.ref == 'refs/heads/staging' && github.repository_owner == 'codecov' }}
8980
uses: codecov/gha-workflows/.github/workflows/[email protected]
9081
secrets: inherit
9182
with:
@@ -97,7 +88,7 @@ jobs:
9788
api-production:
9889
name: Push Production Image (API)
9990
needs: [api-build, api-test]
100-
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
91+
if: ${{ inputs.skip == false && github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
10192
uses: codecov/gha-workflows/.github/workflows/[email protected]
10293
secrets: inherit
10394
with:
@@ -110,7 +101,7 @@ jobs:
110101
name: Push Self Hosted Image (API)
111102
needs: [api-build-self-hosted, api-test]
112103
secrets: inherit
113-
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
104+
if: ${{ inputs.skip == false && github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
114105
uses: codecov/gha-workflows/.github/workflows/[email protected]
115106
with:
116107
push_rolling: true

.github/workflows/ci-router.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
tags:
6+
- prod-*
7+
branches:
8+
- main
9+
- staging
10+
pull_request:
11+
merge_group:
12+
13+
permissions:
14+
contents: "read"
15+
id-token: "write"
16+
issues: "write"
17+
pull-requests: "write"
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
change-detection:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
pull-requests: read
28+
outputs:
29+
worker: ${{ steps.filter.outputs.worker }}
30+
codecov-api: ${{ steps.filter.outputs.codecov-api }}
31+
shared: ${{ steps.filter.outputs.shared }}
32+
steps:
33+
- uses: dorny/paths-filter@v3
34+
id: filter
35+
with:
36+
filters: |
37+
worker:
38+
- 'apps/worker'
39+
- 'apps/worker/**'
40+
- 'libs/shared'
41+
- 'libs/shared/**'
42+
codecov-api:
43+
- 'apps/codecov-api'
44+
- 'apps/codecov-api/**'
45+
- 'libs/shared'
46+
- 'libs/shared/**'
47+
shared:
48+
- 'libs/shared'
49+
- 'libs/shared/**'
50+
51+
api-ci:
52+
name: API CI
53+
needs: change-detection
54+
if: ${{ needs.change-detection.outputs.codecov-api == 'true' }}
55+
uses: ./.github/workflows/api-ci.yml
56+
57+
worker-ci:
58+
name: Worker CI
59+
needs: change-detection
60+
if: ${{ needs.change-detection.outputs.worker == 'true' }}
61+
uses: ./.github/workflows/worker-ci.yml
62+
63+
shared-ci:
64+
name: Shared CI
65+
needs: change-detection
66+
if: ${{ needs.change-detection.outputs.shared == 'true' }}
67+
uses: ./.github/workflows/shared-ci.yml

.github/workflows/shared-ci.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
name: Shared CI
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
paths:
8-
- 'libs/shared/**'
9-
- 'libs/shared'
10-
pull_request:
11-
paths:
12-
- 'libs/shared/**'
13-
- 'libs/shared'
14-
merge_group:
15-
paths:
16-
- 'libs/shared/**'
17-
- 'libs/shared'
4+
workflow_call:
5+
inputs:
6+
skip:
7+
- type: boolean
8+
default: false
189

1910
concurrency:
2011
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -24,19 +15,22 @@ jobs:
2415
# TODO: get mypy running
2516
shared-lint:
2617
name: Run Lint (Shared)
18+
if: ${{ inputs.skip == false }}
2719
uses: codecov/gha-workflows/.github/workflows/[email protected]
2820
with:
2921
working_directory: libs/shared
3022

3123
shared-codecovstartup:
3224
name: Codecov Startup (Shared)
25+
if: ${{ inputs.skip == false }}
3326
uses: codecov/gha-workflows/.github/workflows/[email protected]
3427
secrets: inherit
3528
with:
3629
working_directory: libs/shared
3730

3831
shared-test:
3932
name: Test (Shared)
33+
if: ${{ inputs.skip == false }}
4034
runs-on: ubuntu-latest
4135
defaults:
4236
run:
@@ -73,6 +67,7 @@ jobs:
7367

7468
shared-upload-to-codecov:
7569
name: Upload to Codecov (shared)
70+
if: ${{ inputs.skip == false }}
7671
needs: [shared-test]
7772
runs-on: ubuntu-latest
7873
strategy:

.github/workflows/worker-ci.yml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
name: Worker CI
22

33
on:
4-
push:
5-
tags:
6-
- prod-*
7-
branches:
8-
- main
9-
- staging
10-
paths:
11-
- 'apps/worker/**'
12-
- 'apps/worker'
13-
- 'libs/**'
14-
pull_request:
15-
paths:
16-
- 'apps/worker/**'
17-
- 'apps/worker'
18-
- 'libs/**'
19-
merge_group:
20-
paths:
21-
- 'apps/worker/**'
22-
- 'apps/worker'
23-
- 'libs/**'
4+
workflow_call:
5+
inputs:
6+
skip:
7+
- type: boolean
8+
default: false
249

2510
permissions:
2611
contents: "read"
@@ -35,18 +20,23 @@ concurrency:
3520
jobs:
3621
worker-lint:
3722
name: Run Lint (Worker)
23+
if: ${{ inputs.skip == false }}
3824
uses: codecov/gha-workflows/.github/workflows/[email protected]
3925
with:
4026
working_directory: apps/worker
4127

4228
worker-mypy:
4329
name: Patch typing (Worker)
30+
if: ${{ inputs.skip == false }}
31+
uses: codecov/gha-workflows/.github/workflows/[email protected]
4432
uses: codecov/gha-workflows/.github/workflows/[email protected]
4533
with:
4634
working_directory: apps/worker
4735

4836
worker-build:
4937
name: Build App (Worker)
38+
if: ${{ inputs.skip == false }}
39+
uses: codecov/gha-workflows/.github/workflows/[email protected]
5040
uses: codecov/gha-workflows/.github/workflows/[email protected]
5141
secrets: inherit
5242
with:
@@ -56,6 +46,8 @@ jobs:
5646
# Runs create-commit, create-report
5747
worker-codecovstartup:
5848
name: Codecov Startup (Worker)
49+
if: ${{ inputs.skip == false }}
50+
uses: codecov/gha-workflows/.github/workflows/[email protected]
5951
needs: worker-build
6052
uses: codecov/gha-workflows/.github/workflows/[email protected]
6153
secrets: inherit
@@ -64,6 +56,8 @@ jobs:
6456

6557
worker-test:
6658
name: Test (Worker)
59+
if: ${{ inputs.skip == false }}
60+
uses: codecov/gha-workflows/.github/workflows/[email protected]
6761
needs: [worker-build, worker-codecovstartup]
6862
uses: codecov/gha-workflows/.github/workflows/[email protected]
6963
secrets: inherit
@@ -74,6 +68,8 @@ jobs:
7468

7569
worker-build-self-hosted:
7670
name: Build Self Hosted (Worker)
71+
if: ${{ inputs.skip == false }}
72+
uses: codecov/gha-workflows/.github/workflows/[email protected]
7773
needs: [worker-build, worker-test]
7874
uses: codecov/gha-workflows/.github/workflows/[email protected]
7975
secrets: inherit
@@ -84,7 +80,7 @@ jobs:
8480
worker-staging:
8581
name: Push Staging Image (Worker)
8682
needs: [worker-build, worker-test]
87-
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/staging') && github.repository_owner == 'codecov' }}
83+
if: ${{ inputs.skip == false && github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/staging') && github.repository_owner == 'codecov' }}
8884
uses: codecov/gha-workflows/.github/workflows/[email protected]
8985
secrets: inherit
9086
with:
@@ -96,7 +92,7 @@ jobs:
9692
worker-production:
9793
name: Push Production Image (Worker)
9894
needs: [worker-build, worker-test]
99-
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
95+
if: ${{ inputs.skip == false && github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
10096
uses: codecov/gha-workflows/.github/workflows/[email protected]
10197
secrets: inherit
10298
with:
@@ -109,7 +105,7 @@ jobs:
109105
name: Push Self Hosted Image (Worker)
110106
needs: [worker-build-self-hosted, worker-test]
111107
secrets: inherit
112-
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
108+
if: ${{ inputs.skip == false && github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
113109
uses: codecov/gha-workflows/.github/workflows/[email protected]
114110
with:
115111
push_rolling: true

0 commit comments

Comments
 (0)