Skip to content

Commit 5a69514

Browse files
authored
Merge pull request #2 from WeiXuChong/copilot/create-section-24-ci-setup
Upgrade CI: actions v4, Maven caching, JaCoCo coverage, artifact upload
2 parents ae2cfa1 + 9ca722d commit 5a69514

2 files changed

Lines changed: 39 additions & 18 deletions

File tree

.github/workflows/build-test-lint-format.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,20 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout code
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717

1818
- name: Set up JDK 17
19-
uses: actions/setup-java@v3
19+
uses: actions/setup-java@v4
2020
with:
2121
java-version: '17'
2222
distribution: 'temurin'
23-
24-
# - name: Cache Maven dependencies
25-
# uses: actions/cache@v3
26-
# with:
27-
# path: ~/.m2/repository
28-
# key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
29-
# restore-keys: |
30-
# ${{ runner.os }}-maven-
23+
cache: 'maven'
3124

3225
- name: Install dependencies
33-
run: mvn clean install -DskipTests
26+
run: chmod +x mvnw && ./mvnw clean install -DskipTests
3427

3528
- name: Run Tests
36-
run: mvn test
29+
run: ./mvnw test
3730
env:
3831
ENV: production
3932
DATABASE_URL: ${{ secrets.DATABASE_URL }}
@@ -49,27 +42,36 @@ jobs:
4942
MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }}
5043
MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }}
5144

45+
- name: Upload test reports
46+
if: always()
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: test-reports
50+
path: |
51+
target/surefire-reports/
52+
target/site/jacoco/
53+
5254
# lint-and-format:
5355
# runs-on: ubuntu-latest
5456
# needs: build-and-test
5557
# steps:
5658
# - name: Checkout code
57-
# uses: actions/checkout@v3
59+
# uses: actions/checkout@v4
5860
#
5961
# - name: Set up JDK 17
60-
# uses: actions/setup-java@v3
62+
# uses: actions/setup-java@v4
6163
# with:
6264
# java-version: '17'
6365
# distribution: 'temurin'
6466
#
6567
# - name: Run Checkstyle
66-
# run: mvn checkstyle:check
68+
# run: ./mvnw checkstyle:check
6769
#
6870
# - name: Run PMD
69-
# run: mvn pmd:check
71+
# run: ./mvnw pmd:check
7072
#
7173
# - name: Run SpotBugs
72-
# run: mvn spotbugs:check
74+
# run: ./mvnw spotbugs:check
7375

7476
# - name: Verify code formatting with Spotless (excluding Javadocs)
75-
# run: mvn spotless:check -Dspotless.apply.skip
77+
# run: ./mvnw spotless:check -Dspotless.apply.skip

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@
129129
<groupId>org.springframework.boot</groupId>
130130
<artifactId>spring-boot-maven-plugin</artifactId>
131131
</plugin>
132+
<plugin>
133+
<groupId>org.jacoco</groupId>
134+
<artifactId>jacoco-maven-plugin</artifactId>
135+
<version>0.8.12</version>
136+
<executions>
137+
<execution>
138+
<goals>
139+
<goal>prepare-agent</goal>
140+
</goals>
141+
</execution>
142+
<execution>
143+
<id>report</id>
144+
<phase>test</phase>
145+
<goals>
146+
<goal>report</goal>
147+
</goals>
148+
</execution>
149+
</executions>
150+
</plugin>
132151
</plugins>
133152
</build>
134153

0 commit comments

Comments
 (0)