mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-19 03:11:30 +00:00
182 lines
5.8 KiB
YAML
182 lines
5.8 KiB
YAML
name: ocelot.social end-to-end test CI
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
build_images:
|
|
name: Build Docker Images
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- service: backend
|
|
dockerfile: backend/Dockerfile
|
|
context: backend
|
|
target: build
|
|
- service: webapp
|
|
dockerfile: webapp/Dockerfile
|
|
context: webapp
|
|
target: build
|
|
- service: neo4j
|
|
dockerfile: neo4j/Dockerfile
|
|
context: neo4j
|
|
target: community
|
|
steps:
|
|
- name: Checkout code
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build ${{ matrix.service }} image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./${{ matrix.context }}
|
|
file: ./${{ matrix.dockerfile }}
|
|
target: ${{ matrix.target }}
|
|
tags: ghcr.io/ocelot-social-community/ocelot-social/${{ matrix.service }}:test
|
|
push: false
|
|
outputs: type=docker,dest=/tmp/${{ matrix.service }}.tar
|
|
|
|
- name: Upload Docker image tarball
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.service }}-image
|
|
path: /tmp/${{ matrix.service }}.tar
|
|
|
|
prepare_cypress:
|
|
name: Fullstack | prepare cypress
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Wait for webapp to be ready
|
|
run: |
|
|
npm install --no-save wait-on
|
|
npx wait-on http://localhost:3000 --timeout 120000
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Copy env files
|
|
run: |
|
|
cp webapp/.env.template webapp/.env
|
|
cp backend/.env.test_e2e backend/.env
|
|
|
|
- name: Install cypress requirements
|
|
run: |
|
|
wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386"
|
|
cd backend
|
|
yarn install
|
|
yarn build
|
|
cd ..
|
|
yarn install
|
|
|
|
- name: Cache cypress
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
/opt/cucumber-json-formatter
|
|
/home/runner/.cache/Cypress
|
|
/home/runner/work/Ocelot-Social/Ocelot-Social
|
|
key: ${{ github.run_id }}-e2e-cypress
|
|
|
|
fullstack_tests:
|
|
name: Fullstack | tests
|
|
if: success()
|
|
needs: [build_images, prepare_cypress]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
jobs: 8
|
|
strategy:
|
|
matrix:
|
|
job: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download Docker image tarballs
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp
|
|
|
|
- name: Restore cypress cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
/opt/cucumber-json-formatter
|
|
/home/runner/.cache/Cypress
|
|
/home/runner/work/Ocelot-Social/Ocelot-Social
|
|
key: ${{ github.run_id }}-e2e-cypress
|
|
restore-keys: ${{ github.run_id }}-e2e-cypress
|
|
|
|
- name: Restore backend environment cache
|
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
|
with:
|
|
path: |
|
|
/tmp/backend.tar
|
|
/tmp/neo4j.tar
|
|
/tmp/minio.tar
|
|
/tmp/minio-mc.tar
|
|
/tmp/mailserver.tar
|
|
key: ${{ github.run_id }}-e2e-backend-environment-cache
|
|
|
|
- name: Restore webapp cache
|
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
|
with:
|
|
path: /tmp/webapp.tar
|
|
key: ${{ github.run_id }}-e2e-webapp-cache
|
|
|
|
- name: Boot up test system | docker compose
|
|
run: |
|
|
chmod +x /opt/cucumber-json-formatter
|
|
sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter
|
|
docker load -i /tmp/neo4j-image/neo4j.tar
|
|
docker load -i /tmp/backend-image/backend.tar
|
|
docker load -i /tmp/webapp-image/webapp.tar
|
|
docker load -i /tmp/minio.tar || true
|
|
docker load -i /tmp/minio-mc.tar || true
|
|
docker load -i /tmp/mailserver.tar || true
|
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach backend mailserver webapp
|
|
|
|
- name: Wait for webapp to be ready
|
|
run: |
|
|
npm install --no-save wait-on
|
|
npx wait-on http://localhost:3000 --timeout 120000
|
|
|
|
- name: Full stack tests | run tests
|
|
id: e2e-tests
|
|
run: yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} )
|
|
|
|
- name: Full stack tests | if tests failed, compile html report
|
|
if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }}
|
|
run: |
|
|
cd cypress/
|
|
node create-cucumber-html-report.js
|
|
- name: Full stack tests | if tests failed, upload report
|
|
id: e2e-report
|
|
if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ocelot-e2e-test-report-pr${{ needs.docker_preparation.outputs.pr-number }}
|
|
path: /home/runner/work/Ocelot-Social/Ocelot-Social/cypress/reports/cucumber_html_report
|
|
|
|
cleanup_cache:
|
|
name: Cleanup Cache
|
|
needs: fullstack_tests
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
|
|
|
- name: Full stack tests | cleanup cache
|
|
run: |
|
|
cacheKeys=$(gh cache list --json key --jq '.[] | select(.key | startswith("${{ github.run_id }}-e2e-")) | .key')
|
|
set +e
|
|
echo "Deleting caches..."
|
|
for cacheKey in $cacheKeys
|
|
do
|
|
gh cache delete "$cacheKey"
|
|
done
|
|
echo "Done"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |