-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (63 loc) Β· 2.65 KB
/
testcode.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
name: Run Tests on Pull Request
on:
pull_request:
branches:
- Weekly
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
options: >-
--health-cmd "mysqladmin ping --silent"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: π₯ Checkout Repository
uses: actions/checkout@v4
- name: β Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: π§ͺ Run Tests and Generate Results
env:
SPRING_DATASOURCE_URL: ${{ secrets.MYSQL_URL }}
SPRING_DATASOURCE_USERNAME: ${{ secrets.MYSQL_USERNAME }}
SPRING_DATASOURCE_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
SPRING_JPA_HIBERNATE_DDL_AUTO: "update"
JWT_SECRET: ${{ secrets.JWT_SECRET }}
SLACK_NOTICE_WEBHOOK_URL: ${{ secrets.SLACK_NOTICE_WEBHOOK_URL }}
SLACK_CHARGE_REQUEST_URL: ${{ secrets.SLACK_CHARGE_REQUEST_URL }}
SLACK_WITHDRAW_REQUEST_URL: ${{ secrets.SLACK_WITHDRAW_REQUEST_URL }}
run: ./gradlew clean build -Dspring.profiles.active=test
- name: π’ Notify Test Results on Slack
if: always()
env:
SLACK_WEBHOOK_URL: ${{ secrets.TEST_CODE_SLACK_WEBHOOK_URL }}
run: |
TEST_RESULT=$(grep -E "Tests run: [0-9]+, Failures: [0-9]+, Errors: [0-9]+, Skipped: [0-9]+" **/build/test-results/test/test-*.xml)
if echo "$TEST_RESULT" | grep -q "Failures: 0, Errors: 0"; then
curl -X POST -H 'Content-type: application/json' --data '{"text": "β
*ν
μ€νΈ μ±κ³΅* - λͺ¨λ ν
μ€νΈκ° ν΅κ³Όλμμ΅λλ€.\n'"$TEST_RESULT"'"}' $SLACK_WEBHOOK_URL
else
FAILED_TESTS=$(grep -E "failure|error" build/test-results/test/test-*.xml | sed 's/.*<failure message="\([^"]*\)".*/\1/;s/\s+/ /g')
curl -X POST -H 'Content-type: application/json' --data '{"text": "β *ν
μ€νΈ μ€ν¨* - μ€ν¨ν ν
μ€νΈκ° μμ΅λλ€.\n'"$TEST_RESULT"'\n*μ€ν¨ ν
μ€νΈ λͺ©λ‘:*\n'"$FAILED_TESTS"'"}' $SLACK_WEBHOOK_URL
fi