-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (66 loc) · 2.43 KB
/
pull-request.yml
File metadata and controls
76 lines (66 loc) · 2.43 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
name: Build and Test with Coverage
on:
pull_request:
branches:
- develop
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
checks: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{secrets.CONFIG_SUBMODULE_TOKEN}}
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Make gradlew executable
run: chmod +x gradlew
#라이브러리 캐싱
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
#Gradle 빌드 및 테스트
- name: Build and Test with Gradle
run: ./gradlew clean build test jacocoTestReport
#실패시 실패 코드에 코멘트
- name: If the test fails, register a check comment in the failed code line
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
token: ${{ secrets.GITHUB_TOKEN }}
#테스트 커버리지 리포트 생성 확인
- name: Check if coverage report exists and is valid
id: check_coverage
run: |
FILE_PATH="${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml"
if [ -s "$FILE_PATH" ] && grep -q "<counter type=\"LINE\" missed=\"0\"" "$FILE_PATH"; then
echo "Coverage report exists and is not empty with coverage."
echo "::set-output name=exists::true"
else
echo "Coverage report exists but has no coverage or is empty."
echo "::set-output name=exists::false"
fi
#테스트 커버리지 리포트 출력
- name: Add coverage to PR
if: steps.check_coverage.outputs.exists == 'true'
id: jacoco
uses: madrapps/jacoco-report@v1.2
with:
title: 📝 테스트 커버리지 리포트입니다!
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 80
min-coverage-changed-files: 80