alphagov / govuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
https://frontend.design-system.service.gov.uk/
MIT License
1.16k stars 320 forks source link

File sizes commented on pull requests didn't vary between two PRs #4147

Closed romaricpascal closed 9 months ago

romaricpascal commented 1 year ago

The comment of the file stats reported the same file sizes on the PR that disabled mangling of our class and function names and the last one merged on main.

Running build:release on main and my branch locally does give me different file sizes (and a 10K smaller number than on the stats PR):

Terser options updated
-rw-r--r--   1 romaric.pascal  staff    35K Aug 30 09:31 govuk-frontend-4.6.0.min.js

main
-rw-r--r--   1 romaric.pascal  staff    34K Aug 30 09:56 govuk-frontend-4.6.0.min.js
romaricpascal commented 1 year ago

One lead could be the checkout action using main instead of the actual branch the PR relates to: https://github.com/actions/checkout/issues/1418.

romaricpascal commented 1 year ago

Started a little branch for investigation, logging the SHA that are checked out in the different scripts.

Looking at the logs (expanding "Checking out the ref" in the "Checkout code" step), the stats job checks out the same ref as the ref that the build checks out and the rest of out actions (the SHA referenced by github.sha which is the merge of the PR head with the branch it'll be merged into).

To be continued...

romaricpascal commented 1 year ago

Looks like our workflows are only building the npm package and not the files for our release archive. That would explain the sameness of the stats, as well as the 10K difference between local and CI.

Two potential fixes:

  1. Updating the files being built and the cache paths so we build dist as well.

    npm run build --workspaces --if-present --ignore-scripts
    npm run build:release --workspaces --if-present --ignore-scripts
  2. If it slows the whole checks too much, we could add a step to build of the release only in the stats workflow