-
Notifications
You must be signed in to change notification settings - Fork 4.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
Testing: Fail CI build if local changes exist #10234
Conversation
cb43766
to
935248d
Compare
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 this.
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.
Tested locally and this worked (didn't error when nothing changed; error'd when changes exist).
Totally awesome, thanks a mil. 👍
package.json
Outdated
@@ -161,7 +161,9 @@ | |||
"build": "npm run build:packages && cross-env NODE_ENV=production webpack", | |||
"check-engines": "check-node-version --package", | |||
"check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"", | |||
"ci": "concurrently \"npm run lint\" \"npm run test-unit:coverage-ci\"", | |||
"precheck-local-changes": "npm run docs:build", | |||
"check-local-changes": "git diff --exit-code > /dev/null || ( echo \"There are local uncommitted changes after one or both of 'npm install' or 'npm run docs:build'!\" && exit 1 );", |
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.
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.
Yeah, especially in Travis, it's quite difficult to parse the failing output, made worse with concurrently
which doesn't display the failing command in the final result (https://github.com/kimmobrunfeldt/concurrently/issues/134).
For this case specifically, it would be nice too if we could limit the output by npm
, such that the message is the only thing or at least more obvious.
Oops, @mcsf beat me to it but my GitHub tab didn't update 😅 |
One can never have too many thumbs. |
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.
Looks good for package lock.
Build is failing because platform in which Travis runs will introduce changes to See: |
742a376
to
ed374b4
Compare
To accommodate the issue described in #10234 (comment), I've put together a small script which processes the diff via a series of disgusting regular expressions to effectively ignore the Would love any feedback on the revised approach, otherwise I may move forward with the merge as we're continuing to see the issue crop up (#10510 (comment), #10347 (comment)). |
ed374b4
to
fa44d86
Compare
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.
Reviewed the changes too; they make sense and are well-explained. 🚢
Thanks for providing working solution despite this nasty npm bug 👍 |
This pull request seeks to add a failure case to our existing
ci
script to trigger a build failure if local changes exist after one or both ofnpm run install
(e.g. unsyncedpackage-lock.json
changes) ornpm run docs:build
. This has been increasingly problematic as of late due to failures to update generated files upon changes, causing confusion for later developers who are then forced to consider how to reconcile the change.Testing instructions:
Verify that no error is produced upon running
npm run ci
(or, more specifically,npm run check-local-changes
) after checking out the branch.Verify that an error code is produced when making a local change (but not committing) and re-running the script.