CI now uses actions/setup-node to setup Node and restore the Yarn cache (#89363)

## About The Pull Request
This PR changes CI to use `actions/setup-node` to setup Node, instead of
using `tools/ci/install_node.sh`. The version given to this action is
the same as specified in `dependencies.sh`.

This fixes the issue of CI not using the node version provided in
`dependencies.sh`. Previously, it was using the system-wide Node, which
at the time of this PR is `v20.18.2`.

This change is NOT applied across all jobs, but is applied at minimum to
any jobs where the game is compiled. For example, any integration test
jobs now use `actions/setup-node` - but the "Remove guide comments" job
is untouched.

This PR has the additional following effects:
* The node install is no longer cached - it is instead downloaded from
<https://github.com/actions/node-versions> (or
<https://nodejs.org/dist/> if that fails). Being that the CI runner
needs to contact Github anyways to obtain the cached Node install, this
should make no difference.
* We no longer have to perform Yarn caching ourselves -
`actions/setup-node` does it for us! However, a side effect of this is
that the Yarn cache uses a different cache key now. I would have set up
the action to pull from the existing cache, but unfortunately that
wasn't an option.

Speaking of caching - the new action, `.github/actions/setup_node`, will
NOT restore the Yarn cache unless the `restore-yarn-cache` input is
`true`. This saves a couple seconds where we need node, but don't need
the yarn cache (such as in integration tests).
This commit is contained in:
MichiRecRoom
2025-02-07 14:54:26 -05:00
committed by GitHub
parent 8a1c511dee
commit ba7f720eaa
5 changed files with 37 additions and 31 deletions
+26
View File
@@ -0,0 +1,26 @@
# This action is a wrapper around `actions/setup-node`, to use the version specified in
# `dependencies.sh`.
name: Setup Node
description: Install Node using the version specified in `dependencies.sh`; additionally, restores the Yarn cache if one exists
inputs:
restore-yarn-cache:
description: 'If `true`, restores the Yarn cache alongside installing node.'
required: false
type: boolean
default: false
runs:
using: composite
steps:
- name: Configure Node version
shell: bash
run: |
source dependencies.sh
echo "NODE_VERSION_REQUIRED=$NODE_VERSION_LTS" >> $GITHUB_ENV
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_REQUIRED }}
cache: ${{ fromJSON(inputs.restore-yarn-cache) && 'yarn' || '' }}
cache-dependency-path: ${{ fromJSON(inputs.restore-yarn-cache) && 'tgui/yarn.lock' || '' }}