Skip to content

Add "check-javascript-syntax" CircleCI build task#590

Merged
aduth merged 13 commits intomainfrom
aduth-try-es5-safe
Mar 19, 2021
Merged

Add "check-javascript-syntax" CircleCI build task#590
aduth merged 13 commits intomainfrom
aduth-try-es5-safe

Conversation

@aduth
Copy link
Copy Markdown
Contributor

@aduth aduth commented Mar 17, 2021

Why: To help avoid issues where JavaScript code which is not supported in legacy browsers could unknowingly be included in the built assets.

See:

Changes temporarily include a revert of #587 to verify that the build fails as expected. This should be re-reverted prior to merging.

aduth added 2 commits March 17, 2021 17:22
**Why**: To help avoid issues where JavaScript code which is not supported in legacy browsers could unknowingly be included in the built assets.

See:

- #587
- 18F/identity-idp#4296
@aduth
Copy link
Copy Markdown
Contributor Author

aduth commented Mar 17, 2021

Fails in CircleCI as expected:

#!/bin/bash -eo pipefail
npm run es5-safe

> identity-site@1.0.0 es5-safe /home/circleci/project
> find assets/js/build -name '*.js' -exec cat {} \; | acorn --ecma5 --silent

The keyword 'const' is reserved (2:95470)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! identity-site@1.0.0 es5-safe: `find assets/js/build -name '*.js' -exec cat {} \; | acorn --ecma5 --silent`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the identity-site@1.0.0 es5-safe script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/circleci/.npm/_logs/2021-03-17T22_39_16_534Z-debug.log


Exited with code exit status 1
CircleCI received exit code 1

@aduth
Copy link
Copy Markdown
Contributor Author

aduth commented Mar 17, 2021

Revert the revert in 286bbe5.

@aduth aduth marked this pull request as ready for review March 17, 2021 22:40
Copy link
Copy Markdown
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

- install-dependencies
- run:
name: build javascript
command: npm run build-js
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have a lot of parallel build steps now.

Our JS build is fairly fast, so maybe not worth it here, but this is duplicated from our build-site command. Maybe would it be worth having a multi-phase job where we build the site once in build-site and then save the workspace and load that workspace in all the jobs that run the various checks?

So it would look like:

[build site, cache artifact] ->
  - run JS lint
  - run JS specs
  - run ruby specs on built site, etc etc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that sounds really great. I've tried incorporating this for "base" tests, as well as the external links checking which has a similar need. The timings aren't quite as promising as I'd have hoped, and in-fact the builds take slightly longer than before I'd incorporated it.

Still, it seems like a good idea in theory, and might help some future scalability, so I'd be fine to keep the changes 🤷

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome! thanks for digging in to all that! I'm OK keeping these changes if you are

aduth added 8 commits March 18, 2021 15:54
**Why**: Avoid per-job checkout, install, build
**Why**: Less to persist, vendor dependencies can be expected to be cached in install-dependencies caching
Fix error: "Directory you are trying to checkout to is not empty and not a git repository"
- persist_to_workspace:
root: "."
paths:
- "_site"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we want to persist the node_modules etc too? or do we assume that caching will take care of that for us

Copy link
Copy Markdown
Contributor Author

@aduth aduth Mar 18, 2021

Choose a reason for hiding this comment

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

do we want to persist the node_modules etc too? or do we assume that caching will take care of that for us

I did that at first, and I found that it took a very long time for the persist_to_workspace step itself to complete, probably because node_modules is a black hole. And yeah, was hopeful that the caching in install-dependencies could keep it fast enough.

See: fe78bdf

@aduth aduth merged commit ea3e321 into main Mar 19, 2021
@aduth aduth deleted the aduth-try-es5-safe branch March 19, 2021 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants