-
Notifications
You must be signed in to change notification settings - Fork 0
264 lines (228 loc) · 7.88 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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: Project CI
on:
push:
branches:
- '*'
- '*/*'
- '**'
tags-ignore:
- '**'
jobs:
cancel-prev-runs:
name: Cancel Previous Runs
runs-on: ubuntu-latest
steps:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
validate:
name: Validate Code
runs-on: ubuntu-latest
needs:
- cancel-prev-runs
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/cache@v2
with:
path: |
~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-test-
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Code Validation
run: mvn -B validate --file pom.xml
- name: Archive CycloneDX
uses: actions/upload-artifact@v2
with:
name: cyclone
path: target/bom.json
retention-days: 5
- name: Code Compilation
run: mvn -B clean compile --file pom.xml
- name: Checkstyle
run: mvn -B checkstyle:checkstyle -Dcheckstyle.skip=false --file pom.xml
- name: Archive Checkstyle
uses: actions/upload-artifact@v2
with:
name: checkstyle
path: target/site/checkstyle.html
retention-days: 5
test:
name: Test Code
runs-on: ubuntu-latest
needs:
- validate
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/cache@v2
with:
path: |
~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-test-
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Unit Tests
run: mvn -B test --file pom.xml
- name: Integration Tests
run: mvn -B verify -P integration-test --file pom.xml
- name: Code Coverage
run: mvn -B clean verify -P all-tests --file pom.xml
- name: Check Run Report
uses: check-run-reporter/action@v2.11.1
with:
token: ${{ secrets.CHECK_RUN_REPORTER_TOKEN }}
report: 'target/**/TEST-*.xml'
- name: Report results to DeepSource
if: ${{ always() }}
run: |
curl https://deepsource.io/cli | sh
./bin/deepsource report --analyzer test-coverage --key java --value-file ./target/coverage-reports/merged-test-report/jacoco.xml
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
id: jacoco
with:
generate-branches-badge: true
jacoco-csv-file: target/coverage-reports/merged-test-report/jacoco.csv
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit the badge (if it changed)
run: |
if [[ `git status --porcelain` ]]; then
git config --global user.name 'CI Bot'
git config --global user.email 'cibot@users.noreply.github.com'
git add -A
git commit -m "ci: autogenerated JaCoCo coverage badge"
git push
fi
- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v2
with:
name: jacoco-report
path: target/coverage-reports/merged-test-report/
- name: Qualitygate
run: mvn -B clean verify -P all-tests package sonar:sonar -Dsonar.projectKey=paulushcgcj_database-evo -Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml --file pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
security:
name: Security checks
runs-on: ubuntu-latest
permissions:
security-events: write
needs:
- validate
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/cache@v2
with:
path: |
~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-test-
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: java
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Code Compilation
run: mvn -B clean compile --file pom.xml
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/maven@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high --sarif-file-output=snyk.sarif
release:
name: Release
runs-on: ubuntu-latest
if: github.ref_name == 'main'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/cache@v2
with:
path: |
~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-test-
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Backing up Changelog
run: |
mv CHANGELOG.md OLD.CHANGELOG.md
touch CHANGELOG.md
- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v3
id: changelog
with:
github-token: ${{ github.token }}
output-file: 'CHANGELOG.md'
skip-version-file: 'true'
skip-commit: 'true'
git-push: 'false'
- name: Set new version
run: mvn versions:set -DnewVersion='${{ steps.changelog.outputs.version }}' -f pom.xml -DskipTests -Dtests.skip=true -Dskip.unit.tests=true
- name: Update POM
run: mvn versions:commit
- name: Updating Compose version
run: sed -i -E "s/DBEVO=.*/DBEVO=${{ steps.changelog.outputs.version }}/g" docs/environment/.env
- name: Merging Changelog
run: |
mv CHANGELOG.md RELEASE.md
cat RELEASE.md OLD.CHANGELOG.md > CHANGELOG.md
- name: Update resources
uses: test-room-7/action-update-file@v1
with:
file-path: |
pom.xml
CHANGELOG.md
docs/environment/.env
commit-msg: "doc: updating pom to ${{ steps.changelog.outputs.version }} [ci skip]"
github-token: ${{ secrets.PAT }}
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}