Skip to content

Commit 2c19d9c

Browse files
committed
Initial commit
1 parent a3d3275 commit 2c19d9c

File tree

9 files changed

+198
-0
lines changed

9 files changed

+198
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: SonarQube
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '.reports/**'
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
jobs:
11+
build:
12+
name: Build and analyze
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: 21
22+
distribution: 'zulu' # Alternative distribution options are available.
23+
- name: Cache SonarQube packages
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.sonar/cache
27+
key: ${{ runner.os }}-sonar
28+
restore-keys: ${{ runner.os }}-sonar
29+
- name: Cache Maven packages
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.m2
33+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
34+
restore-keys: ${{ runner.os }}-m2
35+
- name: Build and analyze
36+
env:
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:5.0.0.4389:sonar -Dsonar.projectKey=TaurMorchant_CodeCoverageMultiModuleRepo -Dsonar.organization=vladislav-larkin-test-organization

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

module-a/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.example</groupId>
8+
<artifactId>CodeCoverageTest</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>module-a</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>23</maven.compiler.source>
16+
<maven.compiler.target>23</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.example;
2+
3+
public final class Calculator {
4+
public static int plus(int a, int b) {
5+
return a + b;
6+
}
7+
8+
public static int multiply(int a, int b) {
9+
return a * b;
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.example;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
class CalculatorTest {
8+
9+
@Test
10+
void plus() {
11+
assertEquals(5, Calculator.plus(2, 3));
12+
}
13+
14+
@Test
15+
void multiply() {
16+
assertEquals(6, Calculator.multiply(2, 3));
17+
}
18+
}

module-b/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.example</groupId>
8+
<artifactId>CodeCoverageTest</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>module-b</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>23</maven.compiler.source>
16+
<maven.compiler.target>23</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.example;
2+
3+
public class StringUtils {
4+
public static String valueOf(int i) {
5+
return String.valueOf(i);
6+
}
7+
8+
public static String valueOf(double d) {
9+
return String.valueOf(d);
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.example;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.*;
6+
7+
class StringUtilsTest {
8+
9+
@Test
10+
void valueOf() {
11+
assertEquals("10", StringUtils.valueOf(10));
12+
}
13+
}

pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.example</groupId>
8+
<artifactId>CodeCoverageMultiModule</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>pom</packaging>
11+
<modules>
12+
<module>module-a</module>
13+
<module>module-b</module>
14+
</modules>
15+
16+
<properties>
17+
<maven.compiler.source>21</maven.compiler.source>
18+
<maven.compiler.target>21</maven.compiler.target>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.junit.jupiter</groupId>
25+
<artifactId>junit-jupiter-api</artifactId>
26+
<version>5.10.0</version>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.junit.jupiter</groupId>
31+
<artifactId>junit-jupiter-engine</artifactId>
32+
<version>5.10.0</version>
33+
<scope>test</scope>
34+
</dependency>
35+
</dependencies>
36+
37+
<build>
38+
<plugins>
39+
<plugin>
40+
<groupId>org.apache.maven.plugins</groupId>
41+
<artifactId>maven-surefire-plugin</artifactId>
42+
<version>3.1.2</version>
43+
</plugin>
44+
<plugin>
45+
<groupId>org.jacoco</groupId>
46+
<artifactId>jacoco-maven-plugin</artifactId>
47+
<version>0.8.12</version>
48+
<executions>
49+
<execution>
50+
<goals>
51+
<goal>prepare-agent</goal>
52+
</goals>
53+
</execution>
54+
<execution>
55+
<id>report</id>
56+
<phase>prepare-package</phase>
57+
<goals>
58+
<goal>report</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
66+
</project>

0 commit comments

Comments
 (0)