mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 09:13:15 +03:00
285 lines
8.4 KiB
YAML
285 lines
8.4 KiB
YAML
name: E2E Tests
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- "docs/**"
|
|
- "**.md"
|
|
- ".github/**"
|
|
pull_request:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- "docs/**"
|
|
- "**.md"
|
|
- ".github/**"
|
|
|
|
jobs:
|
|
build:
|
|
if: github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
timeout-minutes: 20
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and export
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
push: false
|
|
load: false
|
|
tags: pocket-id:test
|
|
outputs: type=docker,dest=/tmp/docker-image.tar
|
|
build-args: BUILD_TAGS=e2etest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Upload Docker image artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
path: /tmp/docker-image.tar
|
|
retention-days: 1
|
|
|
|
test-sqlite:
|
|
if: github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: lts/*
|
|
cache: "npm"
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Cache Playwright Browsers
|
|
uses: actions/cache@v3
|
|
id: playwright-cache
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-playwright-
|
|
|
|
- name: Download Docker image artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
path: /tmp
|
|
|
|
- name: Load Docker image
|
|
run: docker load -i /tmp/docker-image.tar
|
|
|
|
- name: Cache LLDAP Docker image
|
|
uses: actions/cache@v3
|
|
id: lldap-cache
|
|
with:
|
|
path: /tmp/lldap-image.tar
|
|
key: lldap-stable-${{ runner.os }}
|
|
|
|
- name: Pull and save LLDAP image
|
|
if: steps.lldap-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
docker pull nitnelave/lldap:stable
|
|
docker save nitnelave/lldap:stable > /tmp/lldap-image.tar
|
|
|
|
- name: Load LLDAP image from cache
|
|
if: steps.lldap-cache.outputs.cache-hit == 'true'
|
|
run: docker load < /tmp/lldap-image.tar
|
|
|
|
- name: Install frontend dependencies
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Install Playwright Browsers
|
|
working-directory: ./frontend
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
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
|
|
run: |
|
|
docker run -d --name pocket-id-sqlite \
|
|
--network pocket-id-network \
|
|
-p 80:80 \
|
|
-e APP_ENV=test \
|
|
pocket-id:test
|
|
|
|
docker logs -f pocket-id-sqlite &> /tmp/backend.log &
|
|
|
|
- name: Run Playwright tests
|
|
working-directory: ./frontend
|
|
run: npx playwright test
|
|
|
|
- name: Upload Frontend Test Report
|
|
uses: actions/upload-artifact@v4
|
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
with:
|
|
name: playwright-report-sqlite
|
|
path: frontend/tests/.report
|
|
include-hidden-files: true
|
|
retention-days: 15
|
|
|
|
- name: Upload Backend Test Report
|
|
uses: actions/upload-artifact@v4
|
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
with:
|
|
name: backend-sqlite
|
|
path: /tmp/backend.log
|
|
include-hidden-files: true
|
|
retention-days: 15
|
|
|
|
test-postgres:
|
|
if: github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: lts/*
|
|
cache: "npm"
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Cache Playwright Browsers
|
|
uses: actions/cache@v3
|
|
id: playwright-cache
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: ${{ runner.os }}-playwright-${{ hashFiles('frontend/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-playwright-
|
|
|
|
- name: Cache PostgreSQL Docker image
|
|
uses: actions/cache@v3
|
|
id: postgres-cache
|
|
with:
|
|
path: /tmp/postgres-image.tar
|
|
key: postgres-17-${{ runner.os }}
|
|
|
|
- name: Pull and save PostgreSQL image
|
|
if: steps.postgres-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
docker pull postgres:17
|
|
docker save postgres:17 > /tmp/postgres-image.tar
|
|
|
|
- name: Load PostgreSQL image from cache
|
|
if: steps.postgres-cache.outputs.cache-hit == 'true'
|
|
run: docker load < /tmp/postgres-image.tar
|
|
|
|
- name: Cache LLDAP Docker image
|
|
uses: actions/cache@v3
|
|
id: lldap-cache
|
|
with:
|
|
path: /tmp/lldap-image.tar
|
|
key: lldap-stable-${{ runner.os }}
|
|
|
|
- name: Pull and save LLDAP image
|
|
if: steps.lldap-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
docker pull nitnelave/lldap:stable
|
|
docker save nitnelave/lldap:stable > /tmp/lldap-image.tar
|
|
|
|
- name: Load LLDAP image from cache
|
|
if: steps.lldap-cache.outputs.cache-hit == 'true'
|
|
run: docker load < /tmp/lldap-image.tar
|
|
|
|
- name: Download Docker image artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: docker-image
|
|
path: /tmp
|
|
|
|
- name: Load Docker image
|
|
run: docker load -i /tmp/docker-image.tar
|
|
|
|
- name: Install frontend dependencies
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Install Playwright Browsers
|
|
working-directory: ./frontend
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
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
|
|
run: |
|
|
docker run -d --name pocket-id-postgres \
|
|
--network pocket-id-network \
|
|
-p 80:80 \
|
|
-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
|
|
working-directory: ./frontend
|
|
run: npx playwright test
|
|
|
|
- name: Upload Frontend Test Report
|
|
uses: actions/upload-artifact@v4
|
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
with:
|
|
name: playwright-report-postgres
|
|
path: frontend/tests/.report
|
|
include-hidden-files: true
|
|
retention-days: 15
|
|
|
|
- name: Upload Backend Test Report
|
|
uses: actions/upload-artifact@v4
|
|
if: always() && github.event.pull_request.head.ref != 'i18n_crowdin'
|
|
with:
|
|
name: backend-postgres
|
|
path: /tmp/backend.log
|
|
include-hidden-files: true
|
|
retention-days: 15
|