Skip to content

Commit 21e89a0

Browse files
committed
Handle env variables in pom.xml for Surefire Plugin
1 parent b38963e commit 21e89a0

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/run-java-spring-boot-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ jobs:
3232
run: chmod +x mvnw
3333

3434
- name: Run unit tests
35-
run: ./mvnw test -DMONGODB_URI="${MONGODB_URI}"
35+
run: ./mvnw test
3636
env:
3737
MONGODB_URI: ${{ secrets.MFLIX_URI }}
3838

3939
- name: Run integration tests
40-
run: ./mvnw test -Dtest=MongoDBSearchIntegrationTest -DMONGODB_URI="${MONGODB_URI}" -DENABLE_SEARCH_TESTS=true
40+
run: ./mvnw test -Dtest=MongoDBSearchIntegrationTest
4141
env:
4242
MONGODB_URI: ${{ secrets.MFLIX_URI }}
43+
ENABLE_SEARCH_TESTS: true
4344
continue-on-error: true
4445

4546
- name: Upload test results

server/java-spring/pom.xml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
55
https://maven.apache.org/xsd/maven-4.0.0.xsd">
66
<modelVersion>4.0.0</modelVersion>
7-
7+
88
<parent>
99
<groupId>org.springframework.boot</groupId>
1010
<artifactId>spring-boot-starter-parent</artifactId>
1111
<version>3.5.7</version>
1212
<relativePath/>
1313
</parent>
14-
14+
1515
<groupId>com.mongodb</groupId>
1616
<artifactId>sample-app-java-mflix</artifactId>
1717
<version>1.0.0</version>
1818
<name>sample-app-java-mflix</name>
1919
<description>Java Spring Boot backend for MongoDB sample_mflix application demonstrating CRUD operations using Spring Data MongoDB</description>
20-
20+
2121
<properties>
2222
<java.version>21</java.version>
2323
<springdoc.version>2.8.13</springdoc.version>
@@ -80,7 +80,7 @@
8080
</exclusion>
8181
</exclusions>
8282
</dependency>
83-
83+
8484
<!-- Spring Boot Test Starter -->
8585
<dependency>
8686
<groupId>org.springframework.boot</groupId>
@@ -101,7 +101,7 @@
101101
<version>${langchain4j.version}</version>
102102
</dependency>
103103
</dependencies>
104-
104+
105105
<build>
106106
<plugins>
107107
<!-- Spring Boot Maven Plugin -->
@@ -138,6 +138,11 @@
138138
-javaagent:${settings.localRepository}/net/bytebuddy/byte-buddy-agent/${byte-buddy.version}/byte-buddy-agent-${byte-buddy.version}.jar
139139
-Xshare:off
140140
</argLine>
141+
<!-- Pass environment variables to test JVM -->
142+
<environmentVariables>
143+
<MONGODB_URI>${env.MONGODB_URI}</MONGODB_URI>
144+
<ENABLE_SEARCH_TESTS>${env.ENABLE_SEARCH_TESTS}</ENABLE_SEARCH_TESTS>
145+
</environmentVariables>
141146
</configuration>
142147
</plugin>
143148

0 commit comments

Comments
 (0)