Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
groups:
maven-minor-and-patch:
update-types: [ "minor", "patch" ]
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read

# Supersede outdated PR runs; queue runs on main in order so badges never regress
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up JDK 25
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'

- name: Run tests with coverage
run: ./mvnw -B clean test

- name: Upload coverage report
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: jacoco-report
path: target/site/jacoco/jacoco.csv
if-no-files-found: error
retention-days: 1

# Only this job gets a write token, and only on main
badges:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
# Check out the branch tip (not the triggering SHA) so the badge commit fast-forwards
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
fetch-depth: 50

# A re-run of an older commit must not replace the badges of newer code
- name: Check commit is still the latest on main
id: latest
run: |
if ! git merge-base --is-ancestor "$GITHUB_SHA" HEAD; then
echo "is_latest=false" >> "$GITHUB_OUTPUT"
elif git log --format=%s "$GITHUB_SHA"..HEAD | grep -qvx 'chore: update JaCoCo coverage badges'; then
echo "is_latest=false" >> "$GITHUB_OUTPUT"
else
echo "is_latest=true" >> "$GITHUB_OUTPUT"
fi

- name: Download coverage report
if: steps.latest.outputs.is_latest == 'true'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: jacoco-report
path: target/site/jacoco

- name: Generate JaCoCo badge
if: steps.latest.outputs.is_latest == 'true'
uses: cicirello/jacoco-badge-generator@72266185b7ee48a6fd74eaf0238395cc8b14fef8 # v2.12.1
with:
generate-branches-badge: true
jacoco-csv-file: target/site/jacoco/jacoco.csv
badges-directory: .github/badges

- name: Commit updated badges
if: steps.latest.outputs.is_latest == 'true'
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
with:
commit_message: "chore: update JaCoCo coverage badges"
file_pattern: '.github/badges/*.svg'
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# java-spring-rest
![CI](https://github.com/andreasarf/java-spring-rest/actions/workflows/ci.yml/badge.svg?branch=main)
![Coverage](.github/badges/jacoco.svg)
![Branches](.github/badges/branches.svg)

Example for implementation Rest API using Spring Boot.

## Requirement
Expand Down
2 changes: 2 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<properties>
<java.version>25</java.version>
<swagger-annotations.version>2.2.55</swagger-annotations.version>
<jacoco.version>0.8.15</jacoco.version>
<!-- Overridden by agents such as JaCoCo; keeps @{argLine} resolvable when none is set -->
<argLine></argLine>
</properties>
Expand Down Expand Up @@ -119,6 +120,25 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Loading