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

ci: share data between jobs using workspaces #28928

Closed
wants to merge 1 commit into from

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Feb 22, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the new behavior?

This PR expands usage of the CircleCI workspaces feature to share artifacts between jobs of the same workflow.

The current mindset WRT to artifacts is that we cache some artifacts at the end of the build-npm-packages job, which is then restored on each job. This works well even for jobs prior to that specific cache because of partial cache hits.

With workspaces the mindset is slightly different. There is an initial job that creates a workspace from the cache, which other jobs use and might enhance.

The key difference is that subsequent jobs do not repeat setup, which can yield different results since part of setup is merging a PR with latest master. Another desirable characteristic of this setup is that it enables easier sharing of artifacts between jobs, and lessens repetition in the circleci configuration.

Here is a sample of comparison of workflows taken roughly at the same time. It's important to capture this comparison at similar times because CircleCI workload varies during the day:

Before: https://circleci.com/workflow-run/155fc8ea-2ea5-45ec-8f75-05f3297f4052
After: https://circleci.com/workflow-run/97e4f222-75f3-426c-bcdf-a583f1524045

Of these we can compare specific jobs:

The gains in individual job setup are lessened by the new common install step though. In https://circleci.com/gh/angular/angular/218899 we can see it took 1m58s.

Of these, 27s seem to be due to yarn behaviour where --frozen-lockfile with a cached directory can still fetch dependencies in some cases (yarnpkg/yarn#5840 (comment)). Updating the AIO lockfile should reduce it to ~2s.

The gain on correctness cannot be compared. Under the previous setup it was possible for individual jobs to run over different code.

Further additions to persisted workspace files can also improve performance of subsequent runs.

It's also important to note that this PR also adds caching of AIO node_modules, which wasn't done before.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@filipesilva filipesilva force-pushed the circleci-workspace branch 8 times, most recently from d1acaa9 to b062782 Compare February 22, 2019 18:45
@benlesh benlesh added the area: build & ci Related the build and CI infrastructure of the project label Feb 22, 2019
@ngbot ngbot bot added this to the needsTriage milestone Feb 22, 2019
@filipesilva filipesilva force-pushed the circleci-workspace branch 3 times, most recently from 95cbb79 to aaf0362 Compare February 22, 2019 19:40
@filipesilva filipesilva marked this pull request as ready for review February 22, 2019 20:10
@filipesilva filipesilva requested a review from a team as a code owner February 22, 2019 20:10
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

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

the rest looks great. we can rename the name in a follow up PR. I want this change now because it's so good ! :-)

version: 2
jobs:
lint:
install:
Copy link
Contributor

Choose a reason for hiding this comment

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

is install the right name? how about init or setup or prepare? we do much more than just "install"

@IgorMinar IgorMinar added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Feb 22, 2019
@IgorMinar
Copy link
Contributor

merge-assistance: if this fails to cherry-pick to patch and the conflict can't be easily resolved, please merge it to master-only and ask @filipesilva to send a separate PR for the patch branch. thanks!

@benlesh benlesh added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Feb 22, 2019
@benlesh benlesh closed this in f0989b7 Feb 22, 2019
@filipesilva filipesilva deleted the circleci-workspace branch February 22, 2019 21:29
filipesilva added a commit to filipesilva/angular that referenced this pull request Feb 22, 2019
filipesilva added a commit to filipesilva/angular that referenced this pull request Feb 25, 2019
@gkalpak
Copy link
Member

gkalpak commented Feb 25, 2019

I think it would be a good idea to capture in the commit message (and PR description) why we did this change (and why "it is so good" 😛).
Also, how this affects total CI time (afaict, it increases the total time for certain jobs) and why the benefits justify any increase in total workflow duration.

@filipesilva
Copy link
Contributor Author

@gkalpak I am a bit late to change the commits but added details and comparison to the PR message.

filipesilva added a commit to filipesilva/angular that referenced this pull request Feb 25, 2019
filipesilva added a commit to filipesilva/angular that referenced this pull request Feb 25, 2019
benlesh pushed a commit that referenced this pull request Feb 25, 2019
filipesilva added a commit to filipesilva/angular that referenced this pull request Feb 25, 2019
filipesilva added a commit to filipesilva/angular that referenced this pull request Feb 25, 2019
@filipesilva filipesilva mentioned this pull request Feb 25, 2019
14 tasks
benlesh pushed a commit that referenced this pull request Feb 25, 2019
benlesh pushed a commit that referenced this pull request Feb 25, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: build & ci Related the build and CI infrastructure of the project cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants