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

[MBL-773] CircleCI Workspaces Integration #1821

Merged
merged 34 commits into from May 18, 2023

Conversation

msadoon
Copy link
Contributor

@msadoon msadoon commented May 14, 2023

πŸ“² What and πŸ€” Why

So our CI pipeline has a lot of repeated steps in it:
Example all of these steps run for every test job (that's 3x for kickstarter-framework-ios, ksapi, library)

    - checkout
    - run:
        name: SPM SSH Workaround
        command: *spm_ssh_workaround
    - run:
        name: Store Xcode Version
        command: xcodebuild -version > xcode_version.txt
    - run:
        name: Bootstrap SPM
        command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
    - run:
        name: Bootstrap
        command: make bootstrap
    - run:
        name: Download GraphQL Schema
        command: bin/apollo-schema-download.sh
    - run:
        name: Pre-load simulator
        command: *preload_simulator
    - run:
        name: Run tests
        command: make test
        no_output_timeout: "20m" # 20 minutes
   - run:
       name: Install Bundler
       command: bundle check || bundle install
       environment:
          BUNDLE_JOBS: 4
          BUNDLE_RETRY: 3

Because these steps are run in parallel, they really don't blow up the time it takes for our suite to finish (approx. 30 min)

However why not run all the steps once, incorporate the environment they ran in (for example all the gems from bundle install) and re-use that environment for our test jobs.

Workspaces allows us to do this.

πŸ›  How

Workspaces has two steps essentially:

a persist_to_workspace step and attach_workspace step.

for our test_job and distribute_job we attach_workspace. The build_and_cache step has persist_to_a_workspace step and sets up the environment with gems, swift package dependencies and the code itself.

🏎 Performance

Side-by-side comparison of reduction in time.

  1. Last time an alpha build got deployed:

Screenshot 2023-05-16 at 7 49 48 PM

  1. New alpha build deploy

Screenshot 2023-05-16 at 8 01 05 PM

Note the tests do not run until the build and cache step completes.

  1. CircleCI reports a 14% decrease in average time to finish.

Screenshot 2023-05-16 at 8 00 55 PM

We might be expected it to be much faster but these jobs were run while CircleCI was in "maintenance" mode, so that probably effected the total time. Let's try this idea for now, and judge its' efficiency after we get some builds distributed.

In theory it "should" improve total time to build, but we need CI to be out of maintenance mode to see the real results.

Noted for posterity

Quick smoke test for new ci build time vs old build time (2 suites running same on conditions in CircleCI):

Screenshot 2023-05-17 at 1 10 30 PM

top workflow is using workspaces, bottom workflow using caching.

Caching is faster for total time taken
Pros:

  • Concurrent workflows run, meaning even with repeated steps, the longest running test suit will be the bottle neck.

Cons:

  • Messier config.yml file, less maintainable.
  • Not using newer circleci options like orbs for MacOS and prelaunch-simulator commands.

Workspaces is faster for individual test suites
Pros:

  • More maintainable config.yml file, all downloads/config/gems/code/packages done in build and cache. Test job and distribute job just use the workspace.
  • Each test job after build-and-cache takes between 3-10 minutes less time.

Cons:

  • Consecutive workflows run, adds time. Meaning build and cache takes 10 min longer and runs first, before test suites. Bottleneck is build-and-cache time + longest test suite time.

βœ… Acceptance criteria

  • CirecleCI steps pass - and a deployment (alpha) should be passing as well.

⏰ TODO

  • Restore SPM step doesn't have permisions to unarchive cache.
  • Ensure tests passing and alpha gets deployed.

@msadoon msadoon added this to the release-5.8.0 milestone May 14, 2023
@msadoon msadoon self-assigned this May 14, 2023
@msadoon msadoon added the WIP label May 14, 2023
msadoon added 24 commits May 14, 2023 12:26
@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Merging #1821 (a4ac6bd) into main (aee3831) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1821   +/-   ##
=======================================
  Coverage   84.45%   84.45%           
=======================================
  Files        1283     1283           
  Lines      116650   116650           
  Branches    30953    30953           
=======================================
  Hits        98521    98521           
  Misses      17052    17052           
  Partials     1077     1077           

πŸ“£ We’re building smart automated test selection to slash your CI/CD build times. Learn more

@msadoon msadoon changed the title [Unticketed] CircleCI Workspaces Integration [MBL-773] CircleCI Workspaces Integration May 17, 2023
@msadoon msadoon marked this pull request as ready for review May 17, 2023 07:44
@msadoon msadoon requested a review from scottkicks May 17, 2023 07:44
@msadoon msadoon added needs review and removed WIP labels May 17, 2023
Copy link
Contributor

@scottkicks scottkicks left a comment

Choose a reason for hiding this comment

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

awesome improvement!

@msadoon
Copy link
Contributor Author

msadoon commented May 17, 2023

@scottkicks I know you already approved this, but I just compared two workflows using the old config file and the newer. If you could take a look at Note for posterity and let me know if you think its' still worth merging this PR.

@msadoon msadoon merged commit c50512a into main May 18, 2023
8 checks passed
@msadoon msadoon deleted the feature/integration-circleci-workspaces branch May 18, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants