Skip to content

Commit c12eb30

Browse files
ci: Add file change detection to workflows (#7524)
Skip tests for changesets that only touch documentation. Co-authored-by: Alexander Alderman Webb <alexander.webb@sentry.io>
1 parent 32490c4 commit c12eb30

2 files changed

Lines changed: 97 additions & 2 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,54 +31,114 @@ permissions:
3131
# if: false # TEMP: skipping, see PR #xxxx
3232
# uses: ./.github/workflows/test-integrations-dbs.yml
3333
jobs:
34+
files-changed:
35+
name: Detect changed files
36+
runs-on: ubuntu-24.04
37+
timeout-minutes: 3
38+
permissions:
39+
contents: read
40+
pull-requests: read
41+
outputs:
42+
code: ${{ github.event_name != 'pull_request' || steps.changes.outputs.code == 'true' }}
43+
steps:
44+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
45+
if: github.event_name == 'pull_request'
46+
- name: Check for code changes
47+
id: changes
48+
if: github.event_name == 'pull_request'
49+
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
50+
with:
51+
token: ${{ github.token }}
52+
predicate-quantifier: some-with-excludes
53+
filters: |
54+
code:
55+
- '**'
56+
- '!**/*.md'
57+
- '!docs/**'
58+
- '!LICENSE'
59+
- '!.agents/**'
60+
- '!.github/ISSUE_TEMPLATE/**'
61+
- '!.github/CODEOWNERS'
62+
- '!.git-blame-ignore-revs'
3463
common:
3564
name: Common
65+
needs: files-changed
66+
if: ${{ needs.files-changed.outputs.code == 'true' }}
3667
uses: ./.github/workflows/test-integrations-common.yml
3768
mcp:
3869
name: MCP
70+
needs: files-changed
71+
if: ${{ needs.files-changed.outputs.code == 'true' }}
3972
uses: ./.github/workflows/test-integrations-mcp.yml
4073
agents:
4174
name: Agents
75+
needs: files-changed
76+
if: ${{ needs.files-changed.outputs.code == 'true' }}
4277
uses: ./.github/workflows/test-integrations-agents.yml
4378
ai_workflow:
4479
name: AI Workflow
80+
needs: files-changed
81+
if: ${{ needs.files-changed.outputs.code == 'true' }}
4582
uses: ./.github/workflows/test-integrations-ai-workflow.yml
4683
ai:
4784
name: AI
85+
needs: files-changed
86+
if: ${{ needs.files-changed.outputs.code == 'true' }}
4887
uses: ./.github/workflows/test-integrations-ai.yml
4988
cloud:
5089
name: Cloud
90+
needs: files-changed
91+
if: ${{ needs.files-changed.outputs.code == 'true' }}
5192
uses: ./.github/workflows/test-integrations-cloud.yml
5293
dbs:
5394
name: DBs
95+
needs: files-changed
96+
if: ${{ needs.files-changed.outputs.code == 'true' }}
5497
uses: ./.github/workflows/test-integrations-dbs.yml
5598
flags:
5699
name: Flags
100+
needs: files-changed
101+
if: ${{ needs.files-changed.outputs.code == 'true' }}
57102
uses: ./.github/workflows/test-integrations-flags.yml
58103
gevent:
59104
name: Gevent
105+
needs: files-changed
106+
if: ${{ needs.files-changed.outputs.code == 'true' }}
60107
uses: ./.github/workflows/test-integrations-gevent.yml
61108
graphql:
62109
name: GraphQL
110+
needs: files-changed
111+
if: ${{ needs.files-changed.outputs.code == 'true' }}
63112
uses: ./.github/workflows/test-integrations-graphql.yml
64113
network:
65114
name: Network
115+
needs: files-changed
116+
if: ${{ needs.files-changed.outputs.code == 'true' }}
66117
uses: ./.github/workflows/test-integrations-network.yml
67118
tasks:
68119
name: Tasks
120+
needs: files-changed
121+
if: ${{ needs.files-changed.outputs.code == 'true' }}
69122
uses: ./.github/workflows/test-integrations-tasks.yml
70123
web_1:
71124
name: Web 1
125+
needs: files-changed
126+
if: ${{ needs.files-changed.outputs.code == 'true' }}
72127
uses: ./.github/workflows/test-integrations-web-1.yml
73128
web_2:
74129
name: Web 2
130+
needs: files-changed
131+
if: ${{ needs.files-changed.outputs.code == 'true' }}
75132
uses: ./.github/workflows/test-integrations-web-2.yml
76133
misc:
77134
name: Misc
135+
needs: files-changed
136+
if: ${{ needs.files-changed.outputs.code == 'true' }}
78137
uses: ./.github/workflows/test-integrations-misc.yml
79138
report:
80139
name: Combine and report coverage
81140
needs:
141+
- files-changed
82142
- common
83143
- mcp
84144
- agents
@@ -95,7 +155,7 @@ jobs:
95155
- web_2
96156
- misc
97157
# Report whatever coverage exists, even if some test jobs failed.
98-
if: ${{ !cancelled() }}
158+
if: ${{ !cancelled() && needs.files-changed.outputs.code == 'true' }}
99159
runs-on: ubuntu-22.04
100160
steps:
101161
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -126,6 +186,7 @@ jobs:
126186
check-required:
127187
name: All tests passed
128188
needs:
189+
- files-changed
129190
- common
130191
- mcp
131192
- agents

‎scripts/split_tox_gh_actions/templates/test_orchestrator.jinja‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,53 @@ permissions:
3636
# if: false # TEMP: skipping, see PR #xxxx
3737
# uses: ./.github/workflows/test-integrations-dbs.yml
3838
jobs:
39+
files-changed:
40+
name: Detect changed files
41+
runs-on: ubuntu-24.04
42+
timeout-minutes: 3
43+
permissions:
44+
contents: read
45+
pull-requests: read
46+
outputs:
47+
code: {% raw %}${{ github.event_name != 'pull_request' || steps.changes.outputs.code == 'true' }}{% endraw %}
48+
steps:
49+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
50+
if: github.event_name == 'pull_request'
51+
- name: Check for code changes
52+
id: changes
53+
if: github.event_name == 'pull_request'
54+
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
55+
with:
56+
token: {% raw %}${{ github.token }}{% endraw %}
57+
predicate-quantifier: some-with-excludes
58+
filters: |
59+
code:
60+
- '**'
61+
- '!**/*.md'
62+
- '!docs/**'
63+
- '!LICENSE'
64+
- '!.agents/**'
65+
- '!.github/ISSUE_TEMPLATE/**'
66+
- '!.github/CODEOWNERS'
67+
- '!.git-blame-ignore-revs'
68+
3969
{% for g in orchestrated_groups %}
4070
{{ g.id }}:
4171
name: {{ g.name }}
72+
needs: files-changed
73+
if: {% raw %}${{ needs.files-changed.outputs.code == 'true' }}{% endraw %}
4274
uses: ./.github/workflows/test-integrations-{{ g.slug }}.yml
4375
{% endfor %}
4476

4577
report:
4678
name: Combine and report coverage
4779
needs:
80+
- files-changed
4881
{% for g in orchestrated_groups %}
4982
- {{ g.id }}
5083
{% endfor %}
5184
# Report whatever coverage exists, even if some test jobs failed.
52-
if: {% raw %}${{ !cancelled() }}{% endraw %}
85+
if: {% raw %}${{ !cancelled() && needs.files-changed.outputs.code == 'true' }}{% endraw %}
5386
runs-on: ubuntu-22.04
5487
steps:
5588
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -81,6 +114,7 @@ jobs:
81114
check-required:
82115
name: All tests passed
83116
needs:
117+
- files-changed
84118
{% for g in orchestrated_groups %}
85119
- {{ g.id }}
86120
{% endfor %}

0 commit comments

Comments
 (0)