mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
refactor(webapp): adapt webapp docker build stages to match e2e testing requirements (#8651)
* refactor: change webapp docker build stages to match e2e testing requirements * refactor: remove build parameter from final docker compose steptin e2e test workflow * Revert "refactor: remove build parameter from final docker compose steptin e2e test workflow" This reverts commit 63461874ba389f6fcdd1f57b45d7f531088cd10a. * e2e: update backend env template for e2e testing * e2e: update e2e testing workflow to recent changes in backend building and config * e2e: update e2e testing workflow add missing env copy * e2e: update e2e testing workflow add missing env copy * e2e: update e2e testing workflow add missing env copy
This commit is contained in:
parent
c1fe4d240b
commit
b61fd597ec
87
.github/workflows/test-e2e.yml
vendored
87
.github/workflows/test-e2e.yml
vendored
@ -3,41 +3,43 @@ name: ocelot.social end-to-end test CI
|
|||||||
on: push
|
on: push
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare_neo4j_image:
|
prepare_backend_environment:
|
||||||
name: Fullstack | prepare neo4j image
|
name: Fullstack | prepare backend environment
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||||
|
|
||||||
- name: Build docker image
|
- name: Copy backend env file
|
||||||
run: |
|
run: |
|
||||||
docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/
|
cp backend/.env.test_e2e backend/.env
|
||||||
docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/neo4j.tar
|
cp webapp/.env.template webapp/.env
|
||||||
|
|
||||||
- name: Cache docker image
|
- 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 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:test" > /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@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
with:
|
with:
|
||||||
path: /tmp/neo4j.tar
|
path: |
|
||||||
key: ${{ github.run_id }}-e2e-neo4j-cache
|
/tmp/backend.tar
|
||||||
|
/tmp/neo4j.tar
|
||||||
prepare_backend_image:
|
/tmp/minio.tar
|
||||||
name: Fullstack | prepare backend image
|
/tmp/minio-mc.tar
|
||||||
runs-on: ubuntu-latest
|
/tmp/mailserver.tar
|
||||||
steps:
|
key: ${{ github.run_id }}-e2e-backend-environment-cache
|
||||||
- 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:
|
prepare_webapp_image:
|
||||||
name: Fullstack | prepare webapp image
|
name: Fullstack | prepare webapp image
|
||||||
@ -46,10 +48,15 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
|
||||||
|
|
||||||
|
- name: Copy backend env file
|
||||||
|
run: |
|
||||||
|
cp backend/.env.test_e2e backend/.env
|
||||||
|
cp webapp/.env.template webapp/.env
|
||||||
|
|
||||||
- name: Build docker image
|
- name: Build docker image
|
||||||
run: |
|
run: |
|
||||||
docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach webapp --build --no-deps
|
||||||
docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar
|
docker save "ghcr.io/ocelot-social-community/ocelot-social/webapp:test" > /tmp/webapp.tar
|
||||||
|
|
||||||
- name: Cache docker image
|
- name: Cache docker image
|
||||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
@ -91,7 +98,7 @@ jobs:
|
|||||||
fullstack_tests:
|
fullstack_tests:
|
||||||
name: Fullstack | tests
|
name: Fullstack | tests
|
||||||
if: success()
|
if: success()
|
||||||
needs: [prepare_neo4j_image, prepare_backend_image, prepare_webapp_image, prepare_cypress]
|
needs: [prepare_backend_environment, prepare_webapp_image, prepare_cypress]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
jobs: 8
|
jobs: 8
|
||||||
@ -110,17 +117,16 @@ jobs:
|
|||||||
key: ${{ github.run_id }}-e2e-cypress
|
key: ${{ github.run_id }}-e2e-cypress
|
||||||
restore-keys: ${{ github.run_id }}-e2e-cypress
|
restore-keys: ${{ github.run_id }}-e2e-cypress
|
||||||
|
|
||||||
- name: Restore neo4j cache
|
- name: Restore backend environment cache
|
||||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
with:
|
with:
|
||||||
path: /tmp/neo4j.tar
|
path: |
|
||||||
key: ${{ github.run_id }}-e2e-neo4j-cache
|
/tmp/backend.tar
|
||||||
|
/tmp/neo4j.tar
|
||||||
- name: Restore backend cache
|
/tmp/minio.tar
|
||||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
/tmp/minio-mc.tar
|
||||||
with:
|
/tmp/mailserver.tar
|
||||||
path: /tmp/backend.tar
|
key: ${{ github.run_id }}-e2e-backend-environment-cache
|
||||||
key: ${{ github.run_id }}-e2e-backend-cache
|
|
||||||
|
|
||||||
- name: Restore webapp cache
|
- name: Restore webapp cache
|
||||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.0.2
|
||||||
@ -134,8 +140,11 @@ jobs:
|
|||||||
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/neo4j.tar
|
docker load < /tmp/neo4j.tar
|
||||||
docker load < /tmp/backend.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 load < /tmp/webapp.tar
|
||||||
docker compose -f docker-compose.yml -f docker-compose.test.yml up --build --detach webapp mailserver
|
docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach backend mailserver webapp
|
||||||
sleep 90s
|
sleep 90s
|
||||||
|
|
||||||
- name: Full stack tests | run tests
|
- name: Full stack tests | run tests
|
||||||
|
|||||||
@ -32,10 +32,12 @@ COMMIT=
|
|||||||
PUBLIC_REGISTRATION=false
|
PUBLIC_REGISTRATION=false
|
||||||
INVITE_REGISTRATION=true
|
INVITE_REGISTRATION=true
|
||||||
|
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=minio
|
||||||
AWS_SECRET_ACCESS_KEY=
|
AWS_SECRET_ACCESS_KEY=12341234
|
||||||
AWS_ENDPOINT=
|
AWS_ENDPOINT=http://localhost:9000
|
||||||
AWS_REGION=
|
AWS_REGION=local
|
||||||
AWS_BUCKET=
|
AWS_BUCKET=ocelot
|
||||||
|
S3_PUBLIC_GATEWAY=http://localhost:8000
|
||||||
|
|
||||||
CATEGORIES_ACTIVE=false
|
CATEGORIES_ACTIVE=false
|
||||||
|
MAX_PINNED_POSTS=1
|
||||||
|
|||||||
@ -6,7 +6,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
target: test
|
target: test
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV="test"
|
- NODE_ENV=test
|
||||||
volumes:
|
volumes:
|
||||||
- ./coverage:/app/coverage
|
- ./coverage:/app/coverage
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,23 @@ ONBUILD RUN cp -r ./locales /build
|
|||||||
ONBUILD RUN cp -r ./package.json ./yarn.lock /build
|
ONBUILD RUN cp -r ./package.json ./yarn.lock /build
|
||||||
ONBUILD RUN cd /build && yarn install --production=true --frozen-lockfile --non-interactive
|
ONBUILD RUN cd /build && yarn install --production=true --frozen-lockfile --non-interactive
|
||||||
|
|
||||||
FROM build AS test
|
FROM base AS test_build
|
||||||
|
ENV NODE_ENV=test
|
||||||
|
COPY . .
|
||||||
|
RUN tools/merge-locales.sh
|
||||||
|
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||||
|
RUN yarn run build
|
||||||
|
RUN mkdir /build
|
||||||
|
RUN cp -r ./.nuxt /build
|
||||||
|
RUN cp -r ./nuxt.config.js /build
|
||||||
|
RUN cp -r ./config/ /build
|
||||||
|
RUN cp -r ./constants /build
|
||||||
|
RUN cp -r ./static /build
|
||||||
|
RUN cp -r ./locales /build
|
||||||
|
RUN cp -r ./package.json ./yarn.lock /build
|
||||||
|
RUN cd /build && yarn install --frozen-lockfile --non-interactive
|
||||||
|
|
||||||
|
FROM test_build AS test
|
||||||
CMD ["/bin/bash", "-c", "yarn run dev"]
|
CMD ["/bin/bash", "-c", "yarn run dev"]
|
||||||
|
|
||||||
FROM build AS production_build
|
FROM build AS production_build
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user