Skip to content

package lock

package lock #303

Workflow file for this run

# Build a cache of build artifacts after PRs to speed up subsequent builds
name: cache
on:
push:
branches: [main, dev, staging]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }}
GH_TOKEN: ${{ secrets.PROSOPONATOR_PAT }}
CARGO_TERM_COLOR: always
NODE_OPTIONS: "--max-old-space-size=4096"
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Print contexts
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
ENV_CONTEXT: ${{ toJson(env) }}
VARS_CONTEXT: ${{ toJson(vars) }}
JOB_CONTEXT: ${{ toJson(job) }}
STEPS_CONTEXT: ${{ toJson(steps) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
SECRETS_CONTEXT: ${{ toJson(secrets) }}
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
NEEDS_CONTEXT: ${{ toJson(needs) }}
INPUTS_CONTEXT: ${{ toJson(inputs) }}
run: |
echo "******************************"
echo "github:" "$GITHUB_CONTEXT"
echo "******************************"
echo "env:" "$ENV_CONTEXT"
echo "******************************"
echo "vars:" "$VARS_CONTEXT"
echo "******************************"
echo "job:" "$JOB_CONTEXT"
echo "******************************"
echo "steps:" "$STEPS_CONTEXT"
echo "******************************"
echo "runner:" "$RUNNER_CONTEXT"
echo "******************************"
echo "secrets:" "$SECRETS_CONTEXT"
echo "******************************"
echo "strategy:" "$STRATEGY_CONTEXT"
echo "******************************"
echo "matrix:" "$MATRIX_CONTEXT"
echo "******************************"
echo "needs:" "$NEEDS_CONTEXT"
echo "******************************"
echo "inputs:" "$INPUTS_CONTEXT"
echo "******************************"
- uses: actions/checkout@v4
with:
submodules: "recursive"
# make cache dirs, these must exist before doing cache stuff
- run: mkdir -p ~/.npm
- run: mkdir -p ~/.cache/Cypress
# don't restore the cache, otherwise we get artifacts left over from the previous run sit in the cache for eternity. Do a clean build every time.
- run: npm cache clean --force
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm i -g "npm@$(jq -r .engines.npm < package.json)"
- run: npm ci
# install cypress so we don't have to do that every time
- run: npx cypress install
- name: Save npm cache
uses: actions/cache/save@v4
if: always()
with:
path: |
~/.npm
~/.cache/Cypress
key: npm-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Cleanup npm caches
if: always()
run: |
set -euxo pipefail # stop on errors, print commands, fail on pipe fails
# remove all but the latest cache, leaving only the cache we just saved
set +e; gh extension install actions/gh-actions-cache; set -e
echo "Fetching list of cache key"
cacheKeys=$(gh actions-cache list --sort created-at --order desc --limit 100 -R "${{ github.repository }}" --key "npm-${{ runner.os }}-${{ runner.arch }}-" | cut -f 1 | tail -n +3)
echo caches to be removed:
echo "${cacheKeys}"
set +e
for cacheKey in $cacheKeys
do
gh actions-cache delete "$cacheKey" -R "${{ github.repository }}" --confirm
done