Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
[![Java CI with Maven](https://github.com/sparsick/testcontainers-git/actions/workflows/maven.yml/badge.svg?branch=main)](https://github.com/sparsick/testcontainers-git/actions/workflows/maven.yml)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.sparsick.testcontainers.gitserver/testcontainers-gitserver/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.sparsick.testcontainers.gitserver/testcontainers-gitserver)

This project contains a [Testcontainers](https://www.testcontainers.org/) implementation for a plain git server based on the Docker image `rockstorm/git-server` ([Github Project](https://github.com/rockstorm101/git-server-docker)) and for a forgejo git server based on the Docker image `forgejoclone/forgejo` ([Codeberg Project](https://codeberg.org/forgejoclone/forgejo)).
This project contains [Testcontainers](https://www.testcontainers.org/) implementations for several git (management) server:
- a plain git server based on the Docker image `rockstorm/git-server` ([Github Project](https://github.com/rockstorm101/git-server-docker)) (module `testcontainers-gitserver`),
- for a forgejo git server based on the Docker image `forgejoclone/forgejo` ([Codeberg Project](https://codeberg.org/forgejoclone/forgejo)) (module `testcontainers-forgejo`) and
- for a gitea git server based on the Docker image `gitea/gitea` ([Github Project](https://github.com/go-gitea/gitea)) (module `testcontainers-gitea`).

It sets up the git server with a ready to use repository with the default name `testRepo`.
The repository name can be overwritten.
Expand Down Expand Up @@ -37,6 +40,11 @@ The port is set by testcontainers' mechanism.
<artifactId>testcontainers-forgejo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.sparsick.testcontainers.gitserver</groupId>
<artifactId>testcontainers-gitea</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
```

Expand All @@ -51,6 +59,7 @@ dependencyManagement {
dependencies {
testImplementation 'io.github.sparsick.testcontainers.gitserver:testcontainers-gitserver'
testImplementation 'io.github.sparsick.testcontainers.gitserver:testcontainers-forgejo'
testImplementation 'io.github.sparsick.testcontainers.gitserver:testcontainers-gitea'
}
```

Expand Down Expand Up @@ -174,10 +183,13 @@ public class GitHttpServerContainerUsedInJUnit5Test {
}
````

### Forgejo Server (`testcontainers-forgejo`)
### Forgejo Server (`testcontainers-forgejo`) / Gitea Server (`testcontainers-gitea`)

Forgejo server is supported since version 0.14.0 and the gitea server is supported since version 1.15.0.

The following samples show how to use the Forgejo git server container or Gitea git server container in a JUnit 5 test.
If you want to use the gitea server, you have to use the `testcontainers-gitea` dependency instead of the `testcontainers-forgejo` dependency and replace `ForgejoContainer` with `GiteaContainer`.

Forgejo server is supported since version 0.14.0.
The following samples show how to use the Forgejo git server container in a JUnit 5 test.
The container exposes two protocols:

- Git over **HTTP** (port `3000`)
Expand Down Expand Up @@ -294,7 +306,7 @@ void checkExistingRepoIsAvailable() {

> **Note:** Using `withCopyExistingGitRepoToContainer()` without a lowercase gitRepoName throws an `IllegalArgumentException`.

#### Choosing a Forgejo Version
#### Choosing a Forgejo/Gitea Version

Use the `ForgejoVersions` enum to pin a specific image version:

Expand All @@ -305,6 +317,15 @@ new ForgejoContainer(ForgejoVersions.V11_0_10.getDockerImageName())
// ... and more, see ForgejoVersions for the full list
````

For Gitea, use the `GiteaVersions` enum to pin a specific image version:

````java
new GiteaContainer(GiteaVersions.V1_15_0.getDockerImageName())
new GiteaContainer(GiteaVersions.V1_14_0.getDockerImageName())
new GiteaContainer(GiteaVersions.V1_13_0.getDockerImageName())
// ... and more, see GiteaVersions for the full list
````

## Migration Guide
### Migration from 0.4.x to 0.5.x

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<module>rewrite-testcontainers-gitserver</module>
<module>testcontainers-git-bom</module>
<module>testcontainers-forgejo</module>
<module>testcontainers-gitea</module>
</modules>

<dependencyManagement>
Expand Down
5 changes: 5 additions & 0 deletions testcontainers-git-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<artifactId>testcontainers-forgejo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.github.sparsick.testcontainers.gitserver</groupId>
<artifactId>testcontainers-gitea</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
140 changes: 140 additions & 0 deletions testcontainers-gitea/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.github.sparsick.testcontainers.gitserver</groupId>
<artifactId>testcontainers-git-parent</artifactId>
<version>0.15.0-SNAPSHOT</version>
</parent>

<artifactId>testcontainers-gitea</artifactId>
<name>Gitea Server for Testcontainers</name>

<properties>
<httpclient-version>5.6</httpclient-version>
<jackson-databind-nullable-version>0.2.9</jackson-databind-nullable-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>
</properties>

<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<!-- needed for open api generated client -->
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>


<!-- HTTP client: apache client -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient-version}</version>
</dependency>

<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable-version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-version}</version>
</dependency>


<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>${jgit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.ssh.jsch</artifactId>
<version>${jgit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.20.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/gitea-1.25.4/swagger.v1.json</inputSpec>
<configOptions>
<useJakartaEe>true</useJakartaEe>
</configOptions>
<generatorName>java</generatorName>
<library>apache-httpclient</library>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading