-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (96 loc) Β· 3.48 KB
/
ci.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
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
113
name: CI (λΉλ λ° ν
μ€νΈ)
on:
pull_request:
branches:
- master
- develop
- 'weekly/**'
permissions:
contents: write
issues: write
pull-requests: write
jobs:
build-and-test:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis
ports:
- 6379:6379
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Decode env.properties from GitHub Secrets
run: |
echo "${{ secrets.ENV_FILE }}" | base64 --decode > ./src/main/resources/env.properties
- name: Decode Firebase config from GitHub Secrets
run: |
echo "${{ secrets.FIREBASE_CONFIG }}" | base64 --decode > ./src/main/resources/splanet-firebase.json
- name: Set environment variables from env.properties
run: |
set -o allexport
source ./src/main/resources/env.properties
set +o allexport
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '21'
distribution: 'temurin'
- name: Wait for MySQL to be ready
run: |
for i in {30..0}; do
if docker exec $(docker ps -q --filter name=mysql) mysqladmin ping -h localhost; then
echo "MySQL is ready"
break
fi
echo "Waiting for MySQL..."
sleep 1
done
if [ $i -eq 0 ]; then
echo "MySQL did not become ready in time"
docker logs $(docker ps -q --filter name=mysql)
exit 1
fi
- name: Build with Gradle
run: ./gradlew clean build -Dspring.profiles.active=test
- name: Run Tests
run: ./gradlew test -Dspring.profiles.active=test
- name: Generate JaCoCo Coverage Report
run: ./gradlew jacocoTestReport
- name: Generate Coverage Badge and Summary
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: 'build/reports/jacoco/test/jacocoTestReport.csv'
badges-directory: 'badges'
generate-branches-badge: true
generate-summary: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Display Coverage Summary JSON
run: |
cat badges/coverage-summary.json
- name: Extract Coverage Information
if: ${{ github.event_name == 'pull_request' }}
run: |
COVERAGE=$(jq '.coverage' badges/coverage-summary.json)
BRANCH_COVERAGE=$(jq '.branches' badges/coverage-summary.json)
FORMATTED_COVERAGE=$(printf "%.2f" $COVERAGE)
FORMATTED_BRANCH_COVERAGE=$(printf "%.2f" $BRANCH_COVERAGE)
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-X POST \
-d "{\"body\": \"### μ½λ 컀λ²λ¦¬μ§\n- Coverage: ${FORMATTED_COVERAGE}%\n- Branches: ${FORMATTED_BRANCH_COVERAGE}%\n\"}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"