Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(ci): compute shard.txt before Compile so the image prefetch overlaps compilation (#4026)

Matheus André5fbaab1cca3e
diff --git a/.github/ci/prefetch-images.sh b/.github/ci/prefetch-images.sh
index 4819f01f0c..af76a179fa 100755
--- a/.github/ci/prefetch-images.sh
+++ b/.github/ci/prefetch-images.sh
@@ -7,7 +7,7 @@
set -u
SHARD_FILE="${1:-}"
command -v docker >/dev/null 2>&1 || exit 0
-[ -r "$SHARD_FILE" ] || exit 0
+[ -r "$SHARD_FILE" ] || { echo "prefetch-images: ${SHARD_FILE:-<none>} not readable, nothing prefetched" >&2; exit 0; }
pull() { docker pull -q "$1" >/dev/null 2>&1 & }
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6eab5a47ca..bd721a1657 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -58,19 +58,16 @@ jobs:
restore-keys: |
maven-${{ runner.os }}-
- - name: Prefetch this shard's Docker images (background)
- run: .github/ci/prefetch-images.sh shard.txt || true
-
- - name: Compile
- run: ./mvnw test-compile -B
-
+ # Derived from test sources, not target/test-classes, so shard.txt exists
+ # before Compile and the image prefetch below overlaps the compile instead
+ # of starting moments before the tests that need the images. Every test is
+ # a top-level class in src/test/java, so the file name is the class name.
- name: Compute shard include list
run: |
- cd target/test-classes
- find . \( -name '*Test.class' -o -name 'Test*.class' \
- -o -name '*Tests.class' -o -name '*TestCase.class' \) \
- ! -name '*$*' \
- | sed 's|^\./||; s|\.class$||' | LC_ALL=C sort \
+ cd src/test/java
+ find . \( -name '*Test.java' -o -name 'Test*.java' \
+ -o -name '*Tests.java' -o -name '*TestCase.java' \) \
+ | sed 's|^\./||; s|\.java$||' | LC_ALL=C sort \
> "$GITHUB_WORKSPACE/all-classes.txt"
cd "$GITHUB_WORKSPACE"
.github/ci/partition.sh all-classes.txt "$SHARD_TOTAL" "${{ matrix.shard }}" > shard.txt
@@ -78,7 +75,12 @@ jobs:
# and run the ENTIRE suite into this shard's timeout.
test -s shard.txt
echo "shard ${{ matrix.shard }}/$SHARD_TOTAL: $(wc -l < shard.txt) classes"
- .github/ci/prefetch-images.sh shard.txt || true
+
+ - name: Prefetch this shard's Docker images (background)
+ run: .github/ci/prefetch-images.sh shard.txt || true
+
+ - name: Compile
+ run: ./mvnw test-compile -B
- name: Run tests
run: >