mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-18 10:51:28 +00:00
v
This commit is contained in:
parent
748780141f
commit
8fb5223d9d
133
.github/workflows/cache-verify.yml
vendored
133
.github/workflows/cache-verify.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: verify build and restore images
|
||||
name: CI Cache Verification and E2E Testing
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -7,69 +7,86 @@ on:
|
||||
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
|
||||
|
||||
build-environment:
|
||||
name: Build Dependencies and Environment
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Install dependencies and build
|
||||
|
||||
- name: Cache backend node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: backend/node_modules
|
||||
key: node-modules-backend-${{ hashFiles('backend/yarn.lock') }}
|
||||
restore-keys: node-modules-backend-
|
||||
|
||||
- name: Cache webapp node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: webapp/node_modules
|
||||
key: node-modules-webapp-${{ hashFiles('webapp/yarn.lock') }}
|
||||
restore-keys: node-modules-webapp-
|
||||
|
||||
- name: Build backend and webapp
|
||||
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:
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-artifacts
|
||||
path: |
|
||||
backend/node_modules
|
||||
backend/build
|
||||
webapp/node_modules
|
||||
webapp/out
|
||||
backend/.env
|
||||
webapp/.env
|
||||
|
||||
build-images:
|
||||
name: Build Docker Images
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-images, build-environment]
|
||||
strategy:
|
||||
matrix:
|
||||
service: [backend, webapp, neo4j]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download Docker image artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: build-artifacts
|
||||
path: ./build-artifacts
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- name: Build ${{ matrix.service }} image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./${{ matrix.service }}
|
||||
file: ./${{ matrix.service }}/Dockerfile
|
||||
target: production
|
||||
push: false
|
||||
outputs: type=docker,dest=/tmp/${{ matrix.service }}.tar
|
||||
- name: Upload ${{ matrix.service }} image
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.service }}-image
|
||||
path: /tmp/${{ matrix.service }}.tar
|
||||
|
||||
consolidate-environment:
|
||||
name: Consolidate Environment and Run Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-environment, build-images]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: |
|
||||
backend-image
|
||||
webapp-image
|
||||
neo4j-image
|
||||
build-artifacts
|
||||
path: /tmp
|
||||
- name: Load Docker images
|
||||
run: |
|
||||
@ -78,26 +95,30 @@ jobs:
|
||||
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
|
||||
cp /tmp/build-artifacts/backend/.env backend/.env || true
|
||||
cp /tmp/build-artifacts/webapp/.env webapp/.env || true
|
||||
- name: Start system
|
||||
run: |
|
||||
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach
|
||||
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
|
||||
echo "Waiting $i..."
|
||||
sleep 2
|
||||
done
|
||||
echo "❌ Webapp did not respond in time" && exit 1
|
||||
- name: Install Cypress and run tests
|
||||
run: |
|
||||
yarn install
|
||||
yarn run cypress:run
|
||||
|
||||
verify-summary:
|
||||
name: CI Summary
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-environment, consolidate-environment]
|
||||
if: always()
|
||||
steps:
|
||||
- name: CI Summary
|
||||
- name: Show summary
|
||||
run: |
|
||||
echo "### ✅ CI Cache Verification Summary" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Build Environment: ${{ needs.build-environment.result }}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user