-
Notifications
You must be signed in to change notification settings - Fork 4
167 lines (142 loc) · 7.07 KB
/
backend_pr_decorator.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: PR 코드 분석
on:
pull_request:
types: [opened, reopened, synchronize]
branches: [ main, develop, develop-be ]
permissions: write-all
jobs:
build:
if: contains(github.event.pull_request.labels.*.name, 'backend')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: settings java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: cache gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: chmod gradle
run: chmod +x backend/ddang/gradlew
- name: run jacocoTestCoverage
run: |
cd backend/ddang
./gradlew jacocoTestCoverage --info
- name: set author slack id
if: always()
id: author-slack
run: |
GIT_ID=${{ github.event.pull_request.user.login }}
if [ "$GIT_ID" == "apptie" ]; then
AUTHOR_NAME="${{ secrets.apptie_slack_display_name }}"
AUTHOR_ID="${{ secrets.apptie_slack_id }}"
elif [ "$GIT_ID" == "swonny" ]; then
AUTHOR_NAME="${{ secrets.swonny_slack_display_name }}"
AUTHOR_ID="${{ secrets.swonny_slack_id }}"
elif [ "$GIT_ID" == "jj503" ]; then
AUTHOR_NAME="${{ secrets.jj503_slack_display_name }}"
AUTHOR_ID="${{ secrets.jj503_slack_id }}"
elif [ "$GIT_ID" == "kwonyj1022" ]; then
AUTHOR_NAME="${{ secrets.kwonyj1022_slack_display_name }}"
AUTHOR_ID="${{ secrets.kwonyj1022_slack_id }}"
fi
echo "AUTHOR_NAME=${AUTHOR_NAME}" >> $GITHUB_OUTPUT
echo "AUTHOR_ID=${AUTHOR_ID}" >> $GITHUB_OUTPUT
- name: run an analysis of the ${{ github.REF }} branch ${{ github.BASE_REF }} base
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_URL }}
with:
args: >
-Dsonar.issuesReport.console.enable=true
-Dsonar.projectKey=develop-be-project
-Dsonar.java.binaries=backend/ddang/build/classes
-Dsonar.exclusions=**/*Dto*.java,**/*Application*.java,**/*Exception*.java,**/*Response*.java,**/*Request*.java,**/*Configuration*.java,**/*Appender*.java,**/*.html,**/generated/**,**/resources/**
-Dsonar.sourceEncoding=UTF-8
-Dsonar.java.coveragePlugin=jacoco
-Dsonar.coverage.jacoco.xmlReportPaths=backend/ddang/build/reports/jacoco/test/jacocoTestReport.xml
-Dsonar.issue.ignore.multicriteria=e1,e2
-Dsonar.issue.ignore.multicriteria.e1.ruleKey=java:S100
-Dsonar.issue.ignore.multicriteria.e1.resourceKey=**/*Test.java
-Dsonar.issue.ignore.multicriteria.e2.ruleKey=java:S1192
-Dsonar.issue.ignore.multicriteria.e2.resourceKey=**/*Test.java
- name: sonarqube quality check
id: sonar-quality
run: |
SONAR_PROJECT_KEY="develop-be-project"
SONAR_TOKEN="${{ secrets.SONAR_TOKEN }}"
RESULT=$(curl -s -u "admin:root" "${{ secrets.SONAR_URL }}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_KEY}&pullRequest=${{github.event.number}}")
STATUS=$(echo "$RESULT" | jq -r '.projectStatus.status')
ERROR_METRIC_KEYS=$(echo "$RESULT" | jq -r '.projectStatus.conditions[] | select(.status == "ERROR").metricKey')
echo "STATUS=${STATUS}" >> $GITHUB_OUTPUT
echo "ERROR_METRIC_KEYS=${ERROR_METRIC_KEYS}" >> $GITHUB_OUTPUT
- name: set variables
id: variables
run: |
SONAR_SCANNER_URL="${{ secrets.SONAR_URL }}/dashboard?id=sonarqube-test&pullRequest=${{github.event.number}}"
REVIEWERS_GIT_ID='${{ toJson(github.event.pull_request.requested_reviewers[*].login) }}'
reviewers=$(echo "$REVIEWERS_GIT_ID" | jq -r '.[]')
REVIEWERS_SLACK_ID=""
for reviewer in $reviewers; do
echo "Reviewer: $reviewer"
if [ "$reviewer" == "apptie" ]; then
REVIEWERS_SLACK_ID+="<@${{ secrets.apptie_slack_id }}> "
elif [ "$reviewer" == "swonny" ]; then
REVIEWERS_SLACK_ID+="<@${{ secrets.swonny_slack_id }}> "
elif [ "$reviewer" == "JJ503" ]; then
REVIEWERS_SLACK_ID+="<@${{ secrets.jj503_slack_id }}> "
elif [ "$reviewer" == "kwonyj1022" ]; then
REVIEWERS_SLACK_ID+="<@${{ secrets.kwonyj1022_slack_id }}> "
fi
done
echo "AUTHOR=${AUTHOR}" >> $GITHUB_OUTPUT
echo "SONAR_SCANNER_URL=${SONAR_SCANNER_URL}" >> $GITHUB_OUTPUT
echo "REVIEWERS=${REVIEWERS}" >> $GITHUB_OUTPUT
echo "REVIEWERS_SLACK_ID=${REVIEWERS_SLACK_ID}" >> $GITHUB_OUTPUT
- name: slack test
run: |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>'
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_NAME }}"
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><"
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} "
SLACK_MESSAGE+="> \n>\n>분석 결과\n>"
SLACK_MESSAGE+=":white_check_mark:"
SLACK_MESSAGE+="\n>\n>*리뷰어*\n>"
SLACK_MESSAGE+="${{ steps.variables.outputs.REVIEWERS_SLACK_ID }}"
SLACK_MESSAGE+='"}}]}'
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}"
- name: slack failed test
if: failure()
run: |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>'
SLACK_MESSAGE+="<@"
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_ID }}"
SLACK_MESSAGE+=">"
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><"
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} "
SLACK_MESSAGE+="> \n>\n>분석 결과\n>"
SLACK_MESSAGE+=":x:"
SLACK_MESSAGE+='"}}]}'
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}"
- name: slack cancelled test
if: cancelled()
run: |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>'
SLACK_MESSAGE+="<@"
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_ID }}"
SLACK_MESSAGE+=">"
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><"
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} "
SLACK_MESSAGE+="> \n>\n>분석 결과\n>"
SLACK_MESSAGE+=":black_square_for_stop:"
SLACK_MESSAGE+='"}}]}'
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}"