This commit is contained in:
resonic-user 2025-06-17 16:45:31 +00:00
parent aeb4077adc
commit f8dcf591fe

View File

@ -55,56 +55,33 @@ jobs:
- name: Compute cache key (unique per run)
id: cache-key
run: |
ROOT_HASH=$(sha256sum yarn.lock | cut -d' ' -f1)
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 "nocypress")
KEY="ci-all-cache-${{ runner.os }}-${BACKEND_HASH}-${WEBAPP_HASH}-${CYPRESS_HASH}-run${{ github.run_id }}"
KEY="ci-unified-cache-${{ runner.os }}-${ROOT_HASH}-${BACKEND_HASH}-${WEBAPP_HASH}-${{ github.run_id }}"
echo "key=$KEY"
echo "key=$KEY" >> $GITHUB_OUTPUT
- name: Ensure directory structure
run: mkdir -p backend webapp cypress
- name: Restore CI cache
- name: Restore unified CI cache
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
backend/node_modules
webapp/node_modules
cypress/node_modules
~/.cache/Cypress
/opt/cucumber-json-formatter
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
ci-all-cache-${{ runner.os }}-
ci-unified-cache-${{ runner.os }}-
- name: Install backend dependencies if needed
- name: Install all dependencies
run: |
if [ ! -d backend/node_modules ] || [ -z "$(ls -A backend/node_modules)" ]; then
cd backend && yarn install
fi
- name: Install webapp dependencies if needed
run: |
if [ ! -d webapp/node_modules ] || [ -z "$(ls -A webapp/node_modules)" ]; then
cd webapp && yarn install
fi
- name: Install Cypress (local in cypress/)
run: |
if [ -f cypress/package.json ]; then
cd cypress
if [ ! -d node_modules ] || [ -z "$(ls -A node_modules)" ]; then
echo "Installing Cypress locally in cypress/"
yarn install
npx --yes cypress verify
else
echo "✅ cypress/node_modules already present."
fi
else
echo "⚠️ No cypress/package.json found — skipping local Cypress install"
fi
yarn install
cd backend && yarn install && cd ..
cd webapp && yarn install && cd ..
npx cypress verify || echo "Cypress verify failed (likely not yet installed)"
- name: Install cucumber-json-formatter if missing
run: |
@ -113,18 +90,19 @@ jobs:
chmod +x /opt/cucumber-json-formatter
fi
- name: Save updated CI cache
- name: Save unified CI cache
uses: actions/cache/save@v4
if: always()
with:
path: |
node_modules
backend/node_modules
webapp/node_modules
cypress/node_modules
~/.cache/Cypress
/opt/cucumber-json-formatter
key: ${{ steps.cache-key.outputs.key }}
verify-environment:
runs-on: ubuntu-latest
needs: [cache-environment]
@ -132,41 +110,27 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Ensure directory structure exists
run: mkdir -p backend webapp cypress
- name: Restore CI cache
- name: Restore unified CI cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
backend/node_modules
webapp/node_modules
cypress/node_modules
~/.cache/Cypress
/opt/cucumber-json-formatter
key: ${{ needs.cache-environment.outputs.cache-key }}
restore-keys: |
ci-all-cache-${{ runner.os }}-
ci-unified-cache-${{ runner.os }}-
- name: Check backend/node_modules
- name: Check all node_modules exist
run: |
[ -d node_modules ] && [ -n "$(ls -A node_modules)" ] || (echo "❌ node_modules missing" && exit 1)
[ -d backend/node_modules ] && [ -n "$(ls -A backend/node_modules)" ] || (echo "❌ backend/node_modules missing" && exit 1)
- name: Check webapp/node_modules
run: |
[ -d webapp/node_modules ] && [ -n "$(ls -A webapp/node_modules)" ] || (echo "❌ webapp/node_modules missing" && exit 1)
- name: Check cypress/node_modules
- name: Check Cypress binary & CLI
run: |
[ -d cypress/node_modules ] && [ -n "$(ls -A cypress/node_modules)" ] || (echo "❌ cypress/node_modules missing" && exit 1)
- name: Check Cypress binary cache
run: |
[ -d ~/.cache/Cypress ] || (echo "❌ Cypress binary cache missing" && exit 1)
- name: Check Cypress CLI (from local install)
run: |
cd cypress
npx --yes cypress --version
npx --yes cypress verify
@ -174,34 +138,6 @@ jobs:
run: |
[ -x /opt/cucumber-json-formatter ] && /opt/cucumber-json-formatter --help || (echo "❌ Formatter missing" && exit 1)
- name: CI Cache Health Summary
run: |
echo "📦 CI Cache Health Summary:"
echo
check() {
if [ -d "$1" ] && [ -n "$(ls -A $1)" ]; then
echo "✅ $1 OK"
else
echo "❌ $1 missing or empty"
fi
}
check backend/node_modules
check webapp/node_modules
check cypress/node_modules
[ -d ~/.cache/Cypress ] && echo "✅ Cypress binary cache OK" || echo "❌ Cypress binary cache missing"
[ -x /opt/cucumber-json-formatter ] && echo "✅ Formatter executable OK" || echo "❌ Formatter missing"
echo
if [ -d backend/node_modules ] && [ -d webapp/node_modules ] && \
[ -d cypress/node_modules ] && [ -d ~/.cache/Cypress ] && \
[ -x /opt/cucumber-json-formatter ]; then
echo "🎉 ✅ All dependencies loaded from cache ready to test"
else
echo "⚠️ Partial cache some installs might have been required"
fi
consolidate-environment:
runs-on: ubuntu-latest