Skip to content

Commit 4d5c613

Browse files
committed
Run integration tests in matrix
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
1 parent ba53778 commit 4d5c613

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
name: Java Version Matrix Tests
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- 'integration-tests/**'
8+
- 'prometheus-metrics-core/**'
9+
- 'prometheus-metrics-exporter-*/**'
10+
- 'prometheus-metrics-exposition-*/**'
11+
- '.github/workflows/java-version-matrix-tests.yml'
12+
push:
13+
branches:
14+
- main
15+
workflow_dispatch:
16+
17+
permissions: {}
18+
19+
jobs:
20+
integration-tests:
21+
name: Integration Tests (Java ${{ matrix.java-version }})
22+
runs-on: ubuntu-24.04
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
java-version: [8, 11, 17, 21, 25]
27+
test-module:
28+
- it-exporter
29+
- it-pushgateway
30+
steps:
31+
- name: Check out
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
35+
36+
- name: Set up mise
37+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
38+
with:
39+
version: v2026.1.4
40+
sha256: 79c798e39b83f0dd80108eaa88c6ca63689695ae975fd6786e7a353ef9f87002
41+
42+
- name: Cache local Maven repository
43+
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
44+
with:
45+
path: ~/.m2/repository
46+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
47+
restore-keys: |
48+
${{ runner.os }}-maven-
49+
50+
- name: Build project artifacts
51+
run: mise exec -- ./mvnw install -DskipTests -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn
52+
53+
- name: Run integration tests for ${{ matrix.test-module }}
54+
env:
55+
TEST_JAVA_VERSION: ${{ matrix.java-version }}
56+
run: |
57+
cd integration-tests/${{ matrix.test-module }}
58+
mise exec -- ../../mvnw verify -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn
59+
60+
summary:
61+
name: Matrix Test Summary
62+
runs-on: ubuntu-24.04
63+
needs: integration-tests
64+
if: always()
65+
steps:
66+
- name: Check matrix results
67+
run: |
68+
if [ "${{ needs.integration-tests.result }}" == "failure" ]; then
69+
echo "::error::One or more Java version matrix tests failed"
70+
exit 1
71+
fi

integration-tests/it-common/src/test/java/io/prometheus/client/it/common/ExporterTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ public ExporterTest(String sampleApp) throws IOException, URISyntaxException {
3333
this.sampleAppVolume =
3434
Volume.create("it-exporter")
3535
.copy("../../it-" + sampleApp + "/target/" + sampleApp + ".jar");
36+
String javaVersion = System.getenv("TEST_JAVA_VERSION");
37+
if (javaVersion == null || javaVersion.isEmpty()) {
38+
javaVersion = "25";
39+
}
3640
this.sampleAppContainer =
37-
new GenericContainer<>("eclipse-temurin:25")
41+
new GenericContainer<>("eclipse-temurin:" + javaVersion)
3842
.withFileSystemBind(sampleAppVolume.getHostPath(), "/app", BindMode.READ_ONLY)
3943
.withWorkingDirectory("/app")
4044
.withLogConsumer(LogConsumer.withPrefix(sampleApp))

integration-tests/it-pushgateway/src/test/java/io/prometheus/metrics/it/pushgateway/PushGatewayIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public class PushGatewayIT {
3333
public void setUp() throws IOException, URISyntaxException {
3434
Network network = Network.newNetwork();
3535
sampleAppVolume = Volume.create("it-pushgateway").copy("pushgateway-test-app.jar");
36+
String javaVersion = System.getenv("TEST_JAVA_VERSION");
37+
if (javaVersion == null || javaVersion.isEmpty()) {
38+
javaVersion = "25";
39+
}
3640
pushGatewayContainer =
3741
new GenericContainer<>("prom/pushgateway:v1.8.0")
3842
.withExposedPorts(9091)
@@ -41,7 +45,7 @@ public void setUp() throws IOException, URISyntaxException {
4145
.withLogConsumer(LogConsumer.withPrefix("pushgateway"))
4246
.waitingFor(Wait.forListeningPort());
4347
sampleAppContainer =
44-
new GenericContainer<>("eclipse-temurin:25")
48+
new GenericContainer<>("eclipse-temurin:" + javaVersion)
4549
.withFileSystemBind(sampleAppVolume.getHostPath(), "/app", BindMode.READ_ONLY)
4650
.withNetwork(network)
4751
.withWorkingDirectory("/app")

0 commit comments

Comments
 (0)