eigen
eigen copied to clipboard
chore: CircleCI performance improvements on PRs 2
Description
This PR aims to improve CircleCI performance by running only relevant Jest tests on PR commits.
With this change, CircleCI only runs a subset of relevant Jest tests when:
- the branch does not include
release,build-me, orhotfix - the PR does not update any global
ts(x)files outside ofsrc/app/Scenes/, - ~~the PR does not include a
build-metag.~~
If a PR only updates ts(x) within a scene, CircleCI will from now on only run a subset of relevant tests (within the same scene or with a similar name).
To Do
- [x] Add a label condition to trigger a full test run by adding a label to the pull request.
- [x] Add
beta-branches to ignored branches - [x]
yarn.lockandpackage.jsonupdates need to trigger test suite
Github Action idea to trigger when adding a tag
# Because we don't run all tests on every PR, adding the label "build-me" to a PR will trigger all tests to run on CircleCI. name: Run all js tests on "build-me" label on: pull_request: types: - labeled
jobs:
trigger:
permissions:
contents: none
runs-on: ubuntu-latest
steps:
- name: Trigger all js tests
run: |
curl
-X POST
--header "Content-Type: application/json"
-d "{"branch": "$GITHUB_HEAD_REF"}"
https://circleci.com/api/v1.1/project/github/artsy/eigen/build?circle-token=${{ secrets.CircleToken }}
Tests
Ideas
git diff --name-only origin/main...$CIRCLE_SHA1 | xargs -n 1 basename | grep -E '^.+\.(ts|tsx)$' | sed 's/\.[^.]*$//'
# Run all tests related to file names
yarn jest $(git diff --name-only origin/main...$CIRCLE_SHA1 | xargs -n 1 basename | grep -E '^.+\.(ts|tsx)$' | sed 's/\.tests//g' | sed 's/\.[^.]*$//')
# Get all updated ts* files
git diff --name-only origin/main...$CIRCLE_SHA1 | xargs -n 1 basename | grep -E '^.+\.(ts|tsx)$'
# Get all 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' | sort | uniq
# test all updated scenes and files
yarn jest $(git diff --name-only origin/main...$CIRCLE_SHA1 | xargs -n 1 basename | grep -E '^.+\.(ts|tsx)$') $(git diff --name-only origin/main...$CIRCLE_SHA1 | grep -E '^.+\.(ts|tsx)$' | sed -n 's#^src/app/Scenes/\([^/]*\)/.*#src/app/Scenes/\1#p' | uniq)
git diff --dirstat=files,0 HEAD main -- src/app/Scenes/ | grep -E '^[0-9.]+\s+src/app/Scenes/([^/]+)/$' -o | sed 's/src\/app\/Scenes\///'
PR Checklist
- [ ] I have tested my changes on iOS and Android.
- [ ] I hid my changes behind a feature flag, or they don't need one.
- [ ] I have included screenshots or videos, or I have not changed the UI.
- [ ] I have added tests, or my changes don't require any.
- [ ] I added an app state migration, or my changes do not require one.
- [ ] I have documented any follow-up work that this PR will require, or it does not require any.
- [ ] I have added a changelog entry below, or my changes do not require one.
To the reviewers 👀
- [ ] I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates
Changelog updates
Cross-platform user-facing changes
iOS user-facing changes
Android user-facing changes
Dev changes
- CircleCI test performance improvements for PR commits - ole
Need help with something? Have a look at our docs, or get in touch with us.
This PR contains the following changes:
- Dev changes (CircleCI test performance improvements for PR commits - ole - olerichter00)
Generated by :no_entry_sign: dangerJS against 426c559bfe603b39acf7fb04ee6c11d2cf8fe178
Closing this - please feel free to open it if needed