From 3660d65465ab04af299e66927044dc48c190751c Mon Sep 17 00:00:00 2001 From: resonic-user Date: Mon, 16 Jun 2025 11:47:09 +0000 Subject: [PATCH] v --- .github/workflows/cache-verify.yml | 110 +++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .github/workflows/cache-verify.yml diff --git a/.github/workflows/cache-verify.yml b/.github/workflows/cache-verify.yml new file mode 100644 index 000000000..2e4d8e385 --- /dev/null +++ b/.github/workflows/cache-verify.yml @@ -0,0 +1,110 @@ +name: verify build and restore images + +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: production + - name: webapp + context: ./webapp + dockerfile: ./webapp/Dockerfile + target: production + - 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 + + build-environment: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies and build + run: | + cd backend && yarn install && yarn build + cd ../webapp && yarn install && yarn build + - name: Build environment image + run: | + docker build -t ocelotsocial/environment:cache -f Dockerfile.environment . + - name: Save environment image as artifact + run: docker save ocelotsocial/environment:cache -o environment.tar + - uses: actions/upload-artifact@v4 + with: + name: environment-image + path: environment.tar + + consolidate-environment: + runs-on: ubuntu-latest + needs: [build-images, verify-cache] + steps: + - uses: actions/checkout@v4 + - name: Download Docker image artifacts + uses: actions/download-artifact@v4 + with: + path: /tmp + - name: Load Docker images + run: | + docker load < /tmp/backend-image/backend.tar + docker load < /tmp/webapp-image/webapp.tar + docker load < /tmp/neo4j-image/neo4j.tar + - name: Setup .env files + run: | + cp webapp/.env.template webapp/.env || touch webapp/.env + cp backend/.env.test_e2e backend/.env || touch backend/.env + - name: Start system + run: | + docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach + - name: Wait for webapp + run: | + echo "Waiting for http://localhost:3000..." + for i in {1..15}; do + curl -sf http://localhost:3000 && echo "✅ Ready" && exit 0 + echo "$i..." && sleep 2 + done + echo "❌ Webapp did not respond in time" && exit 1 + + verify-summary: + runs-on: ubuntu-latest + needs: [build-environment, consolidate-environment] + if: always() + steps: + - name: CI Summary + run: | + echo "### ✅ CI Cache Verification Summary" >> $GITHUB_STEP_SUMMARY + echo "- Build Environment: ${{ needs.build-environment.result }}" >> $GITHUB_STEP_SUMMARY + echo "- Consolidate Environment: ${{ needs.consolidate-environment.result }}" >> $GITHUB_STEP_SUMMARY + if [[ '${{ needs.build-environment.result }}' != 'success' || '${{ needs.consolidate-environment.result }}' != 'success' ]]; then + echo "\n❌ One or more checks failed." >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo "\n✅ All checks passed successfully!" >> $GITHUB_STEP_SUMMARY + fi