Skip to content

feat: output cache restore values (#13) #45

feat: output cache restore values (#13)

feat: output cache restore values (#13) #45

Workflow file for this run

name: test
on:
- push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TZ: Asia/Tokyo
jobs:
save:
strategy:
fail-fast: false
matrix:
runner:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.runner }}
timeout-minutes: 5
permissions:
contents: read
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
- id: os-info
uses: openameba/action-os-info@b1395f434e5fc0aab838ce4f823d6c844e230f07 # v1.0.0
- id: cache-key
run: >
echo 'suffix=${{ format('{0}-{1}-{2}-{3}', runner.environment, runner.arch, runner.os, steps.os-info.outputs.version) }}'
| tee -a "$GITHUB_OUTPUT"
- run: echo '{"private":true}' | tee package.json
- run: npm install --no-audit --no-progress --prefer-offline --save-exact undici
- run: |
gh cache delete 'npm-${{ steps.cache-key.outputs.suffix }}-${{ hashFiles('package-lock.json') }}'
gh cache delete 'node_modules-${{ steps.cache-key.outputs.suffix }}-${{ hashFiles('package-lock.json') }}'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PROMPT_DISABLED: 1
continue-on-error: true
- uses: ./save
- id: npm-cache
run: echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT"
- uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: npm-${{ steps.cache-key.outputs.suffix }}-${{ hashFiles('package-lock.json') }}
fail-on-cache-miss: true
lookup-only: true
- uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: '**/node_modules'
key: node_modules-${{ steps.cache-key.outputs.suffix }}-${{ hashFiles('package-lock.json') }}
fail-on-cache-miss: true
lookup-only: true
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
if-no-files-found: error
name: metafiles-${{ steps.cache-key.outputs.suffix }}
path: |
package.json
package-lock.json
retention-days: 1
restore:
strategy:
fail-fast: false
matrix:
runner:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.runner }}
needs: save
timeout-minutes: 5
permissions:
contents: read
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: lts/*
- id: os-info
uses: openameba/action-os-info@b1395f434e5fc0aab838ce4f823d6c844e230f07 # v1.0.0
- id: cache-key
run: >
echo 'suffix=${{ format('{0}-{1}-{2}-{3}', runner.environment, runner.arch, runner.os, steps.os-info.outputs.version) }}'
| tee -a "$GITHUB_OUTPUT"
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: metafiles-${{ steps.cache-key.outputs.suffix }}
- id: restore
uses: ./restore
- run: test -d "$(npm config get cache)"
- run: test -d node_modules
- run: test -n '${{ steps.restore.outputs.npm-cache-hit }}'
- run: test -n '${{ steps.restore.outputs.npm-cache-primary-key }}'
- run: test -n '${{ steps.restore.outputs.npm-cache-matched-key }}'
- run: test -n '${{ steps.restore.outputs.node_modules-cache-hit }}'
- run: test -n '${{ steps.restore.outputs.node_modules-cache-primary-key }}'
- run: test -n '${{ steps.restore.outputs.node_modules-cache-matched-key }}'