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

ci: improve cache #319

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,32 @@ jobs:

- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
run: echo "PNPM_STORE=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
name: Setup pnpm cache
name: Cache pnpm
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
path: ${{ env.PNPM_STORE }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-

- name: Install dependencies
run: pnpm install

- name: Restore Node.js versions
id: cache-nodejs
uses: actions/cache/restore@v3
- name: Get Node.js cache directory
shell: bash
run: echo "NVE_CACHE=$(node -e 'console.log(require("cachedir")("nve"))')" >> $GITHUB_ENV

- name: Cache Node.js versions
uses: actions/cache@v3
with:
path: /home/runner/.cache/nve
path: ${{ env.NVE_CACHE }}
key: ${{ runner.os }}-nodejs-${{ hashFiles('tests/index.ts') }}
restore-keys: ${{ runner.os }}-nodejs-

- name: Test
run: pnpm test

- name: Save Node.js versions
uses: actions/cache/save@v3
with:
path: /home/runner/.cache/nve
key: ${{ steps.cache-nodejs.outputs.cache-primary-key }}

- name: Type check
if: ${{ matrix.os == 'ubuntu-latest' }}
run: pnpm type-check
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@types/node": "^20.6.0",
"@types/react": "^18.2.21",
"@types/semver": "^7.5.1",
"cachedir": "^2.4.0",
"chokidar": "^3.5.3",
"clean-pkg-json": "^1.2.0",
"cleye": "^1.3.2",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 1 addition & 18 deletions tests/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import { describe } from 'manten';
import { createFixture } from 'fs-fixture';
import { createNode } from './utils/tsx';

const isWin = process.platform === 'win32';
import { nodeVersions } from './utils/node-versions';

const packageTypes = [
'commonjs',
'module',
] as const;

const nodeVersions = [
'18',
'20',
...(
(process.env.CI && !isWin)
? [
'12.20.0', // CJS named export detection added
'12',
'14',
'16',
'17',
]
: []
),
];

(async () => {
for (const packageType of packageTypes) {
await describe(`Package type: ${packageType}`, async ({ describe, onFinish }) => {
Expand Down
18 changes: 18 additions & 0 deletions tests/utils/node-versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const nodeVersions = [
'18',
'20',
...(
(
process.env.CI
&& process.platform !== 'win32'
)
? [
'12.20.0', // CJS named export detection added
'12',
'14',
'16',
'17',
] as const
: [] as const
),
] as const;
Loading