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

Fix for flaky Windows tests preventing deployment #2647

Merged
merged 5 commits into from
Mar 1, 2023

Conversation

colinrotherham
Copy link
Contributor

This PR copies govuk-frontend by making Windows tests optional:

Choice of runner OS

Why? Since the puppeteer@1.14.0 puppeteer@18.2.1 upgrade Windows tests runs keep timing out:

Re-run failed jobs

This PR tackles the issue with:

  1. Only build once per test run via pretest
    This also fixes jest --watch running a full rebuild on every edit

  2. Run GitHub tasks in parallel
    Speeds up our GitHub workflow and gives each task a separate container

  3. Run GitHub tasks in Linux by default
    Windows test runs are now optional but may return

Running tests in parallel

Whilst running `jest --watch` we were doing a full build on every edit
@colinrotherham colinrotherham requested a review from a team as a code owner February 28, 2023 16:26
@netlify
Copy link

netlify bot commented Feb 28, 2023

You can preview this change here:

Name Link
🔨 Latest commit 2474a14
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/63fe478511f8800008fab6ae
😎 Deploy Preview https://deploy-preview-2647--govuk-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

"test": "npm run lint && jest",
"lint": "npm run lint:js && npm run lint:scss && npm run lint:html",
"lint": "npm run lint:js && npm run lint:scss && npm run lint:html --ignore-scripts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When running the "All in one" task npm test we have already built the site using pretest

So I've added --ignore-scripts to skip prelint:html to avoid a double build

Copy link
Member

@romaricpascal romaricpascal Feb 28, 2023

Choose a reason for hiding this comment

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

question If we're doing this to avoid the double build when running test, because both pretest and prelint:html run a build, would this addition be better suited to the test command? Can it run npm run lint -- --ignore-scripts to append ignore-scripts to the lint command (and as such to its last lint:html command)? No worries if it can't though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it work? Happy to switch it

Only worry is "lint" being reordered in future and the flag goes to the wrong script

Copy link
Member

Choose a reason for hiding this comment

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

Seems to work, yup (🤯), but good shout on the reordering. Feels odd that, when run through lint, lint:html won't build, but when run on its own it will. If it becomes an issue we can always adjust then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah maybe aligning it with govuk-frontend was the wrong move?

Where only "test" runs a build via "pretest"

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand your last answer, sorry 😔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry. I mean the linting tasks on govuk-frontend don't run a build, so I copied that here

Might be worth trying to tighten up what runs when

@colinrotherham
Copy link
Contributor Author

colinrotherham commented Feb 28, 2023

The branch protection status checks will need changing

These don't exist in the PR anymore:

Build & Test (ubuntu-latest)
Build & Test (windows-latest)

@colinrotherham
Copy link
Contributor Author

@romaricpascal One thing I left out from govuk-frontend was skipping the build when the SHA was built already

Click into "Cache build" and you'll see a warning is logged:
https://github.com/alphagov/govuk-design-system/actions/runs/4295154283/jobs/7486419368

The warning is logged because we already cached it on the previous run

If that's an issue I can put the conditions in we use in govuk-frontend:

# Skip install when build is already cached
if: steps.build-cache.outputs.cache-hit != 'true'

@romaricpascal
Copy link
Member

Oh, I wasn't aware of that. If we already have a solution on govuk-frontend, I wouldn't mind having it on this one as well to keep the output tidy, please 😄

@colinrotherham
Copy link
Contributor Author

Oh, I wasn't aware of that. If we already have a solution on govuk-frontend, I wouldn't mind having it on this one as well to keep the output tidy, please 😄

@romaricpascal Done, here's one that's been re-run:
https://github.com/alphagov/govuk-design-system/actions/runs/4296180852

If you click into the Build job you'll see the skipped steps

@colinrotherham colinrotherham merged commit d64b98e into main Mar 1, 2023
@colinrotherham colinrotherham deleted the workflow-parallel branch March 1, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

2 participants