mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 15:25:57 +00:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
204 lines
7.2 KiB
YAML
204 lines
7.2 KiB
YAML
name: ocelot.social end-to-end test CI
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
prepare_backend_environment:
|
|
name: Fullstack | prepare backend environment
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4.2.2
|
|
|
|
- name: Copy backend env file
|
|
run: |
|
|
cp backend/.env.test_e2e backend/.env
|
|
cp webapp/.env.template webapp/.env
|
|
|
|
- name: Build backend and dependencies
|
|
run: |
|
|
# Build and start all required images for backend
|
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach neo4j backend --build
|
|
|
|
# Save the build images
|
|
docker save "ghcr.io/ocelot-social-community/ocelot-social/backend:test" > /tmp/backend.tar
|
|
docker save "ghcr.io/ocelot-social-community/ocelot-social/neo4j:community" > /tmp/neo4j.tar
|
|
docker save "quay.io/minio/minio:latest" > /tmp/minio.tar
|
|
docker save "quay.io/minio/mc:latest" > /tmp/minio-mc.tar
|
|
docker save "maildev/maildev:latest" > /tmp/mailserver.tar
|
|
|
|
# Stop the containers
|
|
docker compose -f docker-compose.yml -f docker-compose.test.yml down
|
|
|
|
- name: Cache docker images
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # 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
|
|
|
|
prepare_webapp_image:
|
|
name: Fullstack | prepare webapp image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4.2.2
|
|
|
|
- name: Copy backend env file
|
|
run: |
|
|
cp backend/.env.test_e2e backend/.env
|
|
cp webapp/.env.template webapp/.env
|
|
|
|
- name: Build docker image
|
|
run: |
|
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach webapp --build --no-deps
|
|
docker save "ghcr.io/ocelot-social-community/ocelot-social/webapp:test" > /tmp/webapp.tar
|
|
|
|
- name: Cache docker image
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.0.2
|
|
with:
|
|
path: /tmp/webapp.tar
|
|
key: ${{ github.run_id }}-e2e-webapp-cache
|
|
|
|
prepare_cypress:
|
|
name: Fullstack | prepare cypress
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4.2.2
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v4.4.0
|
|
with:
|
|
node-version-file: 'backend/.tool-versions'
|
|
cache: 'yarn'
|
|
|
|
- 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 docker image
|
|
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.0.2
|
|
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: [prepare_backend_environment, prepare_webapp_image, prepare_cypress]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
jobs: 8
|
|
strategy:
|
|
matrix:
|
|
# run copies of the current job in parallel
|
|
job: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4.2.2
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v4.4.0
|
|
with:
|
|
node-version-file: 'backend/.tool-versions'
|
|
cache: 'yarn'
|
|
|
|
- name: Restore cypress cache
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.0.2
|
|
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@0057852bfaa89a56745cba8c7296529d2fc39830 # 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@0057852bfaa89a56745cba8c7296529d2fc39830 # 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 < /tmp/neo4j.tar
|
|
docker load < /tmp/backend.tar
|
|
docker load < /tmp/minio.tar
|
|
docker load < /tmp/minio-mc.tar
|
|
docker load < /tmp/mailserver.tar
|
|
docker load < /tmp/webapp.tar
|
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach backend mailserver webapp
|
|
sleep 90s
|
|
|
|
- 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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4.2.2
|
|
|
|
- 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 }}
|