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

Fix #16028 and #12647: Cache pip dependencies and make E2E tests use shared webpack build #16629

Merged
merged 26 commits into from
Nov 28, 2022

Conversation

U8NWXD
Copy link
Member

@U8NWXD U8NWXD commented Nov 26, 2022

Overview

  1. This PR fixes Avoid Redundant Builds and Installation in CI E2E tests #16028 and fixes Refactor GitHub Actions Workflows to Reduce Redundant Code #12647.
  2. This PR does the following:
    • Enables caching of pip dependencies to reduce our susceptibility to network problems
    • Runs each E2E test as a separate job. This makes it easier to find E2E test runs of interest because one no longer has to keep track of which suite is in which workflow's job.
    • Uses a strategy matrix to auto-generate the job for each E2E test. This reduces duplicate code across our E2E test workflow files.
    • Before all the E2E jobs are started, download dependencies and compile webpack. Then make these prepared files available for each E2E test run, reducing overall runtime by avoiding redundant downloads and webpack compilation. Avoiding redundant downloads also reduces our susceptibility to network problems.

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

Work remaining:

  • Confirm that we can pass webpack files between jobs as an artifact. Since building webpack is the bulk of our installation (~20 mins), reusing these is the most important step.
  • Confirm that dependencies in oppia_tools are correctly being persisted to the second job. Installing dependencies is the next most time-consuming step (~4 mins), and since we cache pip packages (new in this PR) and node modules, most of the savings will likely come from oppia_tools. To check this, make sure that the installing dependencies step in the second job is fast.
  • Use a matrix to auto-generate jobs for each e2e suite from a single job section in the workflow file. This will cut down on code duplication and let us run every e2e suite as its own job.

Proof that changes are correct

Proof that pip caching works

In the CI runs on this PR (example) we load pip-tools from the cache:

Collecting pip-tools==6.6.2
  Using cached pip_tools-6.6.2-py3-none-any.whl (47 kB)

In contrast, in a CI run from develop (example), we download pip-tools:

Collecting pip-tools==6.6.2
  Downloading pip_tools-6.6.2-py3-none-any.whl (47 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.7/47.7 kB 2.0 MB/s eta 0:00:00

Proof that third-party dependencies transfer

Notice that in this CI run the install-oppia-dependencies step takes only ~2 mins instead of the usual ~4 mins. This speed-up is because third-party dependencies like the google cloud SDK don't have to be downloaded--they were loaded from the zip file.

Proof that upload/download is worthwhile

Comparing this new CI run to an old run we can see the impact of these changes on overall runtime. Note that we previously had 17 E2E test workflows, and we have 43 E2E test suites.

Step Duration Times needed before Total Duration Before Times needed now Total Duration Now
Creating zip file of build files 3:39 0 0:00 1 3:39
Uploading zip file 7:12 0 0:00 1 7:12
Downloading zip file 0:39 0 0:00 43 27:57
Unzipping build files 0:46 0 0:00 43 32:58
Compiling webpack 25:36 17 435:12 1 25:36
install-oppia-dependencies (no zip file) 5:24 17 91:48 1 5:24
install-oppia-dependencies (with zip file) 1:56 0 0:00 43 83:08
Total 527:00 185:54

Therefore even though we spin up more jobs with this approach and transfering build files as an artifact takes time, the benefits from only having to download dependencies and build webpack once mean that this transition will save us time overall.

Proof that all tests work

See CI runs: https://github.com/U8NWXD/oppia/actions/runs/3545519837

PR Pointers

  • Make sure to follow the instructions for making a code change.
  • If you need a review or an answer to a question, and don't have permissions to assign people, leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL". Oppiabot will help assign that person for you.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays.
  • Never force push. If you do, your PR will be closed.
  • Some of the e2e tests are flaky, and can fail for reasons unrelated to your PR. We are working on fixing this, but in the meantime, if you need to restart the tests, please check the "If your build fails" wiki page.

@U8NWXD U8NWXD requested a review from a team as a code owner November 26, 2022 00:56
@U8NWXD U8NWXD requested a review from a team November 26, 2022 00:56
@oppiabot
Copy link

oppiabot bot commented Nov 26, 2022

Hi @U8NWXD, can you complete the following:

  1. The proof that changes are correct has not been provided, please make sure to upload a image/video showing that the changes are correct. Or include a sentence saying "No proof of changes needed because" and the reason why proof of changes cannot be provided.
    Thanks!

This was referenced Nov 28, 2022
@U8NWXD U8NWXD deleted the cache-pip branch November 28, 2022 02:22
@seanlip
Copy link
Member

seanlip commented Nov 28, 2022

@U8NWXD Steps 3 and 4 of this comment are now done! However, I have two questions:

(a) In step 3, "collections" is included twice. Does there mean that there should be 42 workflows added, or that there should still be 43 because one of them is mistyped? (I've only added 42 so far.)

(b) In step 4, am I correct that e2e_coverage_and_typescript_tests (ubuntu-22.04) should be left as-is and not made un-required, or whether I should drop it as well? Currently, I have gone with the first one.

Thanks!

@seanlip seanlip assigned U8NWXD and unassigned seanlip Nov 28, 2022
@U8NWXD
Copy link
Member Author

U8NWXD commented Nov 28, 2022

a) Oops, collections should only appear once. I'll open a PR to remove the duplicate entry.

b) Yes, please leave e2e_coverage_and_typescript_tests un-changed. That job has not changed.

@U8NWXD
Copy link
Member Author

U8NWXD commented Nov 28, 2022

Opened #16645 to remove the duplicate collections entry

kevintab95 pushed a commit that referenced this pull request Dec 30, 2022
…shared webpack build (#16629)

* Enable pip caching on lint.yml as a test

* Pass build files between workflow jobs

* Zip build files before uploading

* For testing, delete e2e workflows not being developed currently

* Fix artifacts upload path

* Add commands to debug build_files.zip location

* Add ls -la debugging

* Add cd that I accidentally removed

* Use working-directory instead of cd

* Specify shell

* Update download path to be parent folder

* Add debugging ls -la statements

* Fix zip to add files recursively

* Add webpack bundles to artifact

* Include more build files in artifact, incl. app.yaml

* Remove comments and line breaks from zip command

* Preserve symlinks when zipping

* Include backend_prod_files/ in zip

* Implement strategy matrix for e2e tests

* Rename e2e workflow yaml now that we only have one

* Remove colon from name

* Revert "For testing, delete e2e workflows not being developed currently"

This reverts commit 11bf75a.

* Delete old e2e workflows

* Fix e2e captured in CI check

* Fix check_e2e_tests_are_captured_in_ci tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: require post-merge sync to HEAD Require all open pull requests to be updated after this PR get's merged
Projects
None yet
3 participants