Skip to content

Commit 980fc3c

Browse files
authored
Separate Sonar checks (#278)
1 parent 8113d30 commit 980fc3c

File tree

6 files changed

+44
-14
lines changed

6 files changed

+44
-14
lines changed

.github/workflows/gradle-build.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
outputs:
3131
build-changes: ${{ steps.filter.outputs.build }}
32+
source-changes: ${{ steps.filter.outputs.java }}
3233
steps:
3334
- uses: actions/checkout@v5
3435
with:
@@ -42,13 +43,50 @@ jobs:
4243
- '**/*.gradle.kts'
4344
- '**/gradle-build.yml'
4445
- 'gradle.properties'
46+
java:
4547
- '**/*.java'
46-
48+
4749
gradle-build:
4850
name: Build project with Gradle
4951
needs: check-changes
5052
if: ${{ needs.check-changes.outputs.build-changes == 'true' }}
5153
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v5
56+
with:
57+
fetch-depth: 0
58+
- name: Set up JDK
59+
uses: actions/setup-java@v5
60+
with:
61+
java-version: '21'
62+
distribution: 'temurin'
63+
cache: 'gradle'
64+
- name: Setup Gradle
65+
uses: gradle/actions/setup-gradle@v4
66+
with:
67+
add-job-summary-as-pr-comment: on-failure
68+
build-scan-publish: true
69+
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
70+
build-scan-terms-of-use-agree: "yes"
71+
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
72+
- name: Setup Testcontainers Cloud Client
73+
uses: atomicjar/testcontainers-cloud-setup-action@v1
74+
with:
75+
token: ${{ secrets.TC_CLOUD_TOKEN }}
76+
- name: Run CI build
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: ./gradlew check --configuration-cache
80+
- name: Terminate Testcontainers Cloud Client active sessions
81+
uses: atomicjar/testcontainers-cloud-setup-action@v1
82+
with:
83+
action: terminate
84+
85+
code-quality:
86+
name: Code Quality with Sonar
87+
needs: check-changes
88+
if: ${{ needs.check-changes.outputs.source-changes == 'true' }}
89+
runs-on: ubuntu-latest
5290
steps:
5391
- uses: actions/checkout@v5
5492
with:
@@ -76,16 +114,12 @@ jobs:
76114
- name: Setup Testcontainers Cloud Client
77115
uses: atomicjar/testcontainers-cloud-setup-action@v1
78116
with:
79-
token: ${{ secrets.TC_CLOUD_TOKEN }}
80-
- name: Run CI build
81-
env:
82-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83-
run: ./gradlew check --configuration-cache
117+
token: ${{ secrets.TC_CLOUD_TOKEN }}
84118
- name: Publish Sonar report
85119
env:
86120
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
87-
run: ./gradlew sonar
121+
run: ./gradlew check sonar
88122
- name: Terminate Testcontainers Cloud Client active sessions
89123
uses: atomicjar/testcontainers-cloud-setup-action@v1
90124
with:
91-
action: terminate
125+
action: terminate

data-mongodb-tc-data-load/src/test/java/zin/rashidi/data/mongodb/tc/dataload/user/UserRepositoryTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import org.springframework.boot.test.context.TestConfiguration;
88
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
99
import org.springframework.context.annotation.Bean;
10-
import org.springframework.context.annotation.ComponentScan;
1110
import org.springframework.context.annotation.ComponentScan.Filter;
12-
import org.springframework.context.annotation.FilterType;
1311
import org.springframework.core.io.ClassPathResource;
1412
import org.springframework.core.io.Resource;
1513
import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean;

graphql/src/test/java/zin/rashidi/boot/graphql/book/BookResourceTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.springframework.stereotype.Repository;
1111

1212
import static org.springframework.context.annotation.FilterType.ANNOTATION;
13-
import static org.springframework.context.annotation.FilterType.ASSIGNABLE_TYPE;
1413

1514
/**
1615
* @author Rashidi Zin

modulith/src/main/java/zin/rashidi/boot/modulith/subscription/Subscription.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Subscription {
1313
private Long id;
1414
private final Long studentId;
1515
private final Long courseId;
16-
private Status status;
16+
private final Status status;
1717

1818
public Subscription(Long studentId, Long courseId) {
1919
this.studentId = studentId;

test-execution-listeners/src/test/java/zin/rashidi/boot/test/user/UserDeletionTestExecutionListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class UserDeletionTestExecutionListener extends AbstractTestExecutionListener {
1313

14-
private static Logger log = LoggerFactory.getLogger(UserDeletionTestExecutionListener.class);
14+
private static final Logger log = LoggerFactory.getLogger(UserDeletionTestExecutionListener.class);
1515

1616
@Override
1717
public void afterTestClass(TestContext testContext) {

test-execution-listeners/src/test/java/zin/rashidi/boot/test/user/UserRepositoryTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.testcontainers.containers.MongoDBContainer;
1414
import org.testcontainers.junit.jupiter.Container;
1515
import org.testcontainers.junit.jupiter.Testcontainers;
16-
import org.testcontainers.utility.DockerImageName;
1716

1817
/**
1918
* @author Rashidi Zin

0 commit comments

Comments
 (0)