mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-17 21:37:06 -04:00
109 lines
3.8 KiB
YAML
109 lines
3.8 KiB
YAML
name: E2E Tests
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
|
|
jobs:
|
|
playwright:
|
|
name: Playwright
|
|
timeout-minutes: 20
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
|
|
- name: Install dependencies
|
|
uses: "./.github/actions/install-dependencies"
|
|
|
|
- name: Get Playwright version
|
|
id: playwright-version
|
|
shell: bash
|
|
run: |
|
|
playwright_version=$(bun -e "console.log((await Bun.file('./package.json').json()).devDependencies['@playwright/test'])")
|
|
echo "version=$playwright_version" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache Playwright Browsers
|
|
id: playwright-cache
|
|
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
|
|
restore-keys: |
|
|
${{ runner.os }}-playwright-
|
|
|
|
- name: Install Playwright Browsers
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
run: bunx playwright install --with-deps
|
|
|
|
- name: Install Playwright System Dependencies
|
|
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
|
run: bunx playwright install-deps
|
|
|
|
- name: Prepare environment
|
|
run: |
|
|
mkdir -p data
|
|
mkdir -p playwright/temp
|
|
mkdir -p playwright/data
|
|
mkdir -p playwright/tinyauth/app-data
|
|
mkdir -p playwright/tinyauth/caddy-data
|
|
chmod -R 777 playwright/temp
|
|
touch .env.local
|
|
echo "SERVER_IP=localhost" >> .env.local
|
|
echo "ZEROBYTE_DATABASE_URL=./data/zerobyte.db" >> .env.local
|
|
echo "BASE_URL=http://localhost:4096" >> .env.local
|
|
echo "E2E_TINYAUTH_ORIGIN=https://tinyauth.example.com:5557" >> .env.local
|
|
echo "TZ=Europe/Zurich" >> .env.local
|
|
|
|
- name: Start zerobyte-e2e service
|
|
run: bun run start:e2e -- -d
|
|
|
|
- name: Check CLI version
|
|
run: |
|
|
expected_version=$(docker exec zerobyte printenv APP_VERSION)
|
|
cli_version=$(docker exec zerobyte bun run --silent cli --version)
|
|
echo "$cli_version"
|
|
test "$cli_version" = "$expected_version"
|
|
|
|
- name: Wait for zerobyte to be ready
|
|
run: |
|
|
timeout 30s bash -c 'until curl -f http://localhost:4096/api/healthcheck; do echo "Waiting for server..." && sleep 2; done'
|
|
|
|
- name: Wait for Tinyauth to be ready
|
|
run: |
|
|
timeout 30s bash -c 'until curl -skf https://localhost:5557/.well-known/openid-configuration; do echo "Waiting for Tinyauth..." && sleep 2; done'
|
|
|
|
- name: Print docker logs if failed to start
|
|
if: failure()
|
|
run: docker compose logs zerobyte-e2e tinyauth tinyauth-app || true
|
|
|
|
- name: Make playwright directory writable
|
|
run: sudo chmod 777 playwright/data/zerobyte.db
|
|
|
|
- name: Run Playwright tests
|
|
run: bun run test:e2e
|
|
|
|
- name: Dump container logs in playwright-report folder
|
|
if: always()
|
|
run: |
|
|
tree playwright || true
|
|
docker compose logs zerobyte-e2e > playwright-report/container-logs.txt || true
|
|
docker compose logs tinyauth tinyauth-app > playwright-report/tinyauth-logs.txt || true
|
|
|
|
- name: Debug - print content of /test-data in container
|
|
if: failure()
|
|
run: |
|
|
docker exec zerobyte /bin/ash -c "ls -la /test-data" || true
|
|
|
|
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: playwright-report/
|
|
retention-days: 5
|
|
|
|
- name: Stop Docker Compose
|
|
if: always()
|
|
run: docker compose down
|