Skip to content

Commit c5899a6

Browse files
authored
internal: Only run most expensive package validation if packages actually change (#3621)
1 parent b8ed430 commit c5899a6

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎.circleci/config.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ executors:
2020
# Keep install cache
2121
YARN_ENABLE_IMMUTABLE_INSTALLS: true
2222

23+
commands:
24+
halt-unless-esmodule-relevant-change:
25+
steps:
26+
# Ensure we have a git checkout with history to diff against
27+
- checkout
28+
- run:
29+
name: Skip job if only non-esmodule paths changed
30+
command: |
31+
# Determine changed files relative to main. Adjust base branch if different.
32+
if [ "${CIRCLE_BRANCH}" = "main" ]; then
33+
CHANGED_FILES="$(git diff --name-only HEAD~1...HEAD || true)"
34+
else
35+
git fetch origin main --depth=1 || true
36+
CHANGED_FILES="$(git diff --name-only origin/main...HEAD || true)"
37+
fi
38+
39+
echo "Changed files:"
40+
echo "${CHANGED_FILES}"
41+
42+
if echo "${CHANGED_FILES}" | grep -Eq \
43+
'^(\.circleci/config\.yml|yarn\.lock|examples/todo-app/|examples/github-app/|packages/)'; then
44+
echo "Relevant changes detected; continuing job."
45+
else
46+
echo "No relevant esmodule-related changes; halting this job."
47+
circleci-agent step halt
48+
fi
49+
2350
jobs:
2451
setup:
2552
executor: node
@@ -164,6 +191,7 @@ jobs:
164191
executor: node
165192
resource_class: large
166193
steps:
194+
- halt-unless-esmodule-relevant-change
167195
- attach_workspace:
168196
at: ~/
169197
- run:
@@ -181,6 +209,7 @@ jobs:
181209
type: string
182210
executor: node
183211
steps:
212+
- halt-unless-esmodule-relevant-change
184213
- attach_workspace:
185214
at: ~/
186215
- run:
@@ -208,6 +237,7 @@ jobs:
208237
esmodule-types-latest:
209238
executor: node
210239
steps:
240+
- halt-unless-esmodule-relevant-change
211241
- attach_workspace:
212242
at: ~/
213243
- run:
@@ -230,6 +260,7 @@ jobs:
230260
validate-esmodule-browser-build:
231261
executor: node
232262
steps:
263+
- halt-unless-esmodule-relevant-change
233264
- attach_workspace:
234265
at: ~/
235266
- run: yarn run ci:build:esmodule

0 commit comments

Comments
 (0)