Skip to content

Commit 1211817

Browse files
authored
Run integration tests in matrix (#1802)
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
1 parent a756947 commit 1211817

3 files changed

Lines changed: 94 additions & 2 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: Integration Tests - Java Version Compatibility Matrix
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: Java ${{ matrix.java-version }}
22+
runs-on: ubuntu-24.04
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
# Note: Java 8 runtime testing is skipped due to Spotless incompatibility
27+
java-version: [11, 17, 21, 25]
28+
steps:
29+
- name: Check out
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
with:
32+
persist-credentials: false
33+
34+
- name: Set up mise
35+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
36+
with:
37+
version: v2026.1.4
38+
sha256: 79c798e39b83f0dd80108eaa88c6ca63689695ae975fd6786e7a353ef9f87002
39+
40+
- name: Cache local Maven repository
41+
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
42+
with:
43+
path: ~/.m2/repository
44+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
45+
restore-keys: |
46+
${{ runner.os }}-maven-
47+
48+
- name: Build core library artifacts
49+
run: mise exec -- ./mvnw install -DskipTests -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn -pl '!integration-tests'
50+
51+
- name: Install parent POMs
52+
run: |
53+
cd integration-tests
54+
mise exec -- ../mvnw clean install -N -Dspotless.skip=true
55+
cd it-exporter
56+
mise exec -- ../../mvnw install -N -Dspotless.skip=true
57+
58+
- name: Rebuild sample apps targeting Java ${{ matrix.java-version }}
59+
run: |
60+
cd integration-tests
61+
# Note: Jetty 12 and Tomcat 11 require Java 17+, so servlet samples are skipped for Java 11
62+
if [ "${{ matrix.java-version }}" = "11" ]; then
63+
MODULES="it-common,it-exporter/it-exporter-httpserver-sample,it-exporter/it-exporter-no-protobuf,it-pushgateway"
64+
else
65+
MODULES="it-common,it-exporter/it-exporter-httpserver-sample,it-exporter/it-exporter-servlet-tomcat-sample,it-exporter/it-exporter-servlet-jetty-sample,it-exporter/it-exporter-no-protobuf,it-pushgateway"
66+
fi
67+
mise exec -- ../mvnw clean install -DskipTests -Dspotless.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn \
68+
-Djava.version=${{ matrix.java-version }} \
69+
-Dmaven.compiler.release=${{ matrix.java-version }} \
70+
-pl $MODULES
71+
72+
- name: Run integration tests
73+
env:
74+
TEST_JAVA_VERSION: ${{ matrix.java-version }}
75+
run: |
76+
cd integration-tests
77+
# Note: Servlet tests require Java 17+ (due to Jetty 12 and Tomcat 11)
78+
if [ "${{ matrix.java-version }}" = "11" ]; then
79+
TEST_MODULES="it-exporter/it-no-protobuf-test,it-pushgateway"
80+
else
81+
TEST_MODULES="it-exporter/it-exporter-test,it-exporter/it-no-protobuf-test,it-pushgateway"
82+
fi
83+
mise exec -- ../mvnw verify -T 2C -Dspotless.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn \
84+
-pl $TEST_MODULES

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 @@ class PushGatewayIT {
3333
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 @@ 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)