-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: enable caching for lint task #26791
Conversation
4 flaky tests on run #46907 ↗︎
Details:
create-from-component.cy.ts • 1 flaky test • app-e2e
specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e
cypress-origin-communicator.cy.ts • 1 flaky test • app-e2e
subscriptions/configChange-subscription.cy.ts • 1 flaky test • app-e2e
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
This PR is a follow up PR after this PR gets merged |
"runner": "nx-cloud", | ||
"options": { | ||
"cacheableOperations": [ | ||
"lint" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what enables lint
tasks to be cached with Nx Cloud
{ | ||
"name": "internal-scripts", | ||
"scripts": { | ||
"lint": "eslint --ext .js,.ts,.json, ." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root level package.json
lint
script also ran this task. This makes the /scripts
directory its own lib from an Nx standpoint and moves the lint
script here so that it can be cached the same way the other libs do
@@ -41,7 +41,7 @@ | |||
"ensure-deps": "./scripts/ensure-dependencies.sh", | |||
"get-next-version": "node scripts/get-next-version.js", | |||
"postinstall": "node ./scripts/run-postInstall.js", | |||
"lint": "lerna run lint --no-bail --concurrency 2 && eslint --ext .js,.ts,.json, scripts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the linting of the /scripts
folder is now moved inside of /scripts/package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dropped linting of the root-level js/json files which we want to keep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root level files were not being linted before. We were only running lint
across all the packages + manually linting the scripts folder. This just moves the manual linting of the scripts to it's own lint
job so the first command will trigger it
b004271
to
b1b523d
Compare
@@ -0,0 +1,17 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be able to re-use the root-level eslint configuration instead of needing to manage another one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the root .eslintrc
config will throw 340 lint errors:
- Unexpected console statement
- Synchronous fs calls should not be used in Cypress
We could certainly ignore these other ways but I feel like a separate config for these scripts makes sense given these warnings. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changed that is is failing with this PR using the same eslint config file and not in develop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jordanpowell88 I found this PR here from a few months ago that was adding linting to the scripts directory. In it, a no-console
of off
was added to an overrides section in the main .eslintrc.js
file. Should this now be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@warrensplayer great catch! I removed that rule in 42aefb1
d33a71f
to
a4d5817
Compare
0b744ad
to
a66a89c
Compare
@@ -13,7 +13,7 @@ | |||
"binary-upload": "node ./scripts/binary.js upload", | |||
"binary-zip": "node ./scripts/binary.js zip", | |||
"build": "yarn build-npm-modules && lerna run build --stream --no-bail --ignore create-cypress-tests --ignore cypress --ignore \"'@packages/{runner}'\" --ignore \"'@cypress/{angular,react,react18,vue,vue2,mount-utils,svelte}'\" && node ./cli/scripts/post-build.js && lerna run build --stream --scope create-cypress-tests", | |||
"build-npm-modules": "lerna run build --scope cypress --scope @cypress/mount-utils && lerna run build --scope \"'@cypress/{angular,react,react18,vue,vue2,svelte}'\"", | |||
"build-npm-modules": "lerna run build --scope cypress --scope @cypress/mount-utils --scope @cypress/react && lerna run build --scope \"'@cypress/{angular,react18,vue,vue2,svelte}'\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jordanpowell88 What is this change doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically because npm/react18 dependsOn npm/react this was failing in CI. It's the same reason why we are building npm/mount-utils before building the rest. By adding Nx into the equation and because we have 2 outputs for the npm libs (their dist and the cli) it was sometimes creating an issue in CI. This change appears to have fixed the inconsistency in CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did your changes for the lint task cause this task to start failing? I saw the issue you had in this branch in CI, but could not find it failing in develop
. Also, I was looking at the differences between the build step in this branch and develop and saw a few differences. The main one was this:
cypress:build --> @cypress/react:build --> cypress:build
here: https://app.circleci.com/pipelines/github/cypress-io/cypress/53051/workflows/046ba13e-d424-469d-a1af-aeac31bc00ed/jobs/2186964/parallel-runs/0/steps/0-114
Is this a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea we have many circular dependencies which is causing this. That is why it requires a bit of change to the build step even though we aren't technically doing anything with build in this PR. This was work that would need to be done either eventually anyways when we cache the build step
"targetDefaults": { | ||
"lint": { | ||
"inputs": [ | ||
"default", | ||
"{workspaceRoot}/.eslintrc.js" | ||
] | ||
}, | ||
"build": { | ||
"dependsOn": [ | ||
"^build" | ||
] | ||
}, | ||
"build-prod": { | ||
"dependsOn": [ | ||
"^build-prod" | ||
] | ||
} | ||
}, | ||
"namedInputs": { | ||
"sharedGlobals": [], | ||
"default": [ | ||
"{projectRoot}/**/*", | ||
"sharedGlobals" | ||
], | ||
"production": [ | ||
"default", | ||
"!{projectRoot}/**/*.spec.ts", | ||
"!{projectRoot}/**/*.md", | ||
"!{projectRoot}/tsconfig.spec.json", | ||
"!{projectRoot}/.eslintrc.json", | ||
"!{projectRoot}/.mocharc.{js,json}", | ||
"!{projectRoot/cypress.config.{ts,js}", | ||
"!{projectRoot/**/*.cy.ts" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jordanpowell88 I am not sure how NX works exactly, so I am not sure how to validate the changes here in nx.json
. Can you describe what each part is doing and point to NX documentation that describes how these should be configured. I am guessing it is describing what should or should not be cache for the task, but not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@warrensplayer . Here is the documentation.
But yes in short, yes the namedInputs
are used to define sort of "shared" global things that specific tasks would read to determine if a library's cache should be invalidated or not.
For Example: the defaultTargets.lint.inputs
array has 2 items that invalidate it's cache. The workspace .eslintrc.js
file and default
. Default points to the namedInputs.default
array which includes any file in that libraries directory ({projectRoot}/**/*
) and the sharedGlobals
which would be any shared global files that should be included across tasks (in our case it is empty)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. Final question in this section... Is the production
option under namedInputs
being used by anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not currently. But I went ahead and added what I would expect to be starting values we would use. We can certainly remove this if we want for the time being though
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
This PR enables
lint
ing withNx Cloud
.Before this step in CI took:
5m 27s
After this step in CI took:
1m 46s
Steps to test
yarn lint
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?