Skip to content

Commit 79e1279

Browse files
committed
ci(tests): add parallel workflow for unit and e2e tests
1 parent 7f6583b commit 79e1279

File tree

4 files changed

+94
-49
lines changed

4 files changed

+94
-49
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/tests.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 🧪 Tests
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
concurrency:
15+
group: tests-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
unit:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
24+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
cache: 'maven'
29+
cache-dependency-path: 'pom.xml'
30+
31+
- name: Run unit tests
32+
run: mvn -B test
33+
34+
e2e:
35+
runs-on: ubuntu-latest
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
keycloak_version:
40+
- '26.2.5'
41+
- '26.3.5'
42+
- '26.4.7'
43+
- '26.5.2'
44+
steps:
45+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46+
47+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
48+
with:
49+
java-version: '21'
50+
distribution: 'temurin'
51+
cache: 'maven'
52+
cache-dependency-path: 'pom.xml'
53+
54+
- name: Build JAR for Keycloak ${{ matrix.keycloak_version }}
55+
run: mvn -B clean package -P keycloak-${{ matrix.keycloak_version }}
56+
57+
- name: Run E2E tests
58+
run: |
59+
cd tests/e2e
60+
KC_VERSION=${{ matrix.keycloak_version }} docker compose --profile test up --build --abort-on-container-exit --exit-code-from test-runner
61+
62+
- name: Stop containers
63+
if: always()
64+
run: |
65+
cd tests/e2e
66+
docker compose --profile test down
67+
68+
- name: Upload test results
69+
if: failure()
70+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
71+
with:
72+
name: playwright-report-kc-${{ matrix.keycloak_version }}
73+
path: tests/e2e/playwright-report/
74+
retention-days: 7

justfile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ build-docker:
1616
build: build-docker
1717
docker run --rm --volume="${PWD}:/opt/maven" keycloak-spi-plugin mvn -B clean package
1818

19+
# Run unit tests
20+
[no-exit-message]
21+
test: build-docker
22+
docker run --rm --volume="${PWD}:/opt/maven" keycloak-spi-plugin mvn -B test -DskipTests=false
23+
1924
# Build for a specific Keycloak version
2025
build-version VERSION: build-docker
2126
docker run --rm --volume="${PWD}:/opt/maven" keycloak-spi-plugin mvn -B clean package -P keycloak-{{VERSION}}
@@ -44,12 +49,19 @@ versions:
4449
@echo "- 26.3.5"
4550
@echo "- 26.2.5"
4651

47-
# Run E2E tests (builds JAR first, runs everything in Docker)
48-
test-e2e KC_VERSION="26.5.2": (build-version KC_VERSION)
49-
cd tests/e2e && KC_VERSION={{KC_VERSION}} docker compose --profile test up --build --abort-on-container-exit --exit-code-from test-runner
50-
cd tests/e2e && KC_VERSION={{KC_VERSION}} docker compose --profile test down
52+
# Run E2E tests (optionally specify a file pattern, requires test-e2e-setup if FILE is provided)
53+
test-e2e KC_VERSION="26.5.2" FILE="": (build-version KC_VERSION)
54+
#!/usr/bin/env bash
55+
cd tests/e2e
56+
if [ -z "{{FILE}}" ]; then
57+
KC_VERSION={{KC_VERSION}} docker compose --profile test up --build --abort-on-container-exit --exit-code-from test-runner; rc=$?
58+
KC_VERSION={{KC_VERSION}} docker compose --profile test down
59+
exit $rc
60+
else
61+
docker compose run --rm test-runner npx playwright test {{FILE}}
62+
fi
5163

52-
# Start test infrastructure only (for debugging)
64+
# Start test infrastructure only (for debugging or running specific tests)
5365
test-e2e-setup KC_VERSION="26.5.2": (build-version KC_VERSION)
5466
cd tests/e2e && KC_VERSION={{KC_VERSION}} docker compose up -d --wait
5567

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3333
<buildVersion>dev</buildVersion>
3434

35+
<!-- Skip tests by default, run explicitly with: mvn test -->
36+
<skipTests>true</skipTests>
37+
3538
<!-- Default Keycloak version -->
3639
<keycloak.version>26.5.2</keycloak.version>
3740

0 commit comments

Comments
 (0)