-
Notifications
You must be signed in to change notification settings - Fork 6
51 lines (40 loc) · 1.46 KB
/
maven.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Workflow for building and testing a Java project with Maven using GitHub Actions
name: Java CI with Maven
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the source code from the repository
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Set up JDK 21 using the Temurin distribution and enable Maven caching
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
# Step 3: Build the project with Maven
- name: Build with Maven
run: mvn -B package --file pom.xml
# Step 4: Run unit tests
- name: Run tests with Maven
run: mvn -B test --file pom.xml
# Step 5: Generate test coverage report (example with JaCoCo)
- name: Generate JaCoCo coverage report
run: mvn jacoco:report --file pom.xml
# Step 6: Upload coverage report (example with GitHub Pages)
- name: Upload coverage report
if: success()
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: target/site/jacoco/
# Step 7: Update the dependency graph to improve the quality of Dependabot alerts
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6