-
Notifications
You must be signed in to change notification settings - Fork 2
213 lines (188 loc) · 6.74 KB
/
main.yml
File metadata and controls
213 lines (188 loc) · 6.74 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: BUILD
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
analysis-kibit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting for sonar
fetch-depth: 0
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache local Maven repository
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Sonar Scanner
uses: warchant/setup-sonar-scanner@v3
with:
version: 4.6.2.2472
- name: Run Sonar Scanner
env:
# provide GITHUB_TOKEN to get access to secrets.SONAR_TOKEN
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: code
run: |
export JAVA_OPTS="-Xms6g -Xmx6g"
export ES_JAVA_OPTS="-Xms6g -Xmx6g"
sonar-scanner -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} -Dsonar.clojure.kibit.enabled=true
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@v1.0.0
# Force to fail step after specific time
timeout-minutes: 5
with:
scanMetadataReportFile: code/.scannerwork/report-task.txt
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
analysis-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting for sonar
fetch-depth: 0
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache local Maven repository
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Sonar Scanner
uses: warchant/setup-sonar-scanner@v3
with:
version: 4.6.2.2472
- name: Run Sonar Scanner
env:
# provide GITHUB_TOKEN to get access to secrets.SONAR_TOKEN
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: code
run: |
export JAVA_OPTS="-Xms5g -Xmx5g"
export ES_JAVA_OPTS="-Xms5g -Xmx5g"
sonar-scanner -Dsonar.login=${{ secrets.SONAR_TOKEN }} -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} -Dsonar.clojure.cloverage.enabled=true -Dsonar.clojure.nvd.enabled=true -Dsonar.clojure.ancient.enabled=true
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@v1.0.0
# Force to fail step after specific time
timeout-minutes: 5
with:
scanMetadataReportFile: code/.scannerwork/report-task.txt
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Get list of tests
if: always()
id: tests
uses: Rishabh510/Path-lister-action@master
with:
path: "code/test-reports"
type: ".xml"
- name: Fail on failed tests
if: always()
run: |
sudo apt-get install -y libxml2-utils
echo "Found ${{ steps.tests.outputs.path_count }} test report(s)"
if [[ ${{ steps.tests.outputs.path_count }} < 1 ]]; then
echo "ERROR: No unit test reports collected."
exit 1
fi
for f in ${{ steps.tests.outputs.paths }}; do
echo "=== $f ==="
if [[ $(xmllint --xpath "string(//testsuite/@failures)" $f) > 1 ]]; then
echo TEST FAILED: $f
exit 1
fi
if [[ $(xmllint --xpath "string(//testsuite/@errors)" $f) > 1 ]]; then
echo TEST ERRORED: $f
exit 1
fi
done
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@v1.0.0
# Force to fail step after specific time
timeout-minutes: 5
with:
scanMetadataReportFile: code/.scannerwork/report-task.txt
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: code/test-reports/TEST-*.xml
build-deploy:
runs-on: ubuntu-latest
needs:
- analysis-coverage
- analysis-kibit
steps:
- uses: actions/checkout@v2
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache local Maven repository
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: s4u/maven-settings-action@v2.2.0
with:
githubServer: false
override: true
servers: |
[{
"id": "docker.io",
"username": "${{ secrets.SIXSQ_DOCKER_USERNAME }}",
"password": "${{ secrets.SIXSQ_DOCKER_PASSWORD }}"
}]
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
id: extract_branch
- name: Build with Maven
env:
TRAVIS_BRANCH: ${{ steps.extract_branch.outputs.branch }}
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.head_ref }}
TRAVIS_BUILD_NUMBER: ${{ github.run_id }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SIXSQ_DOCKER_USERNAME: ${{ secrets.SIXSQ_DOCKER_USERNAME }}
SIXSQ_DOCKER_PASSWORD: ${{ secrets.SIXSQ_DOCKER_PASSWORD }}
run: mvn deploy -DskipTests=true
job-notify:
if: always()
name: Post Workflow Status To Slack
needs:
- build-deploy
runs-on: ubuntu-latest
steps:
- uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}}