-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: CircleCI test performance improvements
- Loading branch information
1 parent
4e09ed9
commit ff2c2f1
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
UPDATED_GLOBAL_FILES=$(git diff --name-only origin/main...$CIRCLE_SHA1 | grep -E '^.+\.(ts|tsx)$' | grep -v '^src/app/Scenes/' | grep -v '^src/__generated__/') | ||
UPDATED_PACKAGES=$(git diff --name-only origin/main...$CIRCLE_SHA1 | grep -E "package.json|yarn.lock") | ||
UPDATED_SCENES=$(git diff --name-only origin/main...$CIRCLE_SHA1 | grep -E '^.+\.(ts|tsx)$' | sed -n 's#^src/app/Scenes/\([^/]*\)/.*#src/app/Scenes/\1#p' | uniq) | ||
|
||
ALL_UPDATED_FILES=$(git diff --name-only origin/main...$CIRCLE_SHA1 | grep -E '^.+\.(ts|tsx)$' | xargs -n 1 basename) | ||
JEST_OPTIONS="--ci --forceExit --logHeapUsage --runInBand --reporters=default --reporters=jest-junit --shard=$(expr $CIRCLE_NODE_INDEX + 1)/$CIRCLE_NODE_TOTAL" | ||
|
||
|
||
# If only scene files in `src/app/Scenes` have been updated, run only tests for those scenes. | ||
# If global TypeScript files or `package.json` have been updated, run all tests. | ||
# If no `.ts` or `.tsx` files or packages have been updated, don't run any tests. | ||
if [ -n "$UPDATED_GLOBAL_FILES" ] || [ -n "$UPDATED_PACKAGES" ] | ||
then | ||
yarn jest $JEST_OPTIONS | ||
elif [ -n "$UPDATED_SCENES" ] || [ -n "$ALL_UPDATED_FILES" ] | ||
yarn jest $UPDATED_SCENES $ALL_UPDATED_FILES $JEST_OPTIONS | ||
then | ||
echo "No ts|tsx files are updated. Skipping tests." | ||
fi |