Ocelot-Social/.github/workflows/cache-verify.yml
resonic-user 683d0565d7 v
2025-06-16 10:45:06 +00:00

95 lines
3.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: CI Cache Verification
on:
push:
paths:
- '.github/workflows/cache-verify.yml'
workflow_dispatch:
jobs:
verify-summary:
runs-on: ubuntu-latest
needs: [verify-cache, verify-backend, verify-webapp]
if: always()
steps:
- name: CI Summary
run: |
echo "### ✅ CI Cache Verification Summary" >> $GITHUB_STEP_SUMMARY
echo "- Cache: ${{ needs.verify-cache.result }}" >> $GITHUB_STEP_SUMMARY
echo "- Backend: ${{ needs.verify-backend.result }}" >> $GITHUB_STEP_SUMMARY
echo "- Webapp: ${{ needs.verify-webapp.result }}" >> $GITHUB_STEP_SUMMARY
if [[ '${{ needs.verify-cache.result }}' != 'success' || '${{ needs.verify-backend.result }}' != 'success' || '${{ needs.verify-webapp.result }}' != 'success' ]]; then
echo "
❌ One or more checks failed." >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "
✅ All checks passed successfully!" >> $GITHUB_STEP_SUMMARY
fi
verify-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- id: cache-key
env:
LOCK_HASH: ${{ hashFiles('backend/yarn.lock', 'webapp/yarn.lock') }}
run: echo "key=node-modules-${{ runner.os }}-${{ env.LOCK_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') }}"
- name: Restore node_modules cache
id: restore-cache
uses: actions/cache@v4
with:
path: |
backend/node_modules
webapp/node_modules
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
node-modules-${{ runner.os }}-
node-modules-
- name: Show cache hit status
run: |
if [[ "${{ steps.restore-cache.outputs.cache-hit }}" == "true" ]]; then
echo "✅ Cache was hit!"
else
echo "❌ Cache was missed."
fi
verify-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: cd backend && yarn install && yarn build
verify-webapp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: cd webapp && yarn install && yarn build
- run: |
if [ -d "webapp/out" ]; then
echo "Serving webapp/out statically..."
npx serve -s webapp/out -l 3000 &
else
echo "webapp/out not found falling back to yarn start..."
cd webapp && yarn start &
fi
- run: |
echo "Waiting for http://localhost:3000 to respond..."
for i in {1..15}; do
curl -sf http://localhost:3000 && echo "✅ Service ready." && exit 0
echo "$i..." && sleep 2
done
echo "❌ Service did not respond in time." && exit 1