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

Merged
merged 3 commits into from Oct 15, 2018

Conversation

@aduth
Member

aduth commented Sep 28, 2018

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 of npm run install (e.g. unsynced package-lock.json changes) or npm 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.

@aduth aduth requested a review from gziolo Sep 28, 2018

@aduth aduth referenced this pull request Oct 3, 2018

Merged

RichText state structure for value manipulation #7890

4 of 4 tasks complete

@aduth aduth requested review from iseulde and mcsf Oct 3, 2018

@aduth aduth requested review from kadamwhite and youknowriad Oct 3, 2018

@mcsf

mcsf approved these changes Oct 3, 2018

Thanks for this.

@tofumatt

Tested locally and this worked (didn't error when nothing changed; error'd when changes exist).

Totally awesome, thanks a mil. 👍

@@ -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 );",

This comment has been minimized.

@tofumatt

tofumatt Oct 3, 2018

Member

It might be nice to add a newline \n in at the end of this message; it's just a bit busy with NPM's output in there. 🤷‍♂️

screenshot 2018-10-03 11 25 38

This comment has been minimized.

@aduth

aduth Oct 3, 2018

Member

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 (kimmobrunfeldt/concurrently#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.

@tofumatt

This comment has been minimized.

Member

tofumatt commented Oct 3, 2018

Oops, @mcsf beat me to it but my GitHub tab didn't update 😅

@mcsf

This comment has been minimized.

Contributor

mcsf commented Oct 3, 2018

One can never have too many thumbs.

@tofumatt

This comment has been minimized.

Member

tofumatt commented Oct 3, 2018

a848a38336c2a7869308c2e4de41b754

@iseulde

iseulde approved these changes Oct 3, 2018

Looks good for package lock.

@iseulde

This comment has been minimized.

Member

iseulde commented Oct 3, 2018

@aduth Merged #10304 which included the package lock update.

@aduth

This comment has been minimized.

Member

aduth commented Oct 4, 2018

Build is failing because platform in which Travis runs will introduce changes to package-lock.json after an install.

See:

@aduth

This comment has been minimized.

Member

aduth commented Oct 12, 2018

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 "optional": true additions to package-lock.json, while still otherwise capturing local changes which could occur by npm install.

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)).

@aduth aduth referenced this pull request Oct 12, 2018

Merged

Fix docs manifest #10555

aduth and others added some commits Oct 12, 2018

@tofumatt

Reviewed the changes too; they make sense and are well-explained. 🚢

@gziolo gziolo merged commit 552913a into master Oct 15, 2018

2 checks passed

codecov/project 49.47% remains the same compared to b1c05b3
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@gziolo gziolo deleted the add/ci-fail-local-changes branch Oct 15, 2018

@gziolo gziolo added this to the 4.1 milestone Oct 15, 2018

@gziolo

This comment has been minimized.

Member

gziolo commented Oct 15, 2018

Thanks for providing working solution despite this nasty npm bug 👍

etoledom added a commit that referenced this pull request Oct 15, 2018

Testing: Fail CI build if local changes exist (#10234)
* Testing: Fail CI build if local changes exist

* Tooling: Ignore optional changes to lockfile

* chore: Tweak diff script comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment