-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (101 loc) · 3.62 KB
/
docker-e2e-tests.yml
File metadata and controls
122 lines (101 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Docker E2E Tests
#
# This workflow runs e2e tests against the Docker container.
# It is triggered by:
# - push: On push to main branch
# - pull_request: On all pull requests
# - workflow_dispatch: Manual trigger for testing
#
# The workflow builds the Docker image locally using GitHub Actions cache (type=gha)
# which is automatically shared with the "Docker Image Build and Publish" workflow.
# This allows both workflows to run in parallel while still benefiting from
# shared cache, making the second build very fast on cache hits.
name: Docker E2E Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
docker-e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image locally
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: ghcr.io/${{ github.repository }}:local-test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".node-version"
cache: "pnpm"
- name: Run Docker container
run: |
docker run -d -p 8080:8080 --name lit-ssr-demo -e PORT=8080 -e APP_TITLE="Hello World!" ghcr.io/${{ github.repository }}:local-test
# Wait for container to be healthy
sleep 10
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Cache Playwright browsers
uses: actions/cache@v5
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-chromium-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-chromium-
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps chromium
working-directory: ./packages/e2e-tests
- name: Install system dependencies only
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm exec playwright install-deps chromium
working-directory: ./packages/e2e-tests
- name: Build project
run: pnpm run build
- name: Wait for server
run: |
pnpm exec wait-on http://localhost:8080 -t 60000
echo "Server is ready"
- name: Generate BDD test files
run: pnpm run generate
working-directory: ./packages/e2e-tests
- name: Run Playwright tests
run: pnpm run e2e --project=chromium
working-directory: ./packages/e2e-tests
env:
PORT: 8080
CI: true
SKIP_WEB_SERVER: true
- name: Upload Playwright Report
if: ${{ always() && env.ACTIONS_RUNTIME_TOKEN != '' }}
uses: actions/upload-artifact@v6
with:
name: playwright-docker-report
path: packages/e2e-tests/playwright-report/
retention-days: 30
- name: Upload test results
if: ${{ always() && env.ACTIONS_RUNTIME_TOKEN != '' }}
uses: actions/upload-artifact@v6
with:
name: playwright-docker-test-results
path: packages/e2e-tests/test-results/
retention-days: 30
- name: Docker logs on failure
if: failure()
run: docker logs lit-ssr-demo
- name: Cleanup
if: always()
run: docker rm -f lit-ssr-demo