-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (96 loc) · 2.93 KB
/
ci.yml
File metadata and controls
114 lines (96 loc) · 2.93 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: CI
on:
pull_request:
branches: [ main ]
types: [ ready_for_review, opened, reopened, synchronize ]
push:
branches: [ main ]
# Cancel in-progress runs for the same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
# Skip draft PRs
if: github.event.pull_request.draft == false
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test-db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 3
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Grant execute permissions for gradlew
run: chmod +x gradlew
- name: Check code formatting
run: ./gradlew spotlessCheck
- name: Build
run: ./gradlew build -x test
- name: Run tests
run: ./gradlew test
env:
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/test-db
SPRING_DATASOURCE_USERNAME: test
SPRING_DATASOURCE_PASSWORD: test
- name: Generate test coverage report
run: ./gradlew jacocoTestReport
- name: Check test coverage
run: ./gradlew jacocoTestCoverageVerification
- name: Upload coverage report
uses: actions/upload-artifact@v5
if: always()
with:
name: coverage-report
path: build/reports/jacoco/test/html/
retention-days: 7
- name: Upload test results
uses: actions/upload-artifact@v5
if: always()
with:
name: test-results
path: build/reports/tests/test/
retention-days: 7
# Add coverage comment to PR
coverage-comment:
name: Coverage Report
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request'
steps:
- name: Download coverage report
uses: actions/download-artifact@v6
with:
name: coverage-report
path: coverage
- name: Add coverage to PR
uses: madrapps/jacoco-report@v1.7.2
with:
paths: build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 80
min-coverage-changed-files: 80