feat(action): Node20, multi-OS/Arch, caching, tests, and Workflows #807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
This PR relates to the discussion from #806 regarding the Node16 deprecation notice.
During this we talked about adding support for multiple OSes, as well as addressing
the caching logic. There was quite a bit of change required to make this work,
so I took the liberty of updating others files to better reflect most
TypeScript Actions now-a-days and adding many more test cases.
There are no breaking changes. Everything will continue to work without
change for existing users, just with a few enhancements. I was actually able to
plug in my fork on some personal projects without any changes.
I hope I'm not overstepping with a PR of this size but I wanted to give a "complete package" - I had some fun fleshing this
out so I may have gone a bit overboard too haha 😇 Happy to make any adjustments
Action CI: https://github.com/IAreKyleW00t/slsa-verifier/actions/runs/10911993495
Test PR w/ bad dist/ changes: https://github.com/IAreKyleW00t/slsa-verifier/actions/runs/10911978180
Update dist/ with Workflow: https://github.com/IAreKyleW00t/slsa-verifier/actions/runs/10911989035
Re-test PR: https://github.com/IAreKyleW00t/slsa-verifier/actions/runs/10912006068
Node20
Obviously this is on Node20, but wanted to make sure it was called out that the
actions/installer/.node-version
file is what defines theversion to be used by CI and developer locals.
README updates
The README has been updated with more information on the Action itself. Since
users are already directed there from the main README, I figured it would be
worth updating this to include details like Inputs, Outputs, usage, and even
Developer guides.
Multi-OS and Arch support
As mentioned, since the main SLSA Verifier project builds binaries for Linux,
macOS, and Windows, I thought it would be good to have this action cover this
too.
The
actions/installer/src/bootstrap.ts
file defines updated SHA256values and includes values for Windows, macOS, and Linux, along with their amd64
and arm64 variants.
The only caveat to this support is that the SLSA Verifier only started releasing
builds for Windows and macOS as of
v2.1.0
, so attempting to use this Actionwith an older version would result in an error (which is tested and called out
in the README).
Versioning
There is now a
version
input to allow the user to install specific version ofthe SLSA verifier. By default this with use the
GITHUB_ACTION_REF
environmentvariable like the previous verison of this Action would. There is a test
included to ensure this sort of logic will work.
Inputs that are allow are:
latest
- Will look up the latest Release and use that.GITHUB_ACTION_REF
env, like mentioned above.vX.Y.Z
- a valid Semantic version tag with thev
prefix. This will bevalidated to ensure the version exists.
functionality with the
GITHUB_ACTION_REF
. This will look through allSemantic Version tags with pagination for a matching commit. It will also make
sure the tag it matches is valid version and has a valid release.
Caching
I saw that the
@action/tool-cache
package was being used but it was missing acrutial step to actually utilize the Runners cache. I've updated the logic to
actually cache files, so existing binaries on the runners will be used to speed up the process.
Cached binaries will always be validated.
I also added logic to skip re-installing the SLSA Verifier if the version is the
same as the bootstrap version. Since we already validate that directly with it's
SHA256 we can simply re-use it.
The bootstrap binary is cached the same as the main binary.
You can use the
cache
input to manually override the caching behavior. If youuse
false
it will still use the Runner tool-cache location, but willalways overwrite the cache. This is true for the bootstrapper too.
Installation PATH
Because we're properly using the Runner tool-cache the final binary no longer
needs to be in the users
HOME
directory. Instead the PATH will be updated withthe Runners cache location, like mentioned above.
This should have no impact on anyone unless they were strictly relying on having
the bin in their
HOME
vs in theirPATH
.Testing, Linting, Formating
The standard
eslint
Linter andprettier
Formatter (that are used with most modern TypeScriptActions) have been included to keep things aligned automatically. Most of the code
aligned to this already since I don't think too much changed in that regards,
but the tooling has been updated and validated.
This is included as part of the
npm run all
command and the Workflows, but canbe triggered individually with
npm run format:write
andnpm run lint
Test coverage has been completely overhauled to include more test cases and
coverage and much more thorough integration testing with the Action itself.
There are 30+ TypeScript tests (~5s), including 30+ Integration tests
(60s) with a workflow where it is not easy to mock locally.
This is incorporated into the
npm run all
command and the Workflows, but canbe triggered individually with
npm run test
.The
Makefile
was updated to include the equivalent commands.Workflows
Both the
e2e.schedule.installer.yml
andupdate-actions-dist-post-commit.yml
have been completely updated to support this new setup. They will "just work".
The E2E Workflow is where the Integration tests take place, which include a
number of matrixed operations to fully validate the Actions various cases across
every supported platform.
The E2E Installer Action CI will trigger on any changes to the Workflow file itself
or on any file changes in the
actions/installer/
directory, on themain
branch.The
update-actions-dist-post-commit.yml
Workflow no longer generates a.patch
file. Instead,it will move the entire
dist/
folder andgit add
them in the job with higher access.The previous Worklfows appeared to have been failing, so
I needed to fix them in order to properly test things anyways.
Misc
Other files in the root of the
actions/installer
that were changes wererelated to linters, testing, etc. They are just part of a TypeScript Action.
The source files are updated with the SLSA Apache-2.0 LICENSE notice at the top
of each source
.ts
file.jasmine
testing suite replaced withjest
andlib
is replaced with the newerdist
naming convention