This commit is contained in:
resonic-user 2025-06-16 12:39:24 +00:00
parent 9984363e88
commit 3cee492e55

View File

@ -1,11 +1,9 @@
name: CI Cache Verification
on:
push:
paths:
- '.github/workflows/cache-verify.yml'
workflow_dispatch:
jobs:
build-images:
runs-on: ubuntu-latest
@ -40,24 +38,31 @@ jobs:
with:
name: ${{ matrix.name }}-image
path: /tmp/${{ matrix.name }}.tar
cache-environment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- id: cache-key
env:
LOCK_HASH: ${{ hashFiles('backend/yarn.lock', 'webapp/yarn.lock', 'cypress/yarn.lock') }}
run: echo "key=ci-all-cache-${{ runner.os }}-${{ env.LOCK_HASH }}" >> $GITHUB_OUTPUT
- name: Compute cache key
id: cache-key
run: |
BACKEND_HASH=$(sha256sum backend/yarn.lock | cut -d' ' -f1)
WEBAPP_HASH=$(sha256sum webapp/yarn.lock | cut -d' ' -f1)
CYPRESS_HASH=$(sha256sum cypress/yarn.lock | cut -d' ' -f1 2>/dev/null || echo "none")
echo "lock-hash=${BACKEND_HASH}-${WEBAPP_HASH}-${CYPRESS_HASH}" >> $GITHUB_OUTPUT
echo "key=ci-all-cache-${{ runner.os }}-${BACKEND_HASH}-${WEBAPP_HASH}-${CYPRESS_HASH}" >> $GITHUB_OUTPUT
- name: Show lockfile hashes (debug)
run: |
echo "backend/yarn.lock hash: ${{ hashFiles('backend/yarn.lock') }}"
echo "webapp/yarn.lock hash: ${{ hashFiles('webapp/yarn.lock') }}"
echo "cypress/yarn.lock hash: ${{ hashFiles('cypress/yarn.lock') }}"
echo "backend/yarn.lock hash: $(sha256sum backend/yarn.lock | cut -d' ' -f1)"
echo "webapp/yarn.lock hash: $(sha256sum webapp/yarn.lock | cut -d' ' -f1)"
echo "cypress/yarn.lock hash: $(sha256sum cypress/yarn.lock | cut -d' ' -f1 2>/dev/null || echo 'not found')"
- name: Restore full CI cache
id: restore-cache
@ -66,8 +71,6 @@ jobs:
path: |
backend/node_modules
webapp/node_modules
cypress/node_modules
node_modules
~/.cache/Cypress
/opt/cucumber-json-formatter
key: ${{ steps.cache-key.outputs.key }}
@ -75,23 +78,22 @@ jobs:
ci-all-cache-${{ runner.os }}-
ci-all-cache-
- name: Show cache hit status
- name: Cache status: Hit
if: steps.restore-cache.outputs.cache-hit == 'true'
run: echo "✅ Cache was hit!"
- name: Show cache miss status
- name: Cache status: Miss
if: steps.restore-cache.outputs.cache-hit != 'true'
run: echo "❌ Cache was missed."
- name: Ensure Cypress binary is present
- name: Ensure Cypress and Formatter are present
run: |
if [ ! -x "$(command -v cypress)" ]; then
# Install Cypress CLI if needed
if ! npx --no-install cypress --version >/dev/null 2>&1; then
yarn global add cypress
fi
npx cypress verify
- name: Ensure cucumber-json-formatter present
run: |
# Install cucumber-json-formatter if missing
if [ ! -f /opt/cucumber-json-formatter ]; then
wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386"
chmod +x /opt/cucumber-json-formatter
@ -100,9 +102,8 @@ jobs:
- name: Print Cypress version
run: npx cypress --version
- name: Check Formatter
- name: Print Formatter version/help
run: /opt/cucumber-json-formatter --help || echo "Formatter missing"
consolidate-environment:
runs-on: ubuntu-latest
needs: [build-images, cache-environment]