Skip to content

Commit

Permalink
add github actions script that comments "test test" after test covera…
Browse files Browse the repository at this point in the history
…ge is created

known-issues: should not comment test test but a badge with coverage result

Signed-off-by: Aleksandar Zivkovic <[email protected]>
  • Loading branch information
alekszivko committed Dec 25, 2024
1 parent 5cee728 commit e4829f9
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 16 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: codeanalysis and coverage

on:
push:
branches:
- main
- dev
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up JDK 22
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '22'
cache: maven
- name: Run Coverage
run: |
chmod +x mvnw
./mvnw clean verify
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
71 changes: 55 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,61 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>sj2324-seed</artifactId>
<description>Simple spring boot project that has a rest api and some serverside
rendered templates</description>
<groupId>dev.azivkovic</groupId>
<artifactId>apiAndSsrExample</artifactId>
<modelVersion>4.0.0</modelVersion>
<name>apiAndSsrExample</name>
<properties>
<sonar.organization>alekszivko</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<java.version>22</java.version>
<querydsl.version>5.0.0</querydsl.version>
</properties>
<version>0.0.1-SNAPSHOT</version>
<build>
<finalName>apiAndSsrExample</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -77,10 +129,6 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
<dependency>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
<dependency>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -131,7 +179,7 @@
<dependency>
<artifactId>postgresql</artifactId>
<groupId>org.testcontainers</groupId>
<scope>test</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -144,19 +192,10 @@
<groupId>org.springframework.boot</groupId>
</dependency>
</dependencies>
<description>Spring Boot seed project</description>
<groupId>at.spengergasse</groupId>
<modelVersion>4.0.0</modelVersion>
<name>SJ2324 Seedproject</name>
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<relativePath/>
<version>3.2.3</version> <!-- lookup parent from repository -->
<version>3.2.4</version> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>22</java.version>
<querydsl.version>5.0.0</querydsl.version>
</properties>
<version>0.0.1-SNAPSHOT</version>
</project>

0 comments on commit e4829f9

Please sign in to comment.