Skip to content

Commit d61b036

Browse files
Fix flaky static analysis tests with retry mechanisms and improved CI configuration
Co-authored-by: yutaro-sakamoto <80912876+yutaro-sakamoto@users.noreply.github.com>
1 parent 2b428bb commit d61b036

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

.github/workflows/static-analysis.yml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,75 @@ jobs:
2222

2323
- name: Install static analysis tools
2424
run: |
25-
dnf update -y
26-
dnf install -y epel-release
27-
dnf install -y gcc make bison flex automake autoconf diffutils gettext java-21-openjdk-devel git-clang-format cppcheck
25+
# Add retry logic for package installation to handle transient network issues
26+
for i in {1..3}; do
27+
if dnf update -y && dnf install -y epel-release && dnf install -y gcc make bison flex automake autoconf diffutils gettext java-21-openjdk-devel git-clang-format cppcheck; then
28+
break
29+
elif [ $i -eq 3 ]; then
30+
echo "Package installation failed after 3 attempts"
31+
exit 1
32+
else
33+
echo "Package installation attempt $i failed, retrying..."
34+
sleep 30
35+
dnf clean all
36+
fi
37+
done
2838
2939
- name: Install opensource COBOL 4J
3040
run: |
31-
./configure --prefix=/usr/
32-
make
33-
make install
41+
# Add retries for build and install to handle transient failures
42+
for i in {1..2}; do
43+
if ./configure --prefix=/usr/ && make && make install; then
44+
break
45+
elif [ $i -eq 2 ]; then
46+
echo "Build and install failed after 2 attempts"
47+
exit 1
48+
else
49+
echo "Build and install attempt $i failed, retrying..."
50+
make clean || true
51+
sleep 10
52+
fi
53+
done
3454
3555
- name: Check format with google-java-format and clang-format
3656
run: |
37-
./check-format
57+
# Add timeout and make format checking more robust
58+
timeout 300 ./check-format
3859
3960
- name: Run SpotBugs
4061
working-directory: libcobj
4162
run: |
42-
./gradlew spotbugsMain
63+
# Use --no-daemon to avoid daemon conflicts in CI and add retries for reliability
64+
for i in {1..3}; do
65+
if ./gradlew spotbugsMain --no-daemon --console=plain; then
66+
break
67+
elif [ $i -eq 3 ]; then
68+
echo "SpotBugs failed after 3 attempts"
69+
exit 1
70+
else
71+
echo "SpotBugs attempt $i failed, retrying..."
72+
sleep 10
73+
fi
74+
done
4375
4476
- name: Run PMD
4577
working-directory: libcobj
4678
run: |
47-
./gradlew pmdMain
79+
# Use --no-daemon to avoid daemon conflicts in CI and add retries for reliability
80+
for i in {1..3}; do
81+
if ./gradlew pmdMain --no-daemon --console=plain; then
82+
break
83+
elif [ $i -eq 3 ]; then
84+
echo "PMD failed after 3 attempts"
85+
exit 1
86+
else
87+
echo "PMD attempt $i failed, retrying..."
88+
sleep 10
89+
fi
90+
done
4891
4992
- name: Run cppcheck
5093
working-directory: cobj
5194
run: |
52-
./cpp-check
95+
# Add timeout to prevent hanging
96+
timeout 300 ./cpp-check

libcobj/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Configuration for CI environments to improve reliability
2+
org.gradle.daemon=false
3+
org.gradle.parallel=false
4+
org.gradle.configureondemand=false
5+
org.gradle.caching=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
4-
networkTimeout=10000
4+
networkTimeout=60000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
77
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)