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

Improve CI run time #8348

Merged
merged 2 commits into from
Oct 12, 2023
Merged

Improve CI run time #8348

merged 2 commits into from
Oct 12, 2023

Conversation

johnny-m-young
Copy link
Contributor

@johnny-m-young johnny-m-young commented Oct 10, 2023

What

Trello ticket link
This PR improves the time it takes our CI tests to run by:

  • Parallelising the integration tests so that one process runs the cucumber:ok task and one process runs the cucumber:preview_design_system task
  • Parallelising the MiniTest workflow using a matrix strategy, randomly distributing tests across 4 nodes.

Benchmark: Approximately 17m39s (average of the 10 most recent merge to main CI runs)

With the changes proposed, this PR reduces CI run time to approximately 7 minutes.

Why

This is to help reduce developer toil and time to deploy changes. The current run time is excessive and slows down development.

Additional information

Order of implementation

To avoid having a period where there are no Minitest or integration checks in our CI/CD pipeline, these changes must be implemented in the following order:

  1. Merge the new parallelised tests to main
  2. Create new branch rules so that parallelised tests must pass before merging
  3. Remove non-parallelised branch rules
  4. Remove non-parallelised workflows

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

@johnny-m-young johnny-m-young changed the title Improve ci run time Improve CI run time Oct 10, 2023
@johnny-m-young johnny-m-young marked this pull request as ready for review October 10, 2023 14:45
@johnny-m-young
Copy link
Contributor Author

johnny-m-young commented Oct 10, 2023

I've got some food for thought on this:

With the current implementation, MiniTest tests are manually assigned to nodes. This potentially puts us at risk of not running the full suite: if we've missed some tests, or if future tests get added to locations which lie outside of the assignment. This could be solved by randomly assigning tests across nodes, potentially resulting in a small increase in run time. The random assignment of tests would make it easier to scale up - as a node can be added without worrying about re-allocating tests across nodes - but increases complexity.

Here's a draft PR to show what random test assignments would look like with 4 nodes.

@davidgisbey
Copy link
Contributor

davidgisbey commented Oct 11, 2023

this is great 🚀

One thought. If we add a new pattern etc. which uses a new directory. We would have to remember to add it to a node or the tests wouldn't run on CI right?

Edit: sorry i missed this #8348 (comment)

Copy link
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. I wasn't expecting us to be quite so fine-grained with the unit test directories, but if this works well then I don't have any objections

@johnny-m-young johnny-m-young force-pushed the improve-ci-run-time branch 4 times, most recently from 891156f to b9f7494 Compare October 12, 2023 06:35
Jonathan Young added 2 commits October 12, 2023 07:38
This separates out the two runs done by integration
tests: one with preview_design_system permissions
and one without. Each is run in a separate workflow.
I opted to make separate worksflows to make it easy
to delete the preview_design_system workflow once
fully ported over to the design system.
This configures the MiniTest workflow to run
using a matrix strategy. It run separate parts
of the test suite on different nodes and hence
speeds up total run time of the CI/CD pipeline.
@davidgisbey
Copy link
Contributor

Seems like a good approach to me. Makes me feel a lot more comfortable about us not missing tests 👍

Copy link
Contributor

@davidgisbey davidgisbey left a comment

Choose a reason for hiding this comment

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

lgtm!

@johnny-m-young johnny-m-young merged commit e730bc5 into main Oct 12, 2023
15 checks passed
@johnny-m-young johnny-m-young deleted the improve-ci-run-time branch October 12, 2023 08:17
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.

4 participants