Skip to content

Commit

Permalink
script
Browse files Browse the repository at this point in the history
  • Loading branch information
olerichter00 committed Mar 21, 2024
1 parent a3a1793 commit 07fe19f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ jobs:
- install-node-modules
- run-relay-compiler
- run:
command: yarn jest $(git diff --name-only HEAD main | xargs -n 1 basename | grep -E '^.+\.(ts|tsx)$') $(git diff --name-only HEAD main | grep -E '^.+\.(ts|tsx)$' | sed -n 's#^src/app/Scenes/\([^/]*\)/.*#src/app/Scenes/\1#p' | uniq) --ci --forceExit --logHeapUsage --runInBand --reporters=default --reporters=jest-junit --shard=$(expr $CIRCLE_NODE_INDEX + 1)/$CIRCLE_NODE_TOTAL
name: Run Jest For Updated Files and Scenes
command: ./scripts/ci/ci_test_pr.sh
name: Run Jest For Updated Files and Scenes Only
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
JEST_JUNIT_UNIQUE_OUTPUT_NAME: true
Expand Down
19 changes: 19 additions & 0 deletions scripts/ci/ci_test_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -ex


UPDATED_GLOBAL_FILES=$(git diff --name-only origin/main...HEAD | grep -E '^.+\.(ts|tsx)$' | grep -v '^src/app/Scenes/' | grep -v '^src/__generated__/')

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)
UPDATED_FILES=$(git diff --name-only origin/main...$CIRCLE_SHA1 | xargs -n 1 basename | grep -E '^.+\.(ts|tsx)$')

JEST_OPTIONS="--ci --forceExit --logHeapUsage --runInBand --reporters=default --reporters=jest-junit --shard=$(expr $CIRCLE_NODE_INDEX + 1)/$CIRCLE_NODE_TOTAL"


# Run all tests if any global files are updated
if [ -n "$UPDATED_GLOBAL_FILES" ]
then
yarn jest $JEST_OPTIONS
else
yarn jest $UPDATED_SCENES $UPDATED_FILES $JEST_OPTIONS
fi

0 comments on commit 07fe19f

Please sign in to comment.