mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
refactor(workflow): parallelize e2e preparation (#8481)
* e2e preparation: separate image buildings * e2e preparation: fix job naming * e2e preparation: set required jobs in cleanup job * e2e preparation: set restore keys * e2e preparation: reduce cleanup job dependencies * e2e preparation: remove primary cache key pattern * Revert "e2e preparation: remove primary cache key pattern" This reverts commit 9df95de90083cc296f38ae87b127f76ac4e59295. * e2e preparation: split cache restore steps * e2e preparation: set concrete archive paths * e2e preparation: remove redundant step id * e2e preparation: fix typo * e2e preparation: fix typo * e2e preparation: move env copying to cypress preaparation job * e2e preparation: update cache cleaning job * e2e preparation: refactor job and step naming * e2e preparation: add repo checkout step to cache cleanup job * e2e preparation: correct docker compose step * e2e preparation: correct backend env copying * e2e preparation: correct cypress cache restore key
This commit is contained in:
parent
fac818a3e4
commit
5d5a5b17b8
137
.github/workflows/test-e2e.yml
vendored
137
.github/workflows/test-e2e.yml
vendored
@ -3,8 +3,62 @@ name: ocelot.social end-to-end test CI
|
|||||||
on: push
|
on: push
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker_preparation:
|
prepare_neo4j_image:
|
||||||
name: Fullstack test preparation
|
name: Fullstack | prepare neo4j image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||||
|
|
||||||
|
- name: Build docker image
|
||||||
|
run: |
|
||||||
|
docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/
|
||||||
|
docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/neo4j.tar
|
||||||
|
|
||||||
|
- name: Cache docker image
|
||||||
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
|
with:
|
||||||
|
path: /tmp/neo4j.tar
|
||||||
|
key: ${{ github.run_id }}-e2e-neo4j-cache
|
||||||
|
|
||||||
|
prepare_backend_image:
|
||||||
|
name: Fullstack | prepare backend image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||||
|
|
||||||
|
- name: Build docker image
|
||||||
|
run: |
|
||||||
|
docker build --target test -t "ocelotsocialnetwork/backend:test" backend/
|
||||||
|
docker save "ocelotsocialnetwork/backend:test" > /tmp/backend.tar
|
||||||
|
|
||||||
|
- name: Cache docker image
|
||||||
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
|
with:
|
||||||
|
path: /tmp/backend.tar
|
||||||
|
key: ${{ github.run_id }}-e2e-backend-cache
|
||||||
|
|
||||||
|
prepare_webapp_image:
|
||||||
|
name: Fullstack | prepare webapp image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||||
|
|
||||||
|
- name: Build docker image
|
||||||
|
run: |
|
||||||
|
docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/
|
||||||
|
docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar
|
||||||
|
|
||||||
|
- name: Cache docker image
|
||||||
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # 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
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@ -13,19 +67,8 @@ jobs:
|
|||||||
- name: Copy env files
|
- name: Copy env files
|
||||||
run: |
|
run: |
|
||||||
cp webapp/.env.template webapp/.env
|
cp webapp/.env.template webapp/.env
|
||||||
cp frontend/.env.dist frontend/.env
|
|
||||||
cp backend/.env.test_e2e backend/.env
|
cp backend/.env.test_e2e backend/.env
|
||||||
|
|
||||||
- name: Build docker images
|
|
||||||
run: |
|
|
||||||
mkdir /tmp/images
|
|
||||||
docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/
|
|
||||||
docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/images/neo4j.tar
|
|
||||||
docker build --target test -t "ocelotsocialnetwork/backend:test" backend/
|
|
||||||
docker save "ocelotsocialnetwork/backend:test" > /tmp/images/backend.tar
|
|
||||||
docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/
|
|
||||||
docker save "ocelotsocialnetwork/webapp:test" > /tmp/images/webapp.tar
|
|
||||||
|
|
||||||
- name: Install cypress requirements
|
- name: Install cypress requirements
|
||||||
run: |
|
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"
|
wget --no-verbose -O /opt/cucumber-json-formatter "https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-386"
|
||||||
@ -35,21 +78,20 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
yarn install
|
yarn install
|
||||||
|
|
||||||
- name: Cache docker images
|
- name: Cache docker image
|
||||||
id: cache
|
|
||||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/opt/cucumber-json-formatter
|
/opt/cucumber-json-formatter
|
||||||
/home/runner/.cache/Cypress
|
/home/runner/.cache/Cypress
|
||||||
/home/runner/work/Ocelot-Social/Ocelot-Social
|
/home/runner/work/Ocelot-Social/Ocelot-Social
|
||||||
/tmp/images/
|
key: ${{ github.run_id }}-e2e-cypress
|
||||||
key: ${{ github.run_id }}-e2e-preparation-cache
|
|
||||||
|
|
||||||
fullstack_tests:
|
fullstack_tests:
|
||||||
name: Fullstack tests
|
name: Fullstack | tests
|
||||||
if: success()
|
if: success()
|
||||||
needs: docker_preparation
|
needs: [prepare_neo4j_image, prepare_backend_image, prepare_webapp_image, prepare_cypress]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
jobs: 8
|
jobs: 8
|
||||||
@ -58,25 +100,41 @@ jobs:
|
|||||||
# run copies of the current job in parallel
|
# run copies of the current job in parallel
|
||||||
job: [1, 2, 3, 4, 5, 6, 7, 8]
|
job: [1, 2, 3, 4, 5, 6, 7, 8]
|
||||||
steps:
|
steps:
|
||||||
- name: Restore cache
|
- name: Restore cypress cache
|
||||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
id: cache
|
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
/opt/cucumber-json-formatter
|
/opt/cucumber-json-formatter
|
||||||
/home/runner/.cache/Cypress
|
/home/runner/.cache/Cypress
|
||||||
/home/runner/work/Ocelot-Social/Ocelot-Social
|
/home/runner/work/Ocelot-Social/Ocelot-Social
|
||||||
/tmp/images/
|
key: ${{ github.run_id }}-e2e-cypress
|
||||||
key: ${{ github.run_id }}-e2e-preparation-cache
|
restore-keys: ${{ github.run_id }}-e2e-cypress
|
||||||
fail-on-cache-miss: true
|
|
||||||
|
- name: Restore neo4j cache
|
||||||
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
|
with:
|
||||||
|
path: /tmp/neo4j.tar
|
||||||
|
key: ${{ github.run_id }}-e2e-neo4j-cache
|
||||||
|
|
||||||
|
- name: Restore backend cache
|
||||||
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
|
with:
|
||||||
|
path: /tmp/backend.tar
|
||||||
|
key: ${{ github.run_id }}-e2e-backend-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
|
- name: Boot up test system | docker compose
|
||||||
run: |
|
run: |
|
||||||
chmod +x /opt/cucumber-json-formatter
|
chmod +x /opt/cucumber-json-formatter
|
||||||
sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter
|
sudo ln -fs /opt/cucumber-json-formatter /usr/bin/cucumber-json-formatter
|
||||||
docker load < /tmp/images/neo4j.tar
|
docker load < /tmp/neo4j.tar
|
||||||
docker load < /tmp/images/backend.tar
|
docker load < /tmp/backend.tar
|
||||||
docker load < /tmp/images/webapp.tar
|
docker load < /tmp/webapp.tar
|
||||||
docker compose -f docker-compose.yml -f docker-compose.test.yml up --build --detach --no-deps webapp neo4j backend mailserver
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --build --detach --no-deps webapp neo4j backend mailserver
|
||||||
sleep 90s
|
sleep 90s
|
||||||
|
|
||||||
@ -98,17 +156,24 @@ jobs:
|
|||||||
name: ocelot-e2e-test-report-pr${{ needs.docker_preparation.outputs.pr-number }}
|
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
|
path: /home/runner/work/Ocelot-Social/Ocelot-Social/cypress/reports/cucumber_html_report
|
||||||
|
|
||||||
cleanup:
|
cleanup_cache:
|
||||||
name: Cleanup
|
name: Cleanup Cache
|
||||||
needs: [docker_preparation, fullstack_tests]
|
needs: fullstack_tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions: write-all
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- name: Delete cache
|
- 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:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
|
||||||
gh extension install actions/gh-actions-cache
|
|
||||||
KEY="${{ github.run_id }}-e2e-preparation-cache"
|
|
||||||
gh actions-cache delete $KEY -R Ocelot-Social-Community/Ocelot-Social --confirm
|
|
||||||
Loading…
x
Reference in New Issue
Block a user