-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (119 loc) · 4.42 KB
/
Copy pathci.yml
File metadata and controls
138 lines (119 loc) · 4.42 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: CI
on:
pull_request:
branches: [ "develop", "main" ]
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch: {}
permissions:
contents: read
checks: write
pull-requests: write
issues: write
concurrency:
group: pr-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v3
if: ${{ !env.ACT }}
with:
cache-read-only: ${{ github.event_name == 'pull_request' }}
gradle-home-cache-cleanup: true
- name: Create dummy .env for CI
env:
AUDIENCE_SECRET: ${{ secrets.JWT_AUDIENCE }}
run: |
AUDIENCE_VALUE="${AUDIENCE_SECRET:-ci-audience}"
cat > .env <<EOF
# ci dummy
JWT_AUDIENCE=${AUDIENCE_VALUE}
EOF
- name: Gradle build (skip tests)
id: assemble
env:
GRADLE_OPTS: "-Dorg.gradle.vfs.watch=false"
run: |
chmod +x ./gradlew
./gradlew build -x test --no-daemon --stacktrace --info --no-watch-fs | tee build.log
- name: Gradle test (H2 in-memory)
id: test
env:
GRADLE_OPTS: "-Dorg.gradle.vfs.watch=false"
SPRING_PROFILES_ACTIVE: test
SPRING_DATASOURCE_URL: jdbc:h2:mem:ci;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=TRUE
SPRING_DATASOURCE_USERNAME: sa
SPRING_DATASOURCE_PASSWORD: ""
SPRING_DATASOURCE_DRIVER_CLASS_NAME: org.h2.Driver
SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.H2Dialect
SPRING_JPA_HIBERNATE_DDL_AUTO: create-drop
SPRING_FLYWAY_ENABLED: "false"
SPRING_DATA_REDIS_HOST: localhost
SPRING_DATA_REDIS_PORT: 6379
run: ./gradlew test --no-daemon --stacktrace --info --no-watch-fs | tee test.log
- name: Publish unit-test results (check UI)
id: publish
if: ${{ always() && !env.ACT && hashFiles('**/build/test-results/test/**/*.xml') != '' }}
uses: EnricoMi/publish-unit-test-result-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "**/build/test-results/test/**/*.xml"
comment_mode: off
check_run: ${{ !github.event.pull_request.head.repo.fork }}
job_summary: true
- name: Compose message
id: status
if: ${{ always() }}
run: |
if [ "${{ steps.assemble.outcome }}" = "success" ]; then
MSG="✅ Assemble 성공"
else
MSG="❌ Assemble 실패"
fi
if [ "${{ steps.test.outcome }}" = "success" ]; then
MSG="$MSG"$'\n'"✅ Test 성공"
else
MSG="$MSG"$'\n'"❌ Test 실패"
fi
if [ "${{ steps.publish.outcome }}" = "failure" ]; then
MSG="$MSG"$'\n'"⚠️ 테스트 리포트 게시 실패(권한/토큰 문제일 수 있음)"
fi
printf "message<<EOF\n%s\nEOF\n" "$MSG" >> "$GITHUB_OUTPUT"
- name: Find existing CI status comment
id: find-comment
if: ${{ always() && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && !env.ACT }}
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'CI status'
- name: Create or update PR comment
if: ${{ always() && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && !env.ACT }}
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
**CI status**
${{ steps.status.outputs.message }}
- name: Fail if any failed
if: ${{ always() && (steps.assemble.outcome != 'success' || steps.test.outcome != 'success') }}
run: exit 1