feat: consolidate E2E testing workflow into Docker build process and remove legacy workflow

This commit is contained in:
Dominik Schröter 2025-02-02 22:53:27 +01:00
parent 568c45b0bb
commit 6e836142ed
3 changed files with 53 additions and 84 deletions

View file

@ -16,29 +16,22 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: 1.22 go-version: 1.22
- name: Install mupdf - name: Install mupdf
run: sudo apt-get install -y mupdf run: sudo apt-get install -y mupdf
- name: Set library path - name: Set library path
run: echo "/usr/lib" | sudo tee -a /etc/ld.so.conf.d/mupdf.conf && sudo ldconfig run: echo "/usr/lib" | sudo tee -a /etc/ld.so.conf.d/mupdf.conf && sudo ldconfig
- name: Install dependencies - name: Install dependencies
run: go mod download run: go mod download
- name: Run Go tests - name: Run Go tests
run: go test ./... run: go test ./...
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 20
- name: Cache npm dependencies - name: Cache npm dependencies
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -46,11 +39,9 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: | restore-keys: |
${{ runner.os }}-node- ${{ runner.os }}-node-
- name: Install frontend dependencies - name: Install frontend dependencies
run: npm install run: npm install
working-directory: web-app working-directory: web-app
- name: Run frontend tests - name: Run frontend tests
run: npm test run: npm test
working-directory: web-app working-directory: web-app
@ -60,13 +51,13 @@ jobs:
needs: test needs: test
outputs: outputs:
digest: ${{ steps.build_amd64.outputs.digest }} digest: ${{ steps.build_amd64.outputs.digest }}
image_tag: ${{ steps.set_image_tag.outputs.image_tag }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub - name: Log in to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
@ -74,7 +65,9 @@ jobs:
- name: Set Docker tags - name: Set Docker tags
id: set_tags id: set_tags
run: | run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
echo "TAGS=icereed/paperless-gpt:pr-${GITHUB_SHA}-amd64" >> $GITHUB_ENV
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
VERSION=${GITHUB_REF#refs/tags/} VERSION=${GITHUB_REF#refs/tags/}
echo "TAGS=icereed/paperless-gpt:${VERSION}-amd64" >> $GITHUB_ENV echo "TAGS=icereed/paperless-gpt:${VERSION}-amd64" >> $GITHUB_ENV
else else
@ -86,7 +79,7 @@ jobs:
with: with:
context: . context: .
platforms: linux/amd64 platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }} push: true
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
tags: ${{ env.TAGS }} tags: ${{ env.TAGS }}
@ -94,6 +87,9 @@ jobs:
VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }} VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
COMMIT=${{ github.sha }} COMMIT=${{ github.sha }}
BUILD_DATE=${{ github.event.repository.pushed_at }} BUILD_DATE=${{ github.event.repository.pushed_at }}
- name: Set image tag output
id: set_image_tag
run: echo "image_tag=${TAGS}" >> $GITHUB_OUTPUT
- name: Export digest for amd64 - name: Export digest for amd64
run: | run: |
mkdir -p ${{ runner.temp }}/digests mkdir -p ${{ runner.temp }}/digests
@ -203,4 +199,45 @@ jobs:
docker buildx imagetools inspect ${DOCKERHUB_REPO}:${VERSION} docker buildx imagetools inspect ${DOCKERHUB_REPO}:${VERSION}
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
docker buildx imagetools inspect ${DOCKERHUB_REPO}:latest docker buildx imagetools inspect ${DOCKERHUB_REPO}:latest
fi fi
e2e-tests:
name: E2E Tests
needs: build-amd64
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./web-app
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './web-app/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install chromium --with-deps
- name: Run Playwright tests
run: npm run test:e2e
env:
CI: true
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PAPERLESS_GPT_IMAGE: ${{ needs.build-amd64.outputs.image_tag }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: web-app/playwright-report/
retention-days: 30
- name: Upload test screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: web-app/test-results/
retention-days: 30

View file

@ -1,70 +0,0 @@
name: E2E Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: E2E Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./web-app
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './web-app/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install chromium --with-deps
- name: Build app
run: npm run build
- name: Create test env file
run: |
echo "PAPERLESS_GPT_URL=http://localhost:8080" > .env.test
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env.test
- name: Start test containers
run: npm run docker:test:up
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Run Playwright tests
run: npm run test:e2e
env:
CI: true
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: web-app/playwright-report/
retention-days: 30
- name: Upload test screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: web-app/test-results/
retention-days: 30
- name: Stop test containers
if: always()
run: npm run docker:test:down

View file

@ -76,7 +76,9 @@ export async function setupTestEnvironment(): Promise<TestEnvironment> {
} }
console.log('Starting Paperless-gpt container...'); console.log('Starting Paperless-gpt container...');
const paperlessGpt = await new GenericContainer('icereed/paperless-gpt:e2e') const paperlessGptImage = process.env.PAPERLESS_GPT_IMAGE || 'icereed/paperless-gpt:e2e';
console.log(`Using image: ${paperlessGptImage}`);
const paperlessGpt = await new GenericContainer(paperlessGptImage)
.withNetwork(network) .withNetwork(network)
.withEnvironment({ .withEnvironment({
PAPERLESS_BASE_URL: `http://paperless-ngx:${paperlessPort}`, PAPERLESS_BASE_URL: `http://paperless-ngx:${paperlessPort}`,