Skip to content

Commit

Permalink
Merge branch 'main' into wiremock-3-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev authored Aug 9, 2024
2 parents 94ed862 + 0186947 commit d648624
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 53 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release to GitHub Packages
name: Release

on:
workflow_dispatch:
Expand All @@ -21,6 +21,19 @@ jobs:
with:
fetch-depth: 0

- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- id: install-secret-key
name: Install gpg secret key
run: |
# Install gpg secret key
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
# Verify gpg secret key
gpg --list-secret-keys --keyid-format LONG
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -29,20 +42,29 @@ jobs:
distribution: 'temurin'
cache: maven

- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Set Release Version
id: vars
shell: bash
run: |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
mvn -ntp -B versions:set -DnewVersion=${{ github.event.inputs.version }}-SNAPSHOT
mvn -ntp --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }}
git diff-index --quiet HEAD || git commit -m "Releasing version ${{ github.event.inputs.version }}" pom.xml
- name: Publish to GitHub Packages
run: mvn -ntp -B release:prepare release:perform
run: mvn -ntp --batch-mode -Dgpg.passphrase="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" clean deploy -Prelease
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Set up Java for publishing to Maven Central
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish to the Maven Central
run: mvn --batch-mode -Dgpg.passphrase="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" clean deploy -Prelease,mavencentral-release
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
70 changes: 38 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
> and there might be incompatible changes before the 1.0 release.
> Contributions are welcome!
This module allows provisioning the WireMock server
This module allows provisioning the WireMock server
as a standalone container
within your unit test, based on [WireMock Docker](https://github.com/wiremock/wiremock-docker).
within your unit tests, based on [WireMock Docker](https://github.com/wiremock/wiremock-docker).

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

### Importing the dependency

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

#### Maven / JitPack
#### Maven

```xml
<dependency>
<groupId>org.wiremock.integrations.testcontainers</groupId>
<artifactId>wiremock-testcontainers-module</artifactId>
<version>${see the releases}</version>
<scope>test</scope>
</dependency>
```

#### Gradle

```gradle
dependencies {
testImplementation 'org.wiremock.integrations.testcontainers:wiremock-testcontainers-module:${wiremock-testcontainers.version}'
}
```

#### GitHub Packages

GitHub Packages uses the official Maven coordinates (same as Maven Central above),
but you will need to configure the server and authentication.

#### JitPack

<details>
<summary>
JitPack / Maven
</summary>

```xml
<dependencies>
Expand All @@ -61,14 +87,14 @@ For the moment, you can use the authenticated GitHub Packages server or
</repositories>
```

</details>

<details>
<summary>
Gradle / JitPack
JitPack / Gradle
</summary>

#### Gradle / JitPack

```groovy
```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
Expand All @@ -80,26 +106,6 @@ Gradle / JitPack
}
```
</details>

<details>
<summary>
Maven / GitHub Packages
</summary>

#### Maven / GitHub Packages

GitHub Packages uses the official Maven coordinates,
but you will need to configure the server and authentication.

```xml
<dependency>
<groupId>org.wiremock.integrations.testcontainers</groupId>
<artifactId>wiremock-testcontainers-module</artifactId>
<version>${see the releases}</version>
<scope>test</scope>
</dependency>
```

</details>

Expand Down
123 changes: 111 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

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

<licenses>
<license>
Expand All @@ -15,15 +17,26 @@
</license>
</licenses>

<developers>
<developer>
<id>oleg-nenashev</id> <!-- OSSRH -->
<name>Oleg Nenashev</name>
<url>https://github.com/oleg-nenashev/</url>
<timezone>CEST</timezone>
<organization>WireMock Inc.</organization>
<organizationUrl>https://www.wiremock.io/</organizationUrl>
</developer>
</developers>

<properties>
<java.version>1.8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<wiremock.version>3.5.4</wiremock.version>
<testcontainers.version>1.19.0</testcontainers.version>
<junit.version>5.10.0</junit.version>
<assertj.version>3.24.2</assertj.version>
<awaitility.version>4.2.0</awaitility.version>
<testcontainers.version>1.19.8</testcontainers.version>
<junit.version>5.10.2</junit.version>
<assertj.version>3.26.3</assertj.version>
<awaitility.version>4.2.2</awaitility.version>
<project.scm.id>github</project.scm.id>
</properties>

Expand Down Expand Up @@ -54,7 +67,7 @@
<!-- Fix dependency convergence [logback-classic vs junit] -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
<version>2.0.15</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down Expand Up @@ -110,18 +123,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.5</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -134,7 +147,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<version>3.8.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -149,7 +162,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.1</version>
<executions>
<execution>
<id>copy</id>
Expand Down Expand Up @@ -218,4 +231,90 @@
<url>https://maven.pkg.github.com/wiremock/wiremock-testcontainers-java</url>
</repository>
</distributionManagement>

<profiles>
<profile>
<id>release</id>
<properties>
<version.maven-release-plugin>3.0.1</version.maven-release-plugin>
<version.maven-gpg-plugin>3.2.4</version.maven-gpg-plugin>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>${version.maven-release-plugin}</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
<!-- The key's name & passphrase are configured via GitHub's setup-java action. -->
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>${version.maven-gpg-plugin}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- This is required to make sure the plugin does not stop asking for -->
<!-- user input on the passphrase -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>mavencentral-release</id>
<properties>
<version.nexus-staging-maven-plugin>1.7.0</version.nexus-staging-maven-plugin>
</properties>
<distributionManagement>
<repository>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${version.nexus-staging-maven-plugin}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {
private static final String WIREMOCK_2_LATEST_TAG = "2.35.0-1";
private static final String WIREMOCK_3_LATEST_TAG = "3.5.4";
/*package*/ static final String WIREMOCK_2_MINIMUM_SUPPORTED_VERSION = "2.0.0";
static final String WIREMOCK_HEALTH_CHECK_SUPPORT_MINIMUM_VERSION = "3.0.0-1";

/**
* @deprecated Not really guaranteed to be latest. Will be reworked
Expand All @@ -66,6 +67,11 @@ public class WireMockContainer extends GenericContainer<WireMockContainer> {
.forHttp("/__admin/mappings")
.withMethod("GET")
.forStatusCode(200);

private static final WaitStrategy HEALTH_CHECK_ENDPOINT_WAITER = Wait
.forHttp("/__admin/health")
.withMethod("GET")
.forStatusCode(200);
private static final int PORT = 8080;
private final StringBuilder wireMockArgs;
private final Map<String, Stub> mappingStubs = new HashMap<>();
Expand Down Expand Up @@ -96,7 +102,13 @@ public WireMockContainer(DockerImageName dockerImage) {
}

wireMockArgs = new StringBuilder();
setWaitStrategy(DEFAULT_WAITER);

if (version.isGreaterThanOrEqualTo(WIREMOCK_HEALTH_CHECK_SUPPORT_MINIMUM_VERSION)) {
setWaitStrategy(HEALTH_CHECK_ENDPOINT_WAITER);
}
else {
setWaitStrategy(DEFAULT_WAITER);
}
}

/**
Expand Down
Loading

0 comments on commit d648624

Please sign in to comment.