Skip to content

Commit 8d22a49

Browse files
committed
Add Docker for local visual regression testing and fix Node.js version at 24 LTS
1 parent f69f94c commit 8d22a49

File tree

8 files changed

+97
-12
lines changed

8 files changed

+97
-12
lines changed

.github/workflows/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Set up Node
3838
uses: actions/setup-node@v6
3939
with:
40-
node-version: lts/*
40+
node-version: 24 # LTS
4141
cache: 'npm'
4242
cache-dependency-path: spock-website/package-lock.json
4343

.github/workflows/update-reference-screenshots.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ permissions:
99
jobs:
1010
update-screenshots:
1111
runs-on: ubuntu-latest
12+
container:
13+
image: mcr.microsoft.com/playwright:v1.57.0-noble
14+
options: --user 1001
1215
defaults:
1316
run:
1417
working-directory: ./spock-website
@@ -21,16 +24,13 @@ jobs:
2124
- name: Set up Node
2225
uses: actions/setup-node@v6
2326
with:
24-
node-version: lts/*
27+
node-version: 24 # LTS
2528
cache: 'npm'
2629
cache-dependency-path: spock-website/package-lock.json
2730

2831
- name: Install dependencies
2932
run: npm ci
3033

31-
- name: Install Playwright Browsers
32-
run: npx playwright install
33-
3434
- name: Run Playwright Tests updating snapshots
3535
run: npx playwright test --update-snapshots
3636

.github/workflows/verify.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up Node
2727
uses: actions/setup-node@v6
2828
with:
29-
node-version: lts/*
29+
node-version: 24 # LTS
3030
cache: 'npm'
3131
cache-dependency-path: spock-website/package-lock.json
3232

@@ -44,6 +44,9 @@ jobs:
4444

4545
verify:
4646
runs-on: ubuntu-latest
47+
container:
48+
image: mcr.microsoft.com/playwright:v1.57.0-noble
49+
options: --user 1001
4750
defaults:
4851
run:
4952
working-directory: ./spock-website
@@ -63,9 +66,6 @@ jobs:
6366
- name: Install dependencies
6467
run: npm ci
6568

66-
- name: Install Playwright Browsers
67-
run: npx playwright install
68-
6969
- name: Run Playwright Tests
7070
run: npx playwright test
7171

spock-website/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist/
2+
node_modules/
3+
playwright-report/
4+
test-results
5+
tests/

spock-website/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM mcr.microsoft.com/playwright:v1.57.0-noble
2+
3+
WORKDIR /app
4+
5+
# Install latest Node.js 24 LTS and update npm
6+
RUN npm install -g n \
7+
&& n 24 \
8+
&& npm install -g npm \
9+
&& node --version \
10+
&& npm --version
11+
12+
# Copy package files and install dependencies
13+
COPY package.json package-lock.json* ./
14+
RUN npm ci
15+
16+
# Copy the rest of the project files
17+
COPY . .

spock-website/Readme.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Spock Website
2+
3+
This folder contains the source code for the [Spock Framework](https://spockframework.org) website. It is built using [Vite](https://vitejs.dev/) and uses [Playwright](https://playwright.dev/) for visual regression testing.
4+
5+
## Features
6+
7+
- Modern frontend development with Vite and Tailwind CSS
8+
- Automated visual regression tests using Playwright
9+
- Easy snapshot updates via Docker
10+
11+
## Development
12+
13+
To start the development server:
14+
15+
```sh
16+
npm ci
17+
npm run dev
18+
```
19+
20+
## Visual Regression Testing
21+
22+
Visual regression tests are located in the `tests/` directory and use Playwright to compare screenshots.
23+
24+
The reference screenshots are taken on linux, so local testing requires the use of Docker.
25+
26+
To run the tests locally:
27+
28+
```sh
29+
./visual-regression-test.sh
30+
```
31+
This requires Docker to be installed and running on your machine.
32+
It will build a local docker image and run the tests inside a container.
33+
34+
To update visual snapshots:
35+
36+
```sh
37+
./visual-regression-test.sh --update-snapshots
38+
```

spock-website/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
"dev": "vite",
88
"build": "tsc && vite build",
99
"preview": "vite preview",
10-
"test": "playwright test",
11-
"update-snapshots": "playwright test --update-snapshots",
1210
"check-links": "linkinator"
1311
},
1412
"devDependencies": {
15-
"@playwright/test": "^1.57.0",
13+
"@playwright/test": "1.57.0",
1614
"@types/aos": "^3.0.7",
1715
"linkinator": "^7.5.1",
1816
"typescript": "~5.9.3",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
IMAGE_NAME="my-playwright-tester:latest"
3+
4+
# Optional flag for updating screenshots
5+
UPDATE_FLAG=""
6+
if [[ "$1" == "--update-screenshots" ]]; then
7+
UPDATE_FLAG="--update-snapshots"
8+
fi
9+
10+
# Ensure required result/report directories exist
11+
mkdir -p "$(pwd)/test-results"
12+
mkdir -p "$(pwd)/playwright-report"
13+
14+
# 1. Build the image
15+
docker build -t $IMAGE_NAME .
16+
17+
# Check if the build was successful
18+
if [ $? -eq 0 ]; then
19+
# 2. Run the container using the tagged image and mount the tests, test-results, and playwright-report directories
20+
docker run --rm --ipc=host --init \
21+
-v "$(pwd)/tests":/app/tests \
22+
-v "$(pwd)/test-results":/app/test-results \
23+
-v "$(pwd)/playwright-report":/app/playwright-report \
24+
$IMAGE_NAME npx playwright test $UPDATE_FLAG
25+
else
26+
echo "Docker build failed. Container not run."
27+
fi

0 commit comments

Comments
 (0)