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

Upgrade govuk-prototype-kit #121

Closed
wants to merge 4 commits into from
Closed

Conversation

yndajas
Copy link
Member

@yndajas yndajas commented Nov 1, 2024

The app is currently broken. This fixes it by way of upgrading to govuk-prototype-kit@latest, and adds testing to prevent automated dependency upgrades fully breaking the app in future

I've pre-emptively added branch protection and set to test step of the end-to-end tests workflow as required

@yndajas yndajas force-pushed the upgrade-govuk-prototype-kit branch from c19c638 to 09fe4dd Compare November 1, 2024 15:31
The app currently errors when starting up with the following message:

```
[...]/dxw-prototype-lib/lib/extensions/extensions.js:75
    throw new Error(`All extension paths must start with a forward slash - "${subject.packageName}" used "${subject.item}".`)
    ^

Error: All extension paths must start with a forward slash - "govuk-frontend" used "[object Object]".
    at throwIfBadFilepath (/Users/ynda/code/github.com/dxw/dxw-prototype-lib/lib/extensions/extensions.js:75:11)
    at getFileSystemPath (/Users/ynda/code/github.com/dxw/dxw-prototype-lib/lib/extensions/extensions.js:145:3)
    at getPublicUrlAndFileSystemPath (/Users/ynda/code/github.com/dxw/dxw-prototype-lib/lib/extensions/extensions.js:152:19)
    at Array.map (<anonymous>)
    at Object.getPublicUrlAndFileSystemPaths (/Users/ynda/code/github.com/dxw/dxw-prototype-lib/lib/extensions/extensions.js:162:57)
    at setupPathsFor (/Users/ynda/code/github.com/dxw/dxw-prototype-lib/lib/middleware/extensions/extensions.js:7:14)
    at Object.<anonymous> (/Users/ynda/code/github.com/dxw/dxw-prototype-lib/lib/middleware/extensions/extensions.js:13:1)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
```

I was able to get the app running fine by adjusting some code in
lib/extensions/extensions.js and
lib/middleware/extensions/extensions.js, but the server logs showed some
missing file errors and this felt a bit hacky. These lib files were
generated when installing the app from [email protected] and
hadn't been touched since

Instead, this migrates the app to govuk-prototype-kit@latest (which
should be 13.16.2). It took a few attempts to get the migration to run
successfully, since some of the generated files had been edited. I
reverted some of these to their default to allow the migration to run
in full, then reapplied some of the changes we've made:
- Add custom `beforeContent` and `header` blocks in
  app/views/layout.html
- Add `serviceName` in app/config.json (previously in app/config.js)
- Add `module.exports = router` in app/routes.js
- Retain the Procfile but remove the build script since this no longer
  exists
- Retain the README.md but move it to the project root (and auto-format
  it)

This app has no tests, so it's likely that a Renovate upgrade PR was
incompatible with [email protected] and therefore broke things
quietly. This was only noticed when someone tried to look at the app on
Heroku
@yndajas yndajas force-pushed the upgrade-govuk-prototype-kit branch from 09fe4dd to 5d50e86 Compare November 1, 2024 15:34
Breaking changes were merged to the app that caused it to be unable to
boot up. We didn't notice this until someone tried to load up the
deployed site. Non-major Renovate dependency PRs are merged
automatically on this repo, which is risky without at least minimal
automated testing. We had a CI workflow to test that the app built but
this evidently wasn't sufficient. This adds Playwright so that we can do
a basic 'homepage loads' kind of end-to-end test, and run this on CI for
pull requests and pushes to main
Per the last commit, this is to ensure automated dependency PRs don't
get merged and silently bring the app down
@yndajas yndajas force-pushed the upgrade-govuk-prototype-kit branch from 5d50e86 to 1131c30 Compare November 1, 2024 15:38
Copy link
Member

@jdudley1123 jdudley1123 left a comment

Choose a reason for hiding this comment

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

This is great work, but I think it needs to be split out a bit as there are a lot of changes happening:

  • PR 1: Upgrade govuk-prototype-kit, 2 commits, one with the automated changes, one with our changes reapplied
  • PR 2: Set up Playwright and add basic end-to-end test

Not sure where the image fixing goes, depends what triggered it.

@yndajas
Copy link
Member Author

yndajas commented Nov 6, 2024

This is great work, but I think it needs to be split out a bit as there are a lot of changes happening:

  • PR 1: Upgrade govuk-prototype-kit, 2 commits, one with the automated changes, one with our changes reapplied
  • PR 2: Set up Playwright and add basic end-to-end test

Not sure where the image fixing goes, depends what triggered it.

Yeah that's fair. I was going for a green upgrade commit, but given the app's not currently functional, we might as well break down the journey. The test stuff is related but not required to get app running again, so I'm happy to split it out. I've broken the work into three PRs: #125, #126, and #127

@yndajas yndajas mentioned this pull request Nov 6, 2024
@yndajas yndajas marked this pull request as draft November 6, 2024 15:00
@yndajas
Copy link
Member Author

yndajas commented Nov 6, 2024

Replaced by the three PRs linked in the previous comment

@yndajas yndajas closed this Nov 6, 2024
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