Skip to content

Commit 2ca3ca1

Browse files
authored
CI - Add retries for Maven central download errors (#3478)
1 parent a74e963 commit 2ca3ca1

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,22 @@ jobs:
8686
- name: Set Scala version
8787
run: ./build/scripts/change-scala-version.sh ${{ matrix.scala-version }}
8888
- name: Build with Maven
89-
run: mvn $MAVEN_COMPILE_ARGS $MAVEN_CLI_OPTS -am -pl ${{ matrix.projects.list }}
89+
id: compile
90+
continue-on-error: true
91+
run: |
92+
set -o pipefail
93+
mvn $MAVEN_COMPILE_ARGS $MAVEN_CLI_OPTS -am -pl ${{ matrix.projects.list }} | tee -a build.log
94+
- name: Build with Maven (retry)
95+
if: steps.compile.outcome=='failure'
96+
run: |
97+
set -o pipefail
98+
# retry if the failure was due to transient download errors from maven central
99+
if [[ grep -q 'Could not transfer artifact .* from/to central' build.log ]]; then
100+
RESUME_FROM="$({ grep --text 'mvn <args> -rf ' build.log || test $? = 1; } | tail -n1 | sed 's/.*-rf/-rf/')"
101+
mvn $MAVEN_COMPILE_ARGS $MAVEN_CLI_OPTS -am -pl ${{ matrix.projects.list }} $RESUME_FROM | tee -a build.log
102+
else
103+
exit 1
104+
fi
90105
- name: Unit tests
91106
id: test
92107
continue-on-error: true
@@ -100,14 +115,7 @@ jobs:
100115
run: |
101116
set -o pipefail
102117
RESUME_FROM="$({ grep --text 'mvn <args> -rf ' test.log || test $? = 1; } | tail -n1 | sed 's/.*-rf/-rf/')"
103-
mvn $MAVEN_TEST_ARGS $MAVEN_CLI_OPTS $RESUME_FROM -pl ${{ matrix.projects.list }} | tee -a test.log
104-
- name: Unit tests (retry)
105-
id: test-retry-retry
106-
if: steps.test-retry.outcome=='failure'
107-
run: |
108-
set -o pipefail
109-
RESUME_FROM="$({ grep --text 'mvn <args> -rf ' test.log || test $? = 1; } | tail -n1 | sed 's/.*-rf/-rf/')"
110-
mvn $MAVEN_TEST_ARGS $MAVEN_CLI_OPTS $RESUME_FROM -pl ${{ matrix.projects.list }} | tee -a test.log
118+
mvn $MAVEN_TEST_ARGS $MAVEN_CLI_OPTS -pl ${{ matrix.projects.list }} $RESUME_FROM | tee -a test.log
111119
- name: Remove geomesa artifacts
112120
if: success() || failure()
113121
run: rm -rf ~/.m2/repository/org/locationtech/geomesa

0 commit comments

Comments
 (0)