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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: CircleCI performance improvements on PRs 2 #10265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olerichter00
Copy link
Contributor

@olerichter00 olerichter00 commented May 21, 2024

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, or hotfix
  • the PR does not update any global ts(x) files outside of src/app/Scenes/,
  • the PR does not include a build-me tag.

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

  • Add a label condition to trigger a full test run by adding a label to the pull request.
  • Add beta- branches to ignored branches
  • yarn.lock and package.json updates 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.

@olerichter00 olerichter00 changed the title Revert "Revert "chore: CircleCI performance improvements on PRs"" chore: CircleCI performance improvements on PRs 2 May 21, 2024
@olerichter00 olerichter00 self-assigned this May 21, 2024
@ArtsyOpenSource
Copy link
Contributor

This PR contains the following changes:

  • Dev changes (CircleCI test performance improvements for PR commits - ole)

Generated by 🚫 dangerJS against b2ec7fb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants