Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: CircleCI performance improvements on PRs #9993

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 47 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ orbs:
macos: circleci/macos@2.5.0
android: circleci/android@2.5.0

only-main-or-release-or-build-me: &only-main-or-release-or-build-me
filters:
branches:
only:
- main
- /.*release$/
- /.*build-me$/
- /.*hotfix$/
- /.*beta-$/

only-prs: &only-prs
filters:
branches:
ignore:
- main
- /.*release$/
- /.*build-me$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought, non-blocking: Always running all tests for main, release and hot fixes makes a lot of sense, for build-me I wonder if forcing a run based on something like a label would be better than having to rename the branch: https://github.com/marketplace/actions/run-circle-ci-on-label

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea! 馃憤 It might be good to keep both because this is how to force all tests to run in Gravity. I'll try to make this version with the label work as well and then add it here and to Gravity's CircleCI config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add the beta-ios and beta-android branches here 鉂わ笍

- /.*hotfix$/
- /.*beta-$/

commands:
await-previous-builds:
parameters:
Expand Down Expand Up @@ -236,6 +256,28 @@ jobs:
echo "Triggering CodePush deployment..."
./scripts/codepush/deploy-to-codepush.sh Staging

test-js-pr:
parallelism: 8
executor:
name: node/default
tag: "20.9.0"
resource_class: large
steps:
- checkout
- install-node-modules
- run-relay-compiler
- run:
name: Run Jest For Updated Files and Scenes Only
command: ./scripts/ci/ci-test-js-pr
no_output_timeout: 3600s
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
JEST_JUNIT_UNIQUE_OUTPUT_NAME: true
- store_artifacts:
path: ./reports/junit/
- store_test_results:
path: ./reports/junit/

test-js:
parallelism: 8
executor:
Expand Down Expand Up @@ -484,7 +526,11 @@ workflows:
only:
- main

- test-js
- test-js:
<<: *only-main-or-release-or-build-me

- test-js-pr:
<<: *only-prs

- build-test-js

Expand Down
21 changes: 21 additions & 0 deletions scripts/ci/ci-test-js-pr
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃檶