mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-18 10:51:28 +00:00
130 lines
4.3 KiB
YAML
130 lines
4.3 KiB
YAML
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
|
|
|
|
cache-environment:
|
|
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', 'cypress/yarn.lock') }}
|
|
run: echo "key=ci-all-cache-${{ 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') }}"
|
|
echo "cypress/yarn.lock hash: ${{ hashFiles('cypress/yarn.lock') }}"
|
|
- name: Restore full CI cache
|
|
id: restore-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
backend/node_modules
|
|
webapp/node_modules
|
|
cypress/node_modules
|
|
node_modules
|
|
~/.cache/Cypress
|
|
/opt/cucumber-json-formatter
|
|
key: ${{ steps.cache-key.outputs.key }}
|
|
restore-keys: |
|
|
ci-all-cache-${{ runner.os }}-
|
|
ci-all-cache-
|
|
- 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
|
|
|
|
- name: Ensure Cypress binary is present
|
|
run: |
|
|
if [ ! -x "$(command -v cypress)" ]; then
|
|
yarn global add cypress
|
|
fi
|
|
npx cypress verify
|
|
- name: Ensure cucumber-json-formatter present
|
|
run: |
|
|
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
|
|
fi
|
|
- name: Print Cypress version
|
|
run: npx cypress --version
|
|
- name: Check Formatter
|
|
run: /opt/cucumber-json-formatter --help || echo "Formatter missing"
|
|
|
|
|
|
consolidate-environment:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-images, cache-environment]
|
|
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
|