Add gitea-actions: Spring Boot 4.2.0 CI with surefire/failsafe, Testcontainers, CycloneDX SBOM and Jib

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b69H5rTewUKPyhGS8r
This commit is contained in:
2026-12-01 23:59:28 +05:30
co-authored by Claude Sonnet 5.5
parent bb12eaca0a
commit 5facfdc212
30 changed files with 811 additions and 0 deletions
+151
View File
@@ -0,0 +1,151 @@
<?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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.2.0</version>
<relativePath/>
</parent>
<groupId>com.ankurm.ci</groupId>
<artifactId>gitea-actions-demo</artifactId>
<version>1.0.0</version>
<name>gitea-actions-demo: a small Spring Boot service with a CI pipeline</name>
<properties>
<java.version>25</java.version>
<jib.version>3.5.2</jib.version>
<!-- Where `mvn jib:build` pushes. Override with -Dimage.name=registry.example.com/owner/gitea-actions-demo -->
<image.name>localhost:5000/gitea-actions-demo</image.name>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- *Test = unit tests (surefire, no Docker). *IT = integration tests (failsafe, needs Docker). -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- SBOM. spring-boot-starter-parent already binds makeAggregateBom to generate-resources and writes
target/classes/META-INF/sbom/application.cdx.json, so it ends up INSIDE the jar and the actuator
can serve it. Declaring the plugin is all that is needed; the version is managed by Spring Boot. -->
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
</plugin>
<!-- Image without a Dockerfile and without a Docker daemon in the build step. -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib.version}</version>
<configuration>
<from>
<image>eclipse-temurin:25-jre</image>
</from>
<to>
<image>${image.name}</image>
<tags>
<tag>${project.version}</tag>
</tags>
</to>
<container>
<ports>
<port>8080</port>
</ports>
<user>1000</user>
<labels>
<org.opencontainers.image.title>gitea-actions-demo</org.opencontainers.image.title>
<org.opencontainers.image.source>https://ankurm.com/git.app/asmhatre/java-devops-demo</org.opencontainers.image.source>
</labels>
</container>
<allowInsecureRegistries>true</allowInsecureRegistries>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- The mistake from the first draft of this module, kept so the post can show its effect:
re-declaring the parent's execution (same id "default") with phase=package moves SBOM generation
AFTER spring-boot:repackage, so the jar no longer contains the SBOM. -->
<profile>
<id>late-sbom</id>
<build>
<plugins>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>makeAggregateBom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>