Repository navigation
194 lines (175 loc) · 6.51 KB
/
Copy pathunit-test.yml
File metadata and controls
194 lines (175 loc) · 6.51 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
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Test
on:
workflow_dispatch:
pull_request:
concurrency:
group: unit-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
paths-filter:
name: Unit-Test-Path-Filter
runs-on: ubuntu-24.04
outputs:
not-ignore: ${{ steps.filter.outputs.not-ignore }}
steps:
- uses: actions/checkout@v6
with:
submodules: true
- uses: ./.github/actions/paths-filter
id: filter
with:
filters: |
not-ignore:
- '!(docs/**)'
sanity-check:
name: Sanity Check
runs-on: ubuntu-24.04
needs: paths-filter
if: ${{ needs.paths-filter.outputs.not-ignore == 'true' }}
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Cache Maven Wrapper
uses: actions/cache@v5
with:
path: ~/.m2/wrapper
key: ${{ runner.os }}-mvnw-${{ hashFiles('.mvn/wrapper/maven-wrapper.properties') }}
- name: Sanity Check
uses: ./.github/actions/sanity-check
with:
token: ${{ secrets.GITHUB_TOKEN }}
generate-matrix:
name: Generate Module Matrix
runs-on: ubuntu-24.04
needs: paths-filter
if: ${{ needs.paths-filter.outputs.not-ignore == 'true' }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v6
- name: Parse modules from pom.xml
id: set-matrix
run: |
MODULES=$(python3 - <<'EOF'
import xml.etree.ElementTree as ET, json, re
tree = ET.parse('pom.xml')
ns = {'m': 'http://maven.apache.org/POM/4.0.0'}
root = tree.getroot()
# Support both namespaced and non-namespaced pom.xml
modules = root.findall('.//m:modules/m:module', ns)
if not modules:
modules = root.findall('.//modules/module')
# Exclude aggregator-only or non-testable modules
exclude = re.compile(r'dolphinscheduler-bom|dolphinscheduler-dist|dolphinscheduler-microbench|dolphinscheduler-ui')
result = [m.text.strip() for m in modules if m.text and not exclude.search(m.text)]
print(json.dumps(result))
EOF
)
echo "matrix={\"module\":$MODULES}" >> "$GITHUB_OUTPUT"
echo "Discovered modules: $MODULES"
unit-test:
name: Unit-Test (${{ matrix.module }} | Java ${{ matrix.java }})
needs: [ paths-filter, generate-matrix, sanity-check ]
if: ${{ needs.paths-filter.outputs.not-ignore == 'true' }}
runs-on: ubuntu-24.04
strategy:
matrix:
java: [ '8', '11' ]
module: ${{ fromJSON(needs.generate-matrix.outputs.matrix).module }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Collect Workflow Metrics
uses: ./.github/actions/actions-workflow-metrics
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Cache Maven Wrapper
uses: actions/cache@v5
with:
path: ~/.m2/wrapper
key: ${{ runner.os }}-mvnw-${{ hashFiles('.mvn/wrapper/maven-wrapper.properties') }}
- uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-backend
restore-keys: ${{ runner.os }}-maven-
# Install the target module and its upstream dependencies into the local
# Maven repository without running tests. Use skipTests instead of
# maven.test.skip so packaging still sees provided-scope dependencies and
# attaches any test/provided artifacts required by downstream modules.
- name: Install Dependencies (${{ matrix.module }})
run: |
export MAVEN_OPTS="-Xmx14g -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=1024m"
./mvnw install -B \
-pl "dolphinscheduler-bom,${{ matrix.module }}" \
-am \
-DskipTests=true \
-Dspotless.skip=true \
-DskipUT=true \
-Djacoco.skip=true \
-Danalyze.skip=true
# Verify only the target module. Do not use -am here, otherwise Maven
# will run the verify lifecycle for dependency modules too.
- name: Run Unit Tests (${{ matrix.module }})
run: |
export MAVEN_OPTS="-Xmx14g -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=1024m"
./mvnw verify -B \
-pl "${{ matrix.module }}" \
-Dmaven.test.skip=false \
-Dspotless.skip=true \
-DskipUT=false \
-Danalyze.skip=true \
-Dsurefire.printSummary=true \
-Dsurefire.useFile=false \
-Dsurefire.reportFormat=plain \
-Dsurefire.redirectTestOutputToFile=false
- name: Upload surefire reports
uses: actions/upload-artifact@v6
if: always()
with:
name: surefire-java${{ matrix.java }}-${{ matrix.module }}
path: '**/target/surefire-reports/'
retention-days: 7
result:
name: Unit Test
runs-on: ubuntu-24.04
timeout-minutes: 5
needs: [ unit-test, paths-filter, sanity-check ]
if: always()
steps:
- name: Status
run: |
if [[ ${{ needs.paths-filter.outputs.not-ignore }} == 'false' && ${{ github.event_name }} == 'pull_request' ]]; then
echo "Skip Unit Test!"
exit 0
fi
if [[ ${{ needs.sanity-check.result }} != 'success' ]]; then
echo "Sanity Check Failed!"
exit -1
fi
if [[ ${{ needs.unit-test.result }} != 'success' ]]; then
echo "Unit Test Failed!"
exit -1
fi