Skip to content

Commit d648624

Browse files
Merge branch 'main' into wiremock-3-by-default
2 parents 94ed862 + 0186947 commit d648624

File tree

5 files changed

+232
-53
lines changed

5 files changed

+232
-53
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release to GitHub Packages
1+
name: Release
22

33
on:
44
workflow_dispatch:
@@ -21,6 +21,19 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24+
- name: Configure Git user
25+
run: |
26+
git config user.email "actions@github.com"
27+
git config user.name "GitHub Actions"
28+
29+
- id: install-secret-key
30+
name: Install gpg secret key
31+
run: |
32+
# Install gpg secret key
33+
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
34+
# Verify gpg secret key
35+
gpg --list-secret-keys --keyid-format LONG
36+
2437
- name: Setup Java
2538
uses: actions/setup-java@v3
2639
with:
@@ -29,20 +42,29 @@ jobs:
2942
distribution: 'temurin'
3043
cache: maven
3144

32-
- name: Configure Git user
33-
run: |
34-
git config user.email "actions@github.com"
35-
git config user.name "GitHub Actions"
36-
3745
- name: Set Release Version
3846
id: vars
3947
shell: bash
4048
run: |
4149
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
42-
mvn -ntp -B versions:set -DnewVersion=${{ github.event.inputs.version }}-SNAPSHOT
50+
mvn -ntp --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }}
4351
git diff-index --quiet HEAD || git commit -m "Releasing version ${{ github.event.inputs.version }}" pom.xml
4452
4553
- name: Publish to GitHub Packages
46-
run: mvn -ntp -B release:prepare release:perform
54+
run: mvn -ntp --batch-mode -Dgpg.passphrase="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" clean deploy -Prelease
4755
env:
4856
GITHUB_TOKEN: ${{ github.token }}
57+
58+
- name: Set up Java for publishing to Maven Central
59+
uses: actions/setup-java@v3
60+
with:
61+
java-version: '11'
62+
distribution: 'temurin'
63+
server-id: ossrh
64+
server-username: MAVEN_USERNAME
65+
server-password: MAVEN_PASSWORD
66+
- name: Publish to the Maven Central
67+
run: mvn --batch-mode -Dgpg.passphrase="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" clean deploy -Prelease,mavencentral-release
68+
env:
69+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
70+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

README.md

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
> and there might be incompatible changes before the 1.0 release.
1010
> Contributions are welcome!
1111
12-
This module allows provisioning the WireMock server
12+
This module allows provisioning the WireMock server
1313
as a standalone container
14-
within your unit test, based on [WireMock Docker](https://github.com/wiremock/wiremock-docker).
14+
within your unit tests, based on [WireMock Docker](https://github.com/wiremock/wiremock-docker).
1515

1616
While you can run [WireMock Java](https://github.com/wiremock/wiremock)
1717
with the same result for the most of the use-cases,
@@ -34,13 +34,39 @@ Please feel free to contribute the integration tests and compatibility layers!
3434

3535
### Importing the dependency
3636

37-
At the moment the module is published to GitHub Packages only,
38-
see [Issue #56](https://github.com/wiremock/wiremock-testcontainers-java/issues/56)
39-
for publishing to Maven Central.
40-
For the moment, you can use the authenticated GitHub Packages server or
41-
[JitPack](https://jitpack.io/) to add the dependency in your projects.
37+
The module is published to Maven Central and GitHub Packages.
38+
You can also use [JitPack](https://jitpack.io/) to add the dependency in your projects.
4239

43-
#### Maven / JitPack
40+
#### Maven
41+
42+
```xml
43+
<dependency>
44+
<groupId>org.wiremock.integrations.testcontainers</groupId>
45+
<artifactId>wiremock-testcontainers-module</artifactId>
46+
<version>${see the releases}</version>
47+
<scope>test</scope>
48+
</dependency>
49+
```
50+
51+
#### Gradle
52+
53+
```gradle
54+
dependencies {
55+
testImplementation 'org.wiremock.integrations.testcontainers:wiremock-testcontainers-module:${wiremock-testcontainers.version}'
56+
}
57+
```
58+
59+
#### GitHub Packages
60+
61+
GitHub Packages uses the official Maven coordinates (same as Maven Central above),
62+
but you will need to configure the server and authentication.
63+
64+
#### JitPack
65+
66+
<details>
67+
<summary>
68+
JitPack / Maven
69+
</summary>
4470

4571
```xml
4672
<dependencies>
@@ -61,14 +87,14 @@ For the moment, you can use the authenticated GitHub Packages server or
6187
</repositories>
6288
```
6389

90+
</details>
91+
6492
<details>
6593
<summary>
66-
Gradle / JitPack
94+
JitPack / Gradle
6795
</summary>
6896

69-
#### Gradle / JitPack
70-
71-
```groovy
97+
```gradle
7298
allprojects {
7399
repositories {
74100
maven { url 'https://jitpack.io' }
@@ -80,26 +106,6 @@ Gradle / JitPack
80106
}
81107
82108
```
83-
</details>
84-
85-
<details>
86-
<summary>
87-
Maven / GitHub Packages
88-
</summary>
89-
90-
#### Maven / GitHub Packages
91-
92-
GitHub Packages uses the official Maven coordinates,
93-
but you will need to configure the server and authentication.
94-
95-
```xml
96-
<dependency>
97-
<groupId>org.wiremock.integrations.testcontainers</groupId>
98-
<artifactId>wiremock-testcontainers-module</artifactId>
99-
<version>${see the releases}</version>
100-
<scope>test</scope>
101-
</dependency>
102-
```
103109

104110
</details>
105111

pom.xml

Lines changed: 111 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
<groupId>org.wiremock.integrations.testcontainers</groupId>
66
<artifactId>wiremock-testcontainers-module</artifactId>
7-
<description>Testcontainers Java module for WireMock</description>
8-
<version>1.0-alpha-8-SNAPSHOT</version>
7+
<name>WireMock module for Testcontainers Java</name>
8+
<description>This Testcontainers module allows provisioning the WireMock server as a standalone container within your unit tests, based on WireMock Docker</description>
9+
<url>https://github.com/wiremock/wiremock-testcontainers-java</url>
10+
<version>1.0-alpha-12-SNAPSHOT</version>
911

1012
<licenses>
1113
<license>
@@ -15,15 +17,26 @@
1517
</license>
1618
</licenses>
1719

20+
<developers>
21+
<developer>
22+
<id>oleg-nenashev</id> <!-- OSSRH -->
23+
<name>Oleg Nenashev</name>
24+
<url>https://github.com/oleg-nenashev/</url>
25+
<timezone>CEST</timezone>
26+
<organization>WireMock Inc.</organization>
27+
<organizationUrl>https://www.wiremock.io/</organizationUrl>
28+
</developer>
29+
</developers>
30+
1831
<properties>
1932
<java.version>1.8</java.version>
2033
<maven.compiler.target>${java.version}</maven.compiler.target>
2134
<maven.compiler.source>${java.version}</maven.compiler.source>
2235
<wiremock.version>3.5.4</wiremock.version>
23-
<testcontainers.version>1.19.0</testcontainers.version>
24-
<junit.version>5.10.0</junit.version>
25-
<assertj.version>3.24.2</assertj.version>
26-
<awaitility.version>4.2.0</awaitility.version>
36+
<testcontainers.version>1.19.8</testcontainers.version>
37+
<junit.version>5.10.2</junit.version>
38+
<assertj.version>3.26.3</assertj.version>
39+
<awaitility.version>4.2.2</awaitility.version>
2740
<project.scm.id>github</project.scm.id>
2841
</properties>
2942

@@ -54,7 +67,7 @@
5467
<!-- Fix dependency convergence [logback-classic vs junit] -->
5568
<groupId>org.slf4j</groupId>
5669
<artifactId>slf4j-api</artifactId>
57-
<version>2.0.7</version>
70+
<version>2.0.15</version>
5871
</dependency>
5972
</dependencies>
6073
</dependencyManagement>
@@ -110,18 +123,18 @@
110123
<plugin>
111124
<groupId>org.apache.maven.plugins</groupId>
112125
<artifactId>maven-compiler-plugin</artifactId>
113-
<version>3.11.0</version>
126+
<version>3.13.0</version>
114127
</plugin>
115128
<plugin>
116129
<groupId>org.apache.maven.plugins</groupId>
117130
<artifactId>maven-surefire-plugin</artifactId>
118-
<version>3.1.2</version>
131+
<version>3.2.5</version>
119132
</plugin>
120133

121134
<plugin>
122135
<groupId>org.apache.maven.plugins</groupId>
123136
<artifactId>maven-source-plugin</artifactId>
124-
<version>3.3.0</version>
137+
<version>3.3.1</version>
125138
<executions>
126139
<execution>
127140
<id>attach-sources</id>
@@ -134,7 +147,7 @@
134147
<plugin>
135148
<groupId>org.apache.maven.plugins</groupId>
136149
<artifactId>maven-javadoc-plugin</artifactId>
137-
<version>3.5.0</version>
150+
<version>3.8.0</version>
138151
<executions>
139152
<execution>
140153
<id>attach-javadocs</id>
@@ -149,7 +162,7 @@
149162
<plugin>
150163
<groupId>org.apache.maven.plugins</groupId>
151164
<artifactId>maven-dependency-plugin</artifactId>
152-
<version>3.6.0</version>
165+
<version>3.7.1</version>
153166
<executions>
154167
<execution>
155168
<id>copy</id>
@@ -218,4 +231,90 @@
218231
<url>https://maven.pkg.github.com/wiremock/wiremock-testcontainers-java</url>
219232
</repository>
220233
</distributionManagement>
234+
235+
<profiles>
236+
<profile>
237+
<id>release</id>
238+
<properties>
239+
<version.maven-release-plugin>3.0.1</version.maven-release-plugin>
240+
<version.maven-gpg-plugin>3.2.4</version.maven-gpg-plugin>
241+
</properties>
242+
<build>
243+
<pluginManagement>
244+
<plugins>
245+
<plugin>
246+
<artifactId>maven-release-plugin</artifactId>
247+
<version>${version.maven-release-plugin}</version>
248+
<configuration>
249+
<tagNameFormat>@{project.version}</tagNameFormat>
250+
</configuration>
251+
</plugin>
252+
<!-- The key's name & passphrase are configured via GitHub's setup-java action. -->
253+
<plugin>
254+
<artifactId>maven-gpg-plugin</artifactId>
255+
<version>${version.maven-gpg-plugin}</version>
256+
<executions>
257+
<execution>
258+
<id>sign-artifacts</id>
259+
<phase>verify</phase>
260+
<goals>
261+
<goal>sign</goal>
262+
</goals>
263+
<configuration>
264+
<!-- This is required to make sure the plugin does not stop asking for -->
265+
<!-- user input on the passphrase -->
266+
<gpgArguments>
267+
<arg>--pinentry-mode</arg>
268+
<arg>loopback</arg>
269+
</gpgArguments>
270+
</configuration>
271+
</execution>
272+
</executions>
273+
</plugin>
274+
</plugins>
275+
</pluginManagement>
276+
<plugins>
277+
<plugin>
278+
<artifactId>maven-gpg-plugin</artifactId>
279+
</plugin>
280+
</plugins>
281+
</build>
282+
</profile>
283+
<profile>
284+
<id>mavencentral-release</id>
285+
<properties>
286+
<version.nexus-staging-maven-plugin>1.7.0</version.nexus-staging-maven-plugin>
287+
</properties>
288+
<distributionManagement>
289+
<repository>
290+
<id>ossrh</id>
291+
<name>Central Repository OSSRH</name>
292+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
293+
</repository>
294+
</distributionManagement>
295+
<build>
296+
<pluginManagement>
297+
<plugins>
298+
<plugin>
299+
<groupId>org.sonatype.plugins</groupId>
300+
<artifactId>nexus-staging-maven-plugin</artifactId>
301+
<version>${version.nexus-staging-maven-plugin}</version>
302+
<extensions>true</extensions>
303+
<configuration>
304+
<serverId>ossrh</serverId>
305+
<nexusUrl>https://oss.sonatype.org</nexusUrl>
306+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
307+
</configuration>
308+
</plugin>
309+
</plugins>
310+
</pluginManagement>
311+
<plugins>
312+
<plugin>
313+
<groupId>org.sonatype.plugins</groupId>
314+
<artifactId>nexus-staging-maven-plugin</artifactId>
315+
</plugin>
316+
</plugins>
317+
</build>
318+
</profile>
319+
</profiles>
221320
</project>

src/main/java/org/wiremock/integrations/testcontainers/WireMockContainer.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {
5050
private static final String WIREMOCK_2_LATEST_TAG = "2.35.0-1";
5151
private static final String WIREMOCK_3_LATEST_TAG = "3.5.4";
5252
/*package*/ static final String WIREMOCK_2_MINIMUM_SUPPORTED_VERSION = "2.0.0";
53+
static final String WIREMOCK_HEALTH_CHECK_SUPPORT_MINIMUM_VERSION = "3.0.0-1";
5354

5455
/**
5556
* @deprecated Not really guaranteed to be latest. Will be reworked
@@ -66,6 +67,11 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {
6667
.forHttp("/__admin/mappings")
6768
.withMethod("GET")
6869
.forStatusCode(200);
70+
71+
private static final WaitStrategy HEALTH_CHECK_ENDPOINT_WAITER = Wait
72+
.forHttp("/__admin/health")
73+
.withMethod("GET")
74+
.forStatusCode(200);
6975
private static final int PORT = 8080;
7076
private final StringBuilder wireMockArgs;
7177
private final Map<String, Stub> mappingStubs = new HashMap<>();
@@ -96,7 +102,13 @@ public WireMockContainer(DockerImageName dockerImage) {
96102
}
97103

98104
wireMockArgs = new StringBuilder();
99-
setWaitStrategy(DEFAULT_WAITER);
105+
106+
if (version.isGreaterThanOrEqualTo(WIREMOCK_HEALTH_CHECK_SUPPORT_MINIMUM_VERSION)) {
107+
setWaitStrategy(HEALTH_CHECK_ENDPOINT_WAITER);
108+
}
109+
else {
110+
setWaitStrategy(DEFAULT_WAITER);
111+
}
100112
}
101113

102114
/**

0 commit comments

Comments
 (0)