mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-15 21:00:06 +00:00
ci/cd: start test containers with Docker Compose
This commit is contained in:
81
.github/workflows/e2e-tests.yml
vendored
81
.github/workflows/e2e-tests.yml
vendored
@@ -95,43 +95,31 @@ jobs:
|
|||||||
if: steps.lldap-cache.outputs.cache-hit == 'true'
|
if: steps.lldap-cache.outputs.cache-hit == 'true'
|
||||||
run: docker load < /tmp/lldap-image.tar
|
run: docker load < /tmp/lldap-image.tar
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
- name: Install test dependencies
|
||||||
working-directory: ./frontend
|
working-directory: ./tests
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
working-directory: ./frontend
|
working-directory: ./tests
|
||||||
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
run: npx playwright install --with-deps chromium
|
run: npx playwright install --with-deps chromium
|
||||||
|
|
||||||
- name: Create Docker network
|
|
||||||
run: docker network create pocket-id-network
|
|
||||||
|
|
||||||
- name: Setup and Configure LLDAP Server
|
|
||||||
run: |
|
|
||||||
chmod +x ./scripts/tests/setup-lldap.sh
|
|
||||||
./scripts/tests/setup-lldap.sh
|
|
||||||
|
|
||||||
- name: Run Docker Container with Sqlite DB and LDAP
|
- name: Run Docker Container with Sqlite DB and LDAP
|
||||||
|
working-directory: ./tests/setup
|
||||||
run: |
|
run: |
|
||||||
docker run -d --name pocket-id-sqlite \
|
docker compose up -d
|
||||||
--network pocket-id-network \
|
docker compose logs -f pocket-id &> /tmp/backend.log &
|
||||||
-p 1411:1411 \
|
|
||||||
-e APP_ENV=test \
|
|
||||||
pocket-id:test
|
|
||||||
|
|
||||||
docker logs -f pocket-id-sqlite &> /tmp/backend.log &
|
|
||||||
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
working-directory: ./frontend
|
working-directory: ./tests
|
||||||
run: npx playwright test
|
run: npx playwright test
|
||||||
|
|
||||||
- name: Upload Frontend Test Report
|
- name: Upload Test Report
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
with:
|
with:
|
||||||
name: playwright-report-sqlite
|
name: playwright-report-sqlite
|
||||||
path: frontend/tests/.report
|
path: tests/.report
|
||||||
include-hidden-files: true
|
include-hidden-files: true
|
||||||
retention-days: 15
|
retention-days: 15
|
||||||
|
|
||||||
@@ -211,61 +199,26 @@ jobs:
|
|||||||
- name: Load Docker image
|
- name: Load Docker image
|
||||||
run: docker load -i /tmp/docker-image.tar
|
run: docker load -i /tmp/docker-image.tar
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
- name: Install test dependencies
|
||||||
working-directory: ./frontend
|
working-directory: ./tests
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
working-directory: ./frontend
|
working-directory: ./tests
|
||||||
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
run: npx playwright install --with-deps chromium
|
run: npx playwright install --with-deps chromium
|
||||||
|
|
||||||
- name: Create Docker network
|
|
||||||
run: docker network create pocket-id-network
|
|
||||||
|
|
||||||
- name: Start Postgres DB
|
|
||||||
run: |
|
|
||||||
docker run -d --name pocket-id-db \
|
|
||||||
--network pocket-id-network \
|
|
||||||
-e POSTGRES_USER=postgres \
|
|
||||||
-e POSTGRES_PASSWORD=postgres \
|
|
||||||
-e POSTGRES_DB=pocket-id \
|
|
||||||
-p 5432:5432 \
|
|
||||||
postgres:17
|
|
||||||
|
|
||||||
- name: Setup and Configure LLDAP Server
|
|
||||||
run: |
|
|
||||||
chmod +x ./scripts/tests/setup-lldap.sh
|
|
||||||
./scripts/tests/setup-lldap.sh
|
|
||||||
|
|
||||||
- name: Wait for Postgres to start
|
|
||||||
run: |
|
|
||||||
for i in {1..5}; do
|
|
||||||
if docker exec pocket-id-db pg_isready -U postgres; then
|
|
||||||
echo "Postgres is ready"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "Waiting for Postgres..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Run Docker Container with Postgres DB and LDAP
|
- name: Run Docker Container with Postgres DB and LDAP
|
||||||
|
working-directory: ./tests/setup
|
||||||
run: |
|
run: |
|
||||||
docker run -d --name pocket-id-postgres \
|
docker compose -f docker-compose-postgres.yml up -d
|
||||||
--network pocket-id-network \
|
docker compose -f docker-compose-postgres.yml logs -f pocket-id &> /tmp/backend.log &
|
||||||
-p 1411:1411 \
|
|
||||||
-e APP_ENV=test \
|
|
||||||
-e DB_PROVIDER=postgres \
|
|
||||||
-e DB_CONNECTION_STRING=postgresql://postgres:postgres@pocket-id-db:5432/pocket-id \
|
|
||||||
pocket-id:test
|
|
||||||
|
|
||||||
docker logs -f pocket-id-postgres &> /tmp/backend.log &
|
|
||||||
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
working-directory: ./frontend
|
working-directory: ./tests
|
||||||
run: npx playwright test
|
run: npx playwright test
|
||||||
|
|
||||||
- name: Upload Frontend Test Report
|
- name: Upload Test Report
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
||||||
with:
|
with:
|
||||||
|
|||||||
13
tests/setup/Dockerfile
Normal file
13
tests/setup/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Modified version of lldap/lldap that seeds lldap with test data
|
||||||
|
FROM lldap/lldap:2025-05-19
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN curl -o /bin/lldap-cli https://raw.githubusercontent.com/Zepmann/lldap-cli/e383494b4dd89ae4e028958b268e200fd85a7a64/lldap-cli
|
||||||
|
|
||||||
|
COPY seed-lldap.sh .
|
||||||
|
RUN chmod +x ./seed-lldap.sh /bin/lldap-cli
|
||||||
|
RUN cp lldap_set_password /bin
|
||||||
|
|
||||||
|
ENTRYPOINT /docker-entrypoint.sh run --config-file /data/lldap_config.toml & ./seed-lldap.sh && wait
|
||||||
|
|
||||||
24
tests/setup/docker-compose-postgres.yml
Normal file
24
tests/setup/docker-compose-postgres.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# This Docker Compose file is used to set up the environment for the tests.
|
||||||
|
services:
|
||||||
|
lldap:
|
||||||
|
extends:
|
||||||
|
file: docker-compose.yml
|
||||||
|
service: lldap
|
||||||
|
postgres:
|
||||||
|
image: postgres:17
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
- POSTGRES_DB=pocket-id
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
pocket-id:
|
||||||
|
extends:
|
||||||
|
file: docker-compose.yml
|
||||||
|
service: pocket-id
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
21
tests/setup/docker-compose.yml
Normal file
21
tests/setup/docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# This Docker Compose file is used to set up the environment for the tests.
|
||||||
|
services:
|
||||||
|
lldap:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
environment:
|
||||||
|
- LLDAP_JWT_SECRET=secret
|
||||||
|
- LLDAP_LDAP_USER_PASS=admin_password
|
||||||
|
- LLDAP_LDAP_BASE_DN=dc=pocket-id,dc=org
|
||||||
|
pocket-id:
|
||||||
|
image: pocket-id:test
|
||||||
|
ports:
|
||||||
|
- "1411:1411"
|
||||||
|
environment:
|
||||||
|
- APP_ENV=test
|
||||||
|
build:
|
||||||
|
args:
|
||||||
|
- BUILD_TAGS=e2etest
|
||||||
|
context: ../..
|
||||||
|
dockerfile: Dockerfile
|
||||||
@@ -1,26 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo 'deb http://download.opensuse.org/repositories/home:/Masgalor:/LLDAP/xUbuntu_24.04/ /' | sudo tee /etc/apt/sources.list.d/home:Masgalor:LLDAP.list
|
|
||||||
curl -fsSL https://download.opensuse.org/repositories/home:Masgalor:LLDAP/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_Masgalor_LLDAP.gpg > /dev/null
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y lldap-cli lldap-set-password
|
|
||||||
|
|
||||||
echo "Setting up LLDAP container..."
|
|
||||||
|
|
||||||
# Run LLDAP container
|
|
||||||
docker run -d --name lldap \
|
|
||||||
--network pocket-id-network \
|
|
||||||
-p 3890:3890 \
|
|
||||||
-p 17170:17170 \
|
|
||||||
-e LLDAP_JWT_SECRET=secret \
|
|
||||||
-e LLDAP_LDAP_USER_PASS=admin_password \
|
|
||||||
-e LLDAP_LDAP_BASE_DN="dc=pocket-id,dc=org" \
|
|
||||||
nitnelave/lldap:stable
|
|
||||||
|
|
||||||
# Wait for LLDAP to start
|
# Wait for LLDAP to start
|
||||||
for i in {1..15}; do
|
for i in {1..15}; do
|
||||||
if curl -s --fail http://localhost:17170/api/healthcheck > /dev/null; then
|
if curl -s --fail http://localhost:17170/api/healthcheck >/dev/null; then
|
||||||
echo "LLDAP is ready"
|
echo "LLDAP is ready"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user