Skip to content

Commit

Permalink
ci: improve node caching
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 24, 2023
1 parent af1b911 commit 4534ef5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Get Node.js cache directory
shell: bash
run: echo "NVE_CACHE=$(node -e 'console.log(require("cachedir")("nve"))')" >> $GITHUB_ENV
run: echo "NVE_CACHE=$(node -p 'require("cachedir")("nve")')" >> $GITHUB_ENV

- name: Cache Node.js versions
uses: actions/cache@v3
Expand Down
13 changes: 10 additions & 3 deletions tests/utils/node-versions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/**
* The specific version is used in CI because of caching
* Only pull the latest major version in development
* and upgrade manually for CI when needed
*/
const latestMajor = (version: string) => (process.env.CI ? version : version.split('.')[0]);

export const nodeVersions = [
'21',
latestMajor('21.2.0'),
...(
(
process.env.CI
&& process.platform !== 'win32'
)
? [
'20',
'18',
latestMajor('20.10.0'),
latestMajor('18.18.2'),
'18.0.0',
] as const
: [] as const
Expand Down

0 comments on commit 4534ef5

Please sign in to comment.