-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (187 loc) · 8.15 KB
/
code-maven_java-QA_integration.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
---
# The name of the workflow
name: code-maven-QA-integration
# The name of the workflow run
run-name: "${{ github.workflow }}-[${{ github.head_ref || github.ref_name }}]=>[${{ github.base_ref }}]"
# Concurrency configuration
concurrency:
# The concurrency group for this workflow
group: "${{ github.workflow }}-[${{ github.head_ref || github.ref_name }}]=>[${{ github.base_ref }}]"
# Cancel all previous runs in progress
cancel-in-progress: true
# Events that trigger the workflow
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
INTEGRATION_COVERAGE_THRESHOLD:
description: |
The minimum coverage threshold to pass the integration tests, for example 80
'DEFAULT' uses the value set in github_config.yml "integration.coverage.threshold".
required: false
default: DEFAULT
# Automatically run the workflow on pull_request events
pull_request:
types: [ opened, edited, labeled, synchronize, ready_for_review, reopened ]
paths:
- 'code/**'
- '.github/workflows/code*'
# Environment variables available to all jobs and steps in this workflow
env:
WORKFLOW_VERSION: 1.0.0
MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# integration-tests
integration-tests:
# The name of the job
name: integration-tests
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Conditions to run the job
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# checkout
- name: checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# config
- name: config
id: config
uses: ./.github/actions/config-resolver
with:
create-annotations: true
files: |
github_config.yml
input-vars: "${{ toJSON(github.event.inputs) }}" # it injects all workflows inputs
# setup-maven-cache
- name: setup-maven-cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# setup-asdf-cache
- name: setup-asdf-cache
uses: actions/cache@v4
continue-on-error: true
with:
path: ~/.asdf/data
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-
# save-tool-versions-content
- name: save-tool-versions-content
run: |
{
echo "TOOL_VERSIONS<<EOF"
cat code/.tool-versions
echo "EOF"
} >> "$GITHUB_ENV"
# asdf-install
- name: asdf-install
id: asdf-install
uses: asdf-vm/actions/install@v3
with:
tool_versions: ${{ env.TOOL_VERSIONS }}
# set-java-home
- name: set-java-home
id: set-java-home
run: |
# set-java-home
echo "::group::+++ set-java-home +++"
# Set JAVA_HOME
JAVA_HOME="$(asdf where java)"
echo "JAVA_HOME=$JAVA_HOME"
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "::endgroup::"
# mvn-clean-verify
- name: mvn-clean-verify
id: mvn-clean-verify
working-directory: code
run: |
# mvn-clean-verify
echo "::group::+++ mvn-clean-verify +++"
# Maven Properties
MVN_PROPERTIES="-DskipUTs -DfailIfNoTests=false -Dmaven.test.failure.ignore=false"
# if: github.event_name == 'release' add -DskipEnforceSnapshots
if [[ -n "${{ github.event.release.tag_name }}" ]]; then
MVN_PROPERTIES="$MVN_PROPERTIES -DskipEnforceSnapshots"
fi
echo "MVN_PROPERTIES=${MVN_PROPERTIES}"
# mvn clean verify
mvn -B -ntp clean verify $MVN_PROPERTIES
echo "::endgroup::"
# mvn-failsafe-report
- name: mvn-failsafe-report
id: mvn-failsafe-report
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
working-directory: code
run: |
# mvn-failsafe-report
echo "::group::+++ mvn-failsafe-report +++"
# mvn surefire-report:failsafe-report-only
mvn -B -ntp surefire-report:failsafe-report-only -DalwaysGenerateSurefireReport=true
echo "::endgroup::"
# failsafe-results-verification
- name: failsafe-results-verification
id: failsafe-results-verification
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: ./.github/actions/test-results-verification
with:
# type: The type of results. Supported types: 'surefire', 'failsafe', 'jacoco', 'karate' and 'pitest'.
type: failsafe
# results_folder: The folder of the results. For example:
# 'surefire/failsafe': code/target/reports
# 'jacoco': code/jacoco-report-aggregate/target/site/jacoco-aggregate or code/jacoco-report-aggregate/target/site/jacoco-aggregate-it
# 'pitest': code/target/pit-reports
# 'karate': e2e/karate/target/karate-reports
results_folder: ${{ fromJSON(steps.config.outputs.config).integration.report.folder }}
# threshold: the threshold to verify, For example: 'coverage %' for 'jacoco' and 'pitest', 'success rate %' for 'surefire', 'failsafe' and 'karate'
threshold: 100
# failsafe-report-upload
- name: failsafe-report-upload
id: failsafe-report-upload
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-integration-${{ github.run_number }}-failsafe-report
path: ${{ fromJSON(steps.config.outputs.config).integration.report.folder }}
# jacoco-results-verification
- name: jacoco-results-verification
id: jacoco-results-verification
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: ./.github/actions/test-results-verification
with:
# type: The type of results. Supported types: 'surefire', 'failsafe', 'jacoco', 'karate' and 'pitest'.
type: jacoco
# results_folder: The folder of the results. For example:
# 'surefire/failsafe': code/target/reports
# 'jacoco': code/jacoco-report-aggregate/target/site/jacoco-aggregate or code/jacoco-report-aggregate/target/site/jacoco-aggregate-it
# 'pitest': code/target/pit-reports
# 'karate': e2e/karate/target/karate-reports
results_folder: ${{ fromJSON(steps.config.outputs.config).integration.jacoco.report.folder }}
# threshold: the threshold to verify, For example: 'coverage %' for 'jacoco' and 'pitest', 'success rate %' for 'surefire', 'failsafe' and 'karate'
threshold: ${{ fromJSON(steps.config.outputs.config).integration.coverage.threshold || 80 }}
# jacoco-report-upload
- name: jacoco-report-upload
id: jacoco-report-upload
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-integration-${{ github.run_number }}-jacoco-report
path: ${{ fromJSON(steps.config.outputs.config).integration.jacoco.report.folder }}
# execution-logs-upload
- name: execution-logs-upload
id: execution-logs-upload
if: ${{ always() && !cancelled() && steps.mvn-clean-verify.conclusion != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-karate-${{ github.run_number }}-logs
path: |
code/**/*.log