Skip to content

Commit 8597b61

Browse files
authored
chore: Upgrade CI (#259)
1 parent 9e6050b commit 8597b61

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

.github/workflows/gradle-ci.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
name: Java CI with Gradle
1+
name: Java CI with Gradle and SonarQube
22

33
on:
44
push:
55
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
68

79
jobs:
810
build-and-analyze:
9-
10-
runs-on: ubuntu-20.04
11+
name: Build and SonarQube Analysis
12+
runs-on: ubuntu-latest
1113

1214
steps:
13-
- uses: actions/checkout@v3
15+
- name: Checkout source
16+
uses: actions/checkout@v4
17+
18+
- name: Validate Gradle wrapper
19+
uses: gradle/wrapper-validation-action@v1
20+
1421
- name: Set up JDK 21
15-
uses: actions/setup-java@v3
22+
uses: actions/setup-java@v4
1623
with:
17-
java-version: '21'
1824
distribution: 'temurin'
19-
- name: Grant execute permission for gradlew
20-
run: chmod +x gradlew
25+
java-version: '21'
26+
cache: 'gradle'
27+
28+
- name: Grant execute permission for Gradle
29+
run: chmod +x ./gradlew
30+
2131
- name: Build and run SonarQube analysis
22-
run: ./gradlew build sonarqube
32+
run: ./gradlew build sonarqube --no-daemon
2333
env:
2434
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will build a Java project with Gradle
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3-
4-
name: Java PR builder with Gradle
1+
name: Java PR Builder with Gradle and SonarCloud
52

63
on:
74
pull_request_target:
@@ -10,26 +7,37 @@ on:
107

118
jobs:
129
build-and-analyze:
13-
14-
runs-on: ubuntu-20.04
10+
name: Build and SonarCloud Analysis
11+
runs-on: ubuntu-latest
1512

1613
steps:
17-
- name: Checkout Code
18-
uses: actions/checkout@v3
14+
- name: Checkout PR source code
15+
uses: actions/checkout@v4
1916
with:
2017
ref: ${{ github.event.pull_request.head.sha }}
2118

19+
- name: Validate Gradle wrapper
20+
uses: gradle/wrapper-validation-action@v1
21+
2222
- name: Set up JDK 21
23-
uses: actions/setup-java@v3
23+
uses: actions/setup-java@v4
2424
with:
25-
java-version: '21'
2625
distribution: 'temurin'
27-
28-
- name: Grant execute permission for gradlew
29-
run: chmod +x gradlew
30-
31-
- name: Build and analyze with Gradle
32-
run: ./gradlew build sonarqube -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=iluwatar -Dsonar.projectKey=iluwatar_30-seconds-of-java -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.base=${{ github.base_ref }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
26+
java-version: '21'
27+
cache: 'gradle'
28+
29+
- name: Make Gradle executable
30+
run: chmod +x ./gradlew
31+
32+
- name: Build and analyze with Gradle and SonarCloud
33+
run: |
34+
./gradlew build sonarqube --no-daemon \
35+
-Dsonar.host.url=https://sonarcloud.io \
36+
-Dsonar.organization=iluwatar \
37+
-Dsonar.projectKey=iluwatar_30-seconds-of-java \
38+
-Dsonar.pullrequest.branch=${{ github.head_ref }} \
39+
-Dsonar.pullrequest.base=${{ github.base_ref }} \
40+
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
3341
env:
3442
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3543
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)