name: CI Cache Verification on: push: paths: - '.github/workflows/cache-verify.yml' workflow_dispatch: jobs: build-images: runs-on: ubuntu-latest strategy: matrix: include: - name: backend context: ./backend dockerfile: ./backend/Dockerfile target: build - name: webapp context: ./webapp dockerfile: ./webapp/Dockerfile target: build - name: neo4j context: ./neo4j dockerfile: ./neo4j/Dockerfile target: community steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - name: Build ${{ matrix.name }} image uses: docker/build-push-action@v5 with: context: ${{ matrix.context }} file: ${{ matrix.dockerfile }} target: ${{ matrix.target }} push: false outputs: type=docker,dest=/tmp/${{ matrix.name }}.tar - name: Upload ${{ matrix.name }} image uses: actions/upload-artifact@v4 with: name: ${{ matrix.name }}-image path: /tmp/${{ matrix.name }}.tar 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-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