Skip to content

Commit bb9d7ea

Browse files
committed
Extracting unit test error logs for troubleshooting
1 parent d8aeba3 commit bb9d7ea

File tree

4 files changed

+122
-80
lines changed

4 files changed

+122
-80
lines changed

.github/workflows/build-and-test-pr.yml

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test For PR
1+
name: "Build and Test For PR"
22

33
on: [push, pull_request, workflow_dispatch]
44

@@ -16,41 +16,47 @@ env:
1616
spring.version:5.3.24;
1717
spring-boot.version:2.7.6;
1818
'
19+
MAVEN_OPTS: >-
20+
-XX:+UseG1GC
21+
-XX:InitiatingHeapOccupancyPercent=45
22+
-XX:+UseStringDeduplication
23+
-XX:-TieredCompilation
24+
-XX:TieredStopAtLevel=1
1925
2026
jobs:
2127
check-format:
22-
name: Check if code needs formatting
28+
name: "Check if code needs formatting"
2329
runs-on: ubuntu-latest
2430
steps:
25-
- name: Checkout
31+
- name: "Checkout"
2632
uses: actions/checkout@v4
27-
- name: Setup Maven
33+
- name: "Setup Maven"
2834
uses: actions/setup-java@v4
2935
with:
3036
java-version: 21
3137
distribution: zulu
32-
- name: Check if code aligns with code style
38+
- name: "Check if code aligns with code style"
3339
id: check
3440
run: mvn --log-file mvn.log spotless:check
3541
continue-on-error: true
36-
- name: Upload checkstyle result
42+
- name: "Upload checkstyle result"
3743
uses: actions/upload-artifact@v4
3844
with:
3945
name: checkstyle-result
4046
path: mvn.log
41-
- name: Generate Summary for successful run
47+
- name: "Generate Summary for successful run"
4248
if: ${{ steps.check.outcome == 'success' }}
4349
run: |
4450
echo ":ballot_box_with_check: Kudos! No formatting issues found!" >> $GITHUB_STEP_SUMMARY
45-
- name: Generate Summary for failed run
51+
- name: "Generate Summary for failed run"
4652
if: ${{ steps.check.outcome == 'failure' }}
4753
run: |
4854
echo "## :negative_squared_cross_mark: Formatting issues found!" >> $GITHUB_STEP_SUMMARY
4955
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
5056
cat mvn.log | grep "ERROR" | sed 's/Check if code needs formatting Check if code aligns with code style [0-9A-Z:.-]\+//' | sed 's/\[ERROR] //' | head -n -11 >> $GITHUB_STEP_SUMMARY
5157
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
5258
echo "Please run \`mvn spotless:apply\` to fix the formatting issues." >> $GITHUB_STEP_SUMMARY
53-
- name: Fail if code needs formatting
59+
- name: "Fail if code needs formatting"
5460
if: ${{ steps.check.outcome == 'failure' }}
5561
uses: actions/[email protected]
5662
with:
@@ -64,7 +70,7 @@ jobs:
6470
runs-on: ubuntu-latest
6571
steps:
6672
- uses: actions/checkout@v3
67-
- name: Check License
73+
- name: "Check License"
6874
uses: apache/skywalking-eyes@e1a02359b239bd28de3f6d35fdc870250fa513d5
6975
env:
7076
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -76,7 +82,7 @@ jobs:
7682
- name: "Compile Dubbo (Linux)"
7783
run: |
7884
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean install -DskipTests=true -DskipIntegrationTests=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
79-
- name: Check Dependencies' License
85+
- name: "Check Dependencies' License"
8086
uses: apache/skywalking-eyes/dependency@e1a02359b239bd28de3f6d35fdc870250fa513d5
8187
env:
8288
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -91,20 +97,30 @@ jobs:
9197
outputs:
9298
version: ${{ steps.dubbo-version.outputs.version }}
9399
steps:
94-
- uses: actions/checkout@v3
100+
- name: "Checkout code"
101+
uses: actions/checkout@v3
95102
with:
96103
path: dubbo
97-
- uses: actions/setup-java@v3
104+
- name: "Set up JDK"
105+
uses: actions/setup-java@v3
98106
with:
99107
distribution: 'zulu'
100108
java-version: 21
101-
- uses: actions/cache@v3
102-
name: "Cache local Maven repository"
109+
- name: "Set current date as env variable"
110+
run: echo "DATE_NOW=$(date +'%Y%m%d')" >> $GITHUB_ENV
111+
- name: "Restore local Maven repository cache"
112+
uses: actions/cache/restore@v4
113+
id: cache-maven-repository
103114
with:
104115
path: ~/.m2/repository
105-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }}
116+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.DATE_NOW }}
117+
- name: "Restore common local Maven repository cache"
118+
uses: actions/cache/restore@v4
119+
if: steps.cache-maven-repository.outputs.cache-hit != 'true'
120+
with:
121+
path: ~/.m2/repository
122+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
106123
restore-keys: |
107-
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
108124
${{ runner.os }}-maven-
109125
- name: "Dubbo cache"
110126
uses: actions/cache@v3
@@ -114,7 +130,13 @@ jobs:
114130
- name: "Build Dubbo with Maven"
115131
run: |
116132
cd ./dubbo
117-
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean source:jar install -Pjacoco,checkstyle -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.test.skip=true -Dmaven.test.skip.exec=true -DembeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper
133+
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean install -Psources,skip-spotless,checkstyle -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.test.skip=true -Dmaven.test.skip.exec=true -DembeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper
134+
- name: "Save local Maven repository cache"
135+
uses: actions/cache/save@v4
136+
if: steps.cache-maven-repository.outputs.cache-hit != 'true'
137+
with:
138+
path: ~/.m2/repository
139+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.DATE_NOW }}
118140
- name: "Pack class result"
119141
run: |
120142
shopt -s globstar
@@ -128,8 +150,8 @@ jobs:
128150
if: failure()
129151
run: zip ${{ github.workspace }}/checkstyle.zip *checkstyle* -r
130152
- name: "Upload checkstyle file if failure"
131-
if: failure()
132153
uses: actions/upload-artifact@v3
154+
if: failure()
133155
with:
134156
name: "checkstyle-file"
135157
path: ${{ github.workspace }}/checkstyle.zip
@@ -149,17 +171,17 @@ jobs:
149171
env:
150172
ZOOKEEPER_VERSION: 3.6.3
151173
steps:
152-
- uses: actions/cache@v3
153-
name: "Cache zookeeper binary archive"
174+
- name: "Cache zookeeper binary archive"
175+
uses: actions/cache@v3
154176
id: "cache-zookeeper"
155177
with:
156178
path: ${{ github.workspace }}/.tmp/zookeeper
157179
key: zookeeper-${{ runner.os }}-${{ env.ZOOKEEPER_VERSION }}
158180
restore-keys: |
159181
zookeeper-${{ runner.os }}-${{ env.ZOOKEEPER_VERSION }}
160182
- name: "Set up msys2 if necessary"
161-
if: ${{ startsWith( matrix.os, 'windows') && steps.cache-zookeeper.outputs.cache-hit != 'true' }}
162183
uses: msys2/setup-msys2@v2
184+
if: ${{ startsWith( matrix.os, 'windows') && steps.cache-zookeeper.outputs.cache-hit != 'true' }}
163185
with:
164186
release: false # support cache, see https://github.com/msys2/setup-msys2#context
165187
- name: "Download zookeeper binary archive in Linux OS"
@@ -184,24 +206,27 @@ jobs:
184206
DISABLE_FILE_SYSTEM_TEST: true
185207
CURRENT_ROLE: ${{ matrix.case-role }}
186208
steps:
187-
- uses: actions/checkout@v3
209+
- name: "Checkout code"
210+
uses: actions/checkout@v3
188211
with:
189212
fetch-depth: 0
190213
- name: "Set up JDK ${{ matrix.jdk }}"
191214
uses: actions/setup-java@v3
192215
with:
193216
distribution: 'zulu'
194217
java-version: 21
195-
- uses: actions/cache@v3
196-
name: "Cache local Maven repository"
218+
- name: "Set current date as env variable"
219+
run: echo "DATE_NOW=$(date +'%Y%m%d')" >> $GITHUB_ENV
220+
- name: "Cache local Maven repository"
221+
uses: actions/cache@v3
197222
with:
198223
path: ~/.m2/repository
199-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }}
224+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.DATE_NOW }}
200225
restore-keys: |
201226
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
202227
${{ runner.os }}-maven-
203-
- uses: actions/cache@v3
204-
name: "Cache zookeeper binary archive"
228+
- name: "Cache zookeeper binary archive"
229+
uses: actions/cache@v3
205230
id: "cache-zookeeper"
206231
with:
207232
path: ${{ github.workspace }}/.tmp/zookeeper
@@ -211,7 +236,11 @@ jobs:
211236
- name: "Test with Maven"
212237
timeout-minutes: 90
213238
run: |
214-
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Pjacoco,jdk15ge-simple,'!jdk15ge',jacoco089 -DtrimStackTrace=false -Dmaven.wagon.http.retryHandler.count=5 -DskipTests=false -DskipIntegrationTests=false -Dcheckstyle.skip=false -Dcheckstyle_unix.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true -DembeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper
239+
set -o pipefail
240+
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast clean test verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Pjacoco,jdk15ge-simple,'!jdk15ge',jacoco089 -DtrimStackTrace=false -Dmaven.wagon.http.retryHandler.count=5 -DskipTests=false -DskipIntegrationTests=false -Dcheckstyle.skip=false -Dcheckstyle_unix.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true -DembeddedZookeeperPath=${{ github.workspace }}/.tmp/zookeeper 2>&1 | tee >(grep -n -B 1 -A 200 "FAILURE! -- in" > test_errors.log)
241+
- name: "Print test error log"
242+
if: failure()
243+
run: cat test_errors.log
215244
- name: "Upload coverage result"
216245
uses: actions/upload-artifact@v3
217246
with:
@@ -253,11 +282,13 @@ jobs:
253282
with:
254283
repository: 'apache/dubbo-samples'
255284
ref: master
285+
- name: "Set current date as env variable"
286+
run: echo "DATE_NOW=$(date +'%Y%m%d')" >> $GITHUB_ENV
256287
- name: "Cache local Maven repository"
257288
uses: actions/cache@v3
258289
with:
259290
path: ~/.m2/repository
260-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }}
291+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.DATE_NOW }}
261292
restore-keys: |
262293
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
263294
${{ runner.os }}-maven-
@@ -357,11 +388,13 @@ jobs:
357388
with:
358389
repository: 'apache/dubbo-integration-cases'
359390
ref: main
391+
- name: "Set current date as env variable"
392+
run: echo "DATE_NOW=$(date +'%Y%m%d')" >> $GITHUB_ENV
360393
- name: "Cache local Maven repository"
361394
uses: actions/cache@v3
362395
with:
363396
path: ~/.m2/repository
364-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.run_id }}
397+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.DATE_NOW }}
365398
restore-keys: |
366399
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
367400
${{ runner.os }}-maven-
@@ -558,9 +591,12 @@ jobs:
558591
559592
- name: "Compile and run Dubbo demo for native (Linux)"
560593
run: |
561-
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider
562-
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true native:compile
594+
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface
595+
MVNW="${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C -Dmaven.test.skip=true"
596+
$MVNW clean install
597+
cd ../dubbo-demo-native-provider
598+
$MVNW clean package -P native native:compile
563599
nohup ./target/dubbo-demo-native-provider &
564-
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer
565-
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true native:compile
600+
cd ../dubbo-demo-native-consumer
601+
$MVNW clean package -P native native:compile
566602
./target/dubbo-demo-native-consumer

build

100644100755
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ print_help() {
5050
echo "Fast local compilation with incremental build and caching"
5151
echo "Options:"
5252
echo " -c Execute clean goal (removes build artifacts)"
53-
echo " -i Execute install goal (builds and installs the project)"
5453
echo " -p Execute compile goal (compiles the source code)"
54+
echo " -i Execute install goal (builds and installs the project)"
5555
echo " -t Execute test goal (runs the tests)"
5656
echo " -s Execute spotless:apply (format the code)"
5757
echo " -d Execute dependency:tree (displays the dependency tree)"
@@ -60,38 +60,40 @@ print_help() {
6060
echo " -h Display this help message"
6161
echo ""
6262
echo "Examples:"
63-
echo " $0 -ci Execute clean, install goals"
63+
echo " $0 Execute install goal compilation"
64+
echo " $0 -m Execute a minimal compilation"
65+
echo " $0 -ci Execute clean, install goals compilation"
6466
echo " $0 -s Execute spotless:apply"
67+
echo " $0 -d Display the dependency tree"
6568
echo " $0 -t -m dubbo-config Execute test goal for dubbo-config module"
6669
echo " $0 -cp -m dubbo-common Execute clean, compile the dubbo-common module"
67-
echo " $0 -d Display the dependency tree"
6870
exit 0
6971
}
7072

71-
while getopts ":ciptdsm:f:h" opt; do
73+
while getopts ":cpitstdm:f:h" opt; do
7274
case $opt in
7375
c)
7476
ARGS="$ARGS clean"
7577
;;
76-
i)
77-
ARGS="$ARGS install"
78-
;;
7978
p)
8079
ARGS="$ARGS compile"
8180
;;
81+
i)
82+
ARGS="$ARGS install"
83+
;;
8284
t)
8385
ARGS="$ARGS test"
8486
export MAVEN_OPTS=$(echo "$MAVEN_OPTS" | sed 's/-Dmaven\.test\.skip=true/-Dmaven.test.skip=false/')
8587
;;
86-
d)
87-
ARGS="$ARGS dependency:tree"
88-
;;
8988
s)
9089
ARGS="$ARGS spotless:apply"
9190
PROFILES="sources"
9291
;;
92+
d)
93+
ARGS="$ARGS dependency:tree"
94+
;;
9395
m)
94-
MODULES="-pl $OPTARG -am"
96+
MODULES=" -pl $OPTARG -am"
9597
;;
9698
f)
9799
PROFILES="$OPTARG"
@@ -103,23 +105,15 @@ while getopts ":ciptdsm:f:h" opt; do
103105
if [ "$OPTARG" = "m" ]; then
104106
MODULES=" -pl $DEFAULT_MODULES -am"
105107
else
106-
echo "Error: Unknown option -$OPTARG" >&2
107-
print_help
108-
exit 1
108+
ARGS="$ARGS $@"
109109
fi
110110
;;
111111
esac
112112
done
113113

114-
shift $((OPTIND -1))
115-
116-
if [ -z "$ARGS" ] && [ -z "$@" ]; then
117-
ARGS="install"
118-
fi
119-
120-
if [ -n "$@" ]; then
121-
ARGS="$ARGS $@"
114+
if [ -z "$ARGS" ] ; then
115+
ARGS=" install"
122116
fi
123117

124118
set -x
125-
$CMD $ARGS$MODULES -P $PROFILES
119+
$CMD$ARGS$MODULES -P $PROFILES

0 commit comments

Comments
 (0)