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: optimize task execution #27848

Merged
merged 37 commits into from Oct 4, 2023
Merged

Conversation

astone123
Copy link
Contributor

@astone123 astone123 commented Sep 19, 2023

This PR makes various improvements to task execution both locally and in CI. Main changes are

  • Allow Lerna (Nx) to cache the results of build targets for all packages (note that the CLI package cypress is excluded from this and uses its own command build-cli)
  • Remove buildProd gulp command and incorporate steps into build commands inside of the packages that are related to each step. This allows for caching these steps with Lerna
  • Change the name of the cli build step to build-cli so that Lerna doesn't cache it
  • Add yarn autoclean to remove unnecessary files from node modules to reduce the cache size
  • Remove unnecessary build-prod targets for packages
  • Parallelize test runs for test-binary-against-recipes job in CI
  • Resolve various circular dependencies between packages

The results of these changes are:

  • Decreased CI runtime for most change sets
  • Decreased build time for local development

Testing

  • Download a pre-release binary from a recent commit and manually smoke test it.
  • Look at the CI runs for this branch and look for abnormal behavior

Related work

This work requires changes to the cypress-publish-binary project as well
https://github.com/cypress-io/cypress-publish-binary/pull/28

astone123 and others added 29 commits August 21, 2023 11:36
* chore: update build-npm-modules script

* chore: update build-npm-modules script

* chore: update build-npm-modules script

* chore: update build-npm-modules script

* chore: update lerna to 6

* [run ci]

* try caching build step

* we can't clean without building after

* add dependencies on scripts for npm packages

* update commands

* add config for data-context build step

* fix output configurations for npm packages, add gitignores

* revert changes to config and data-context build steps

* fix outputs

* run with cache

* fix outputs for cli

* actually fix outputs

* test with cache

---------

Co-authored-by: astone123 <adams@cypress.io>
* chore: simplify build script

* update CI workflows

* fix workflows

* empty commit because Percy weirdness
@astone123 astone123 self-assigned this Sep 19, 2023
@astone123 astone123 changed the title optimize tasks chore: optimize task execution Sep 20, 2023
@@ -14,6 +14,7 @@ const { getNextVersionForBinary } = require('../get-next-version')
}

const body = JSON.stringify({
branch: 'lerna-optimize-tasks',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures that the pipeline that we trigger runs on the lerna-optimize-tasks branch in the publish binary workflow. I'll remove this before merging and merge my corresponding PR https://github.com/cypress-io/cypress-publish-binary/pull/28

@@ -102,7 +102,12 @@ export async function buildCypressApp (options: BuildCypressAppOpts) {
if (!keepBuild) {
log('#buildPackages')

await execa('yarn', ['lerna', 'run', 'build-prod', '--ignore', 'cli', '--concurrency', '4'], {
await execa('yarn', ['lerna', 'run', 'build', '--concurrency', '4'], {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to make sure that everything is built here before we build the binary. These will be cached because we already built them in a previous step. We can probably remove this in the future

@@ -116,30 +115,6 @@ gulp.task('open', startCypressWatch)
* Tasks that aren't watched. Usually composed together with other tasks.
*------------------------------------------------------------------------**/

gulp.task('buildProd',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I targeted this task because it was being called in CI, but I want to come back and clean up more of these tasks - we don't need to use Gulp for these tasks. Each task should be isolated to its related package if possible

@@ -1,5 +1,6 @@
{
"name": "internal-scripts",
"version": "0.0.0-development",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets rid of that annoying warning saying that scripts doesn't have a version

@astone123 astone123 marked this pull request as ready for review September 20, 2023 16:05
@cypress
Copy link

cypress bot commented Sep 20, 2023

5 flaky tests on run #51443 ↗︎

0 466 19 0 Flakiness 5

Details:

try to fix Electron install in Windows workflow
Project: cypress Commit: 0caf3fd52a
Status: Passed Duration: 16:50 💡
Started: Oct 4, 2023 5:11 PM Ended: Oct 4, 2023 5:28 PM
Flakiness  cypress\e2e\runs.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
... > displays a list of recorded runs if a run has been recorded Test Replay Output Screenshots
Flakiness  cypress\e2e\create-from-component.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
... > Shows create from component card for React projects Test Replay Output Screenshots
Flakiness  cypress\e2e\specs.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
... > shows No Specs page with specPattern from config Test Replay Output Screenshots
Flakiness  cypress\e2e\specs_list_latest_runs.cy.ts • 2 flaky tests • app-e2e

View Output Video

Test Artifacts
App/Cloud Integration - Latest runs and Average duration > when no runs are recorded > shows placeholders for all visible specs Test Replay Output Screenshots
App/Cloud Integration - Latest runs and Average duration > when offline > shows offline alert then hides it after coming online Test Replay Output Screenshots

Review all test suite changes for PR #27848 ↗︎

Copy link
Collaborator

@jordanpowell88 jordanpowell88 left a comment

Choose a reason for hiding this comment

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

Looks good to me overall. Left a couple of minor changes that aren't show stoppers but ideally we can resolve them before merging. Also left a few future improvements comments along the way that we can use to inform future improvements

npm/react/package.json Outdated Show resolved Hide resolved
npm/react18/package.json Outdated Show resolved Hide resolved
"nexus-build"
],
"outputs": [
"{workspaceRoot}/packages/frontend-shared/cypress/support/generated/test-graphql-types.gen.ts",
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's worth noting that we should eventually move away from one lib having outputs in another. It's fine for now but we should consider refactoring this at some point

@@ -170,9 +145,6 @@ gulp.task('watchForE2E', gulp.series(
*------------------------------------------------------------------------**/

gulp.task('cyRunLaunchpadE2E', gulp.series(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this no longer needed because the build has already been cached? This probably works as is in CI but ideally those gulp script that call the build-prod would have a depends on build in case someone tries to run this locally. Probably ok for now but we want to get to a place where local and CI run the same way

scripts/run-postInstall.js Outdated Show resolved Hide resolved
@dkasper-was-taken dkasper-was-taken merged commit 4c11731 into develop Oct 4, 2023
126 of 128 checks passed
@dkasper-was-taken dkasper-was-taken deleted the lerna-optimize-tasks branch October 4, 2023 17:25
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 11, 2023

Released in 13.3.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.3.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Oct 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants