Skip to content

Commit 6c0f01a

Browse files
authored
fix(ci): Bring back job skipping for PRs without code changes (#13340)
1 parent 334f869 commit 6c0f01a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ jobs:
9696
profiling_node:
9797
- 'packages/profiling-node/**'
9898
- 'dev-packages/e2e-tests/test-applications/node-profiling/**'
99+
any_code:
100+
- '!**/*.md'
99101
100102
101103
- name: Get PR labels
@@ -109,6 +111,8 @@ jobs:
109111
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
110112
changed_profiling_node: ${{ steps.changed.outputs.profiling_node == 'true' }}
111113
changed_ci: ${{ steps.changed.outputs.workflow == 'true' }}
114+
changed_any_code: ${{ steps.changed.outputs.any_code == 'true' }}
115+
112116
# When merging into master, or from master
113117
is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }}
114118
has_gitflow_label:
@@ -123,6 +127,7 @@ jobs:
123127
runs-on: ubuntu-20.04
124128
timeout-minutes: 15
125129
if: |
130+
(needs.job_get_metadata.outputs.changed_any_code) &&
126131
(needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false')
127132
steps:
128133
- name: Check out base commit (${{ github.event.pull_request.base.sha }})
@@ -274,24 +279,37 @@ jobs:
274279

275280
job_check_format:
276281
name: Check file formatting
277-
needs: [job_get_metadata, job_build]
282+
needs: [job_get_metadata]
278283
timeout-minutes: 10
279284
runs-on: ubuntu-20.04
280285
steps:
281286
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
282287
uses: actions/checkout@v4
283288
with:
284289
ref: ${{ env.HEAD_COMMIT }}
290+
285291
- name: Set up Node
286292
uses: actions/setup-node@v4
287293
with:
288294
node-version-file: 'package.json'
295+
296+
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
297+
# so no need to reinstall them
298+
- name: Compute dependency cache key
299+
id: compute_lockfile_hash
300+
run: echo "hash=${{ hashFiles('yarn.lock', '**/package.json') }}" >> "$GITHUB_OUTPUT"
301+
289302
- name: Check dependency cache
290-
uses: actions/cache/restore@v4
303+
uses: actions/cache@v4
304+
id: cache_dependencies
291305
with:
292306
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
293-
key: ${{ needs.job_build.outputs.dependency_cache_key }}
294-
fail-on-cache-miss: true
307+
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
308+
309+
- name: Install dependencies
310+
if: steps.cache_dependencies.outputs.cache-hit != 'true'
311+
run: yarn install --ignore-engines --frozen-lockfile
312+
295313
- name: Check file formatting
296314
run: yarn lint:prettier && yarn lint:biome
297315

0 commit comments

Comments
 (0)