Skip to content

Commit 3544296

Browse files
committed
ci: Bring back job skipping for PRs without code changes
1 parent 70e1815 commit 3544296

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ jobs:
9696
profiling_node:
9797
- 'packages/profiling-node/**'
9898
- 'dev-packages/e2e-tests/test-applications/node-profiling/**'
99-
99+
any_code:
100+
- '!**/*.md'
100101
101102
- name: Get PR labels
102103
id: pr-labels
@@ -109,6 +110,7 @@ jobs:
109110
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
110111
changed_profiling_node: ${{ steps.changed.outputs.profiling_node == 'true' }}
111112
changed_ci: ${{ steps.changed.outputs.workflow == 'true' }}
113+
changed_any_code: ${{ steps.changed.outputs.any_code == 'true' }}
112114
# When merging into master, or from master
113115
is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }}
114116
has_gitflow_label:
@@ -158,6 +160,10 @@ jobs:
158160
if: steps.cache_dependencies.outputs.cache-hit != 'true'
159161
run: yarn install --ignore-engines --frozen-lockfile
160162

163+
- name: Skip step if no code changes
164+
if: needs.job_get_metadata.outputs.changed_any_code == 'false'
165+
run: echo "No code changes, skipping build."
166+
161167
- name: Check for Affected Nx Projects
162168
uses: dkhunt27/[email protected]
163169
id: checkForAffected
@@ -204,6 +210,12 @@ jobs:
204210
changed_browser_integration: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry-internal/browser-integration-tests') }}
205211
# If you are looking for changed_profiling_node, this is defined in job_get_metadata
206212

213+
job_changed_any_code:
214+
name: Check for code changes
215+
needs: [job_get_metadata, job_build]
216+
runs-on: ubuntu-20.04
217+
if: needs.job_get_metadata.outputs.changed_any_code == 'true'
218+
207219
job_check_branches:
208220
name: Check PR branches
209221
needs: job_get_metadata
@@ -221,7 +233,7 @@ jobs:
221233
222234
job_size_check:
223235
name: Size Check
224-
needs: [job_get_metadata, job_build]
236+
needs: [job_get_metadata, job_build, job_changed_any_code]
225237
timeout-minutes: 15
226238
runs-on: ubuntu-20.04
227239
if:
@@ -251,7 +263,7 @@ jobs:
251263
name: Lint
252264
# Even though the linter only checks source code, not built code, it needs the built code in order check that all
253265
# inter-package dependencies resolve cleanly.
254-
needs: [job_get_metadata, job_build]
266+
needs: [job_get_metadata, job_build, job_changed_any_code]
255267
timeout-minutes: 10
256268
runs-on: ubuntu-20.04
257269
steps:
@@ -297,7 +309,7 @@ jobs:
297309

298310
job_circular_dep_check:
299311
name: Circular Dependency Check
300-
needs: [job_get_metadata, job_build]
312+
needs: [job_get_metadata, job_build, job_changed_any_code]
301313
timeout-minutes: 10
302314
runs-on: ubuntu-20.04
303315
steps:
@@ -318,7 +330,7 @@ jobs:
318330

319331
job_artifacts:
320332
name: Upload Artifacts
321-
needs: [job_get_metadata, job_build, job_compile_bindings_profiling_node]
333+
needs: [job_get_metadata, job_build, job_changed_any_code, job_compile_bindings_profiling_node]
322334
runs-on: ubuntu-20.04
323335
# Build artifacts are only needed for releasing workflow.
324336
if: needs.job_get_metadata.outputs.is_release == 'true'
@@ -360,7 +372,7 @@ jobs:
360372
361373
job_browser_unit_tests:
362374
name: Browser Unit Tests
363-
needs: [job_get_metadata, job_build]
375+
needs: [job_get_metadata, job_build, job_changed_any_code]
364376
timeout-minutes: 10
365377
runs-on: ubuntu-20.04
366378
steps:
@@ -398,7 +410,7 @@ jobs:
398410

399411
job_bun_unit_tests:
400412
name: Bun Unit Tests
401-
needs: [job_get_metadata, job_build]
413+
needs: [job_get_metadata, job_build, job_changed_any_code]
402414
if: needs.job_build.outputs.changed_bun == 'true' || github.event_name != 'pull_request'
403415
timeout-minutes: 10
404416
runs-on: ubuntu-20.04
@@ -425,7 +437,7 @@ jobs:
425437
426438
job_deno_unit_tests:
427439
name: Deno Unit Tests
428-
needs: [job_get_metadata, job_build]
440+
needs: [job_get_metadata, job_build, job_changed_any_code]
429441
if: needs.job_build.outputs.changed_deno == 'true' || github.event_name != 'pull_request'
430442
timeout-minutes: 10
431443
runs-on: ubuntu-20.04
@@ -456,7 +468,7 @@ jobs:
456468
457469
job_node_unit_tests:
458470
name: Node (${{ matrix.node }}) Unit Tests
459-
needs: [job_get_metadata, job_build]
471+
needs: [job_get_metadata, job_build, job_changed_any_code]
460472
timeout-minutes: 10
461473
runs-on: ubuntu-20.04
462474
strategy:
@@ -501,7 +513,7 @@ jobs:
501513

502514
job_profiling_node_unit_tests:
503515
name: Node Profiling Unit Tests
504-
needs: [job_get_metadata, job_build]
516+
needs: [job_get_metadata, job_build, job_changed_any_code]
505517
if: needs.job_build.outputs.changed_node == 'true' || needs.job_get_metadata.outputs.changed_profiling_node == 'true' || github.event_name != 'pull_request'
506518
runs-on: ubuntu-latest
507519
timeout-minutes: 10
@@ -529,7 +541,7 @@ jobs:
529541

530542
job_browser_playwright_tests:
531543
name: Playwright ${{ matrix.bundle }}${{ matrix.project && matrix.project != 'chromium' && format(' {0}', matrix.project) || ''}}${{ matrix.shard && format(' ({0}/{1})', matrix.shard, matrix.shards) || ''}} Tests
532-
needs: [job_get_metadata, job_build]
544+
needs: [job_get_metadata, job_build, job_changed_any_code]
533545
if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
534546
runs-on: ubuntu-20.04-large-js
535547
timeout-minutes: 25
@@ -609,7 +621,7 @@ jobs:
609621

610622
job_browser_loader_tests:
611623
name: PW ${{ matrix.bundle }} Tests
612-
needs: [job_get_metadata, job_build]
624+
needs: [job_get_metadata, job_build, job_changed_any_code]
613625
if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
614626
runs-on: ubuntu-20.04
615627
timeout-minutes: 15
@@ -659,7 +671,7 @@ jobs:
659671

660672
job_check_for_faulty_dts:
661673
name: Check for faulty .d.ts files
662-
needs: [job_get_metadata, job_build]
674+
needs: [job_get_metadata, job_build, job_changed_any_code]
663675
runs-on: ubuntu-20.04
664676
timeout-minutes: 5
665677
steps:
@@ -686,7 +698,7 @@ jobs:
686698
name:
687699
Node (${{ matrix.node }})${{ (matrix.typescript && format(' (TS {0})', matrix.typescript)) || '' }} Integration
688700
Tests
689-
needs: [job_get_metadata, job_build]
701+
needs: [job_get_metadata, job_build, job_changed_any_code]
690702
if: needs.job_build.outputs.changed_node_integration == 'true' || github.event_name != 'pull_request'
691703
runs-on: ubuntu-20.04
692704
timeout-minutes: 15
@@ -728,7 +740,7 @@ jobs:
728740

729741
job_remix_integration_tests:
730742
name: Remix v${{ matrix.remix }} (Node ${{ matrix.node }}) Tests
731-
needs: [job_get_metadata, job_build]
743+
needs: [job_get_metadata, job_build, job_changed_any_code]
732744
if: needs.job_build.outputs.changed_remix == 'true' || github.event_name != 'pull_request'
733745
runs-on: ubuntu-20.04
734746
timeout-minutes: 10
@@ -776,7 +788,7 @@ jobs:
776788
if: |
777789
always() && needs.job_build.result == 'success' &&
778790
(needs.job_compile_bindings_profiling_node.result == 'success' || needs.job_compile_bindings_profiling_node.result == 'skipped')
779-
needs: [job_get_metadata, job_build, job_compile_bindings_profiling_node]
791+
needs: [job_get_metadata, job_build, job_changed_any_code, job_compile_bindings_profiling_node]
780792
runs-on: ubuntu-20.04-large-js
781793
timeout-minutes: 15
782794
steps:
@@ -834,7 +846,7 @@ jobs:
834846
# We need to add the `always()` check here because the previous step has this as well :(
835847
# See: https://github.com/actions/runner/issues/2205
836848
if: always() && needs.job_e2e_prepare.result == 'success'
837-
needs: [job_get_metadata, job_build, job_e2e_prepare]
849+
needs: [job_get_metadata, job_build, job_changed_any_code, job_e2e_prepare]
838850
runs-on: ubuntu-20.04
839851
timeout-minutes: 10
840852
env:
@@ -999,7 +1011,7 @@ jobs:
9991011
always() && needs.job_e2e_prepare.result == 'success' &&
10001012
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) &&
10011013
github.actor != 'dependabot[bot]'
1002-
needs: [job_get_metadata, job_build, job_e2e_prepare]
1014+
needs: [job_get_metadata, job_build, job_changed_any_code, job_e2e_prepare]
10031015
runs-on: ubuntu-20.04
10041016
timeout-minutes: 10
10051017
env:
@@ -1114,7 +1126,7 @@ jobs:
11141126
(needs.job_get_metadata.outputs.is_release == 'true') ||
11151127
(github.event_name != 'pull_request')
11161128
)
1117-
needs: [job_get_metadata, job_build, job_e2e_prepare]
1129+
needs: [job_get_metadata, job_build, job_changed_any_code, job_e2e_prepare]
11181130
runs-on: ubuntu-20.04
11191131
timeout-minutes: 10
11201132
env:
@@ -1224,7 +1236,7 @@ jobs:
12241236
12251237
overhead_metrics:
12261238
name: Overhead metrics
1227-
needs: [job_get_metadata, job_build]
1239+
needs: [job_get_metadata, job_build, job_changed_any_code]
12281240
runs-on: ubuntu-20.04
12291241
timeout-minutes: 30
12301242
if: |
@@ -1265,7 +1277,7 @@ jobs:
12651277

12661278
job_compile_bindings_profiling_node:
12671279
name: Compile & Test Profiling Bindings (v${{ matrix.node }}) ${{ matrix.target_platform || matrix.os }}, ${{ matrix.node || matrix.container }}, ${{ matrix.arch || matrix.container }}, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }}
1268-
needs: [job_get_metadata, job_build]
1280+
needs: [job_get_metadata, job_build, job_changed_any_code]
12691281
# Compiling bindings can be very slow (especially on windows), so only run precompile
12701282
# Skip precompile unless we are on a release branch as precompile slows down CI times.
12711283
if: |

0 commit comments

Comments
 (0)