From 2d3fa5cd86a242f8b5f0da3be1a776cd26e8c49c Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Mon, 16 Nov 2026 08:39:28 -0400 Subject: [PATCH] ci: run the checks too heavy for a pull request nightly (#8574) Some checks need images of several gigabytes or long runs: an EMR Serverless run on a custom image pushed to Floci's ECR copies the whole 3.5 GB base image into the registry on every run, and Floci running in a container with an EMR cluster beside it needs the Floci image built first. Every *Test class lands in one of the five CI shards, already close to their time limit, so these have had no place to run. The Nightly checks workflow runs the classes named *NightlyIntegrationTest with -Dfloci.nightly=true: once a day on main, on demand, and on a pull request that adds or changes one, so a check is seen to pass before it merges. Each such class skips without the property, which keeps the shards' cost at a skip. It frees the runner's unused toolchains for the images, prefetches them through prefetch-images.sh, and uploads the reports. GitHub-hosted runners only. A nightly check keys its images in prefetch-images.sh on its own name, and ci.yml hands the prefetch its shard's classes without the nightly ones, so a shard never pulls an image for a check that skips there. AGENTS.md names the convention. --- .github/ci/prefetch-images.sh | 2 + .github/workflows/ci.yml | 7 +- .github/workflows/nightly-checks.yml | 114 +++++++++++++++++++++++++++ AGENTS.md | 5 ++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/nightly-checks.yml diff --git a/.github/ci/prefetch-images.sh b/.github/ci/prefetch-images.sh index 2edb88e426..9efb2cccb0 100755 --- a/.github/ci/prefetch-images.sh +++ b/.github/ci/prefetch-images.sh @@ -13,6 +13,8 @@ # so a test that pulled the image itself can be told apart from a prefetch that failed or was # still downloading. The lines go to a file because the pulls outlive the workflow step that # started them and the step's stdout is closed by then. +# A nightly check, a *NightlyIntegrationTest class, keys its images on its own name: ci.yml leaves those names out +# of the list it passes, so they are pulled only for nightly-checks.yml, which passes nothing else. # Usage: prefetch-images.sh set -u SHARD_FILE="${1:-}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 316e7dfe04..81b267854b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,8 +107,13 @@ jobs: test -s shard.txt echo "shard ${{ matrix.shard }}/$SHARD_TOTAL: $(wc -l < shard.txt) classes" + # A nightly check (*NightlyIntegrationTest) skips in the shards, so its images are left to + # nightly-checks.yml: the prefetch is handed the shard's classes without it, while Surefire + # still gets them all. - name: Prefetch this shard's Docker images (background) - run: .github/ci/prefetch-images.sh shard.txt || true + run: | + grep -v 'NightlyIntegrationTest$' shard.txt > prefetch.txt || true + .github/ci/prefetch-images.sh prefetch.txt || true - name: Compile run: ./mvnw test-compile -B diff --git a/.github/workflows/nightly-checks.yml b/.github/workflows/nightly-checks.yml new file mode 100644 index 0000000000..b778063713 --- /dev/null +++ b/.github/workflows/nightly-checks.yml @@ -0,0 +1,114 @@ +name: Nightly checks + +# Runs the test classes named *NightlyIntegrationTest: checks that pull or push images too large, or run too long, +# for every pull request's shards. Each such class skips unless the JVM has -Dfloci.nightly=true, so the CI shards, +# which pick every *Test class, see it skip at no cost; this workflow sets the property. It runs once a day on +# main, on demand, and on a pull request that adds or changes a nightly check, so the check is seen to pass before +# it merges. GitHub-hosted runners only, which a public repository runs at no charge. +on: + schedule: + # 08:00 UTC, after Nightly (23:00 America/Chicago) and away from the daytime merges' CI runs. + - cron: '0 8 * * *' + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - '.github/workflows/nightly-checks.yml' + - 'src/test/java/**/*NightlyIntegrationTest.java' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + checks: + name: Nightly checks + runs-on: ubuntu-latest + timeout-minutes: 90 + # A fork's schedule would spend its owner's minutes on checks it never asked for; a draft waits until it is + # ready for review, as the CI shards do. + if: >- + (github.event_name != 'schedule' || !github.event.repository.fork) && + (github.event_name != 'pull_request' || github.event.pull_request.draft == false) + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + # Every test is a top-level class in src/test/java, so the file name is the class name, as ci.yml relies on. + - name: List the nightly checks + id: list + run: | + cd src/test/java + find . -name '*NightlyIntegrationTest.java' | sed 's|^\./||; s|\.java$||' | LC_ALL=C sort \ + > "$GITHUB_WORKSPACE/nightly.txt" + cd "$GITHUB_WORKSPACE" + count=$(wc -l < nightly.txt | tr -d ' ') + echo "count=$count" >> "$GITHUB_OUTPUT" + echo "$count nightly checks" + cat nightly.txt + + - name: No nightly checks yet + if: steps.list.outputs.count == '0' + run: echo "::notice title=Nightly checks::No *NightlyIntegrationTest class exists, so nothing ran." + + # The checks' images run to several gigabytes, a pushed copy of one included, and the runner's disk holds + # toolchains they never use. + - name: Free disk space + if: steps.list.outputs.count != '0' + run: | + df -h / + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL + df -h / + + - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 + if: steps.list.outputs.count != '0' + with: + java-version: '25' + distribution: 'temurin' + # no `cache: maven`, as in ci.yml; main's cache is restored below. + + # Restored only: ci.yml saves main's copy under this key. + - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + if: steps.list.outputs.count != '0' + with: + path: ~/.m2/repository + key: maven-${{ runner.os }}-${{ hashFiles('pom.xml') }} + restore-keys: | + maven-${{ runner.os }}- + + - name: Prefetch the checks' Docker images (background) + if: steps.list.outputs.count != '0' + run: .github/ci/prefetch-images.sh nightly.txt || true + + - name: Compile + if: steps.list.outputs.count != '0' + run: ./mvnw test-compile -B + + # nightly.txt is never empty here: an empty includesFile would make surefire run the whole suite. + - name: Run the nightly checks + if: steps.list.outputs.count != '0' + run: > + ./mvnw surefire:test -B + -Dsurefire.includesFile="$GITHUB_WORKSPACE/nightly.txt" + -Dsurefire.failIfNoTests=true + -Dfloci.nightly=true + + - name: Image prefetch results + if: always() && steps.list.outputs.count != '0' + run: | + cat prefetch-images.log 2>/dev/null || echo "no prefetch log" + grep -E 'stale prefetch key|prefetch skipped|prefetch failed' prefetch-images.log 2>/dev/null \ + | sed 's/^/::warning title=prefetch-images.sh::/' || true + + - name: Upload the checks' results + if: always() && steps.list.outputs.count != '0' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: nightly-checks + path: | + nightly.txt + prefetch-images.log + target/surefire-reports/ + if-no-files-found: warn diff --git a/AGENTS.md b/AGENTS.md index 055f142b40..654d9e67bb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -253,6 +253,11 @@ Guidelines: - Unit tests: `*ServiceTest.java` - Integration tests: `*IntegrationTest.java` +- Nightly checks: `*NightlyIntegrationTest.java`, for a check too heavy for every pull request's shards + (multi-gigabyte images, long runs). It skips unless the JVM has `-Dfloci.nightly=true`, which + `.github/workflows/nightly-checks.yml` sets once a day and on a pull request that adds or changes one. + Its images go in `.github/ci/prefetch-images.sh` keyed on its own class name, which only that + workflow's list carries - Prefer package-private constructors for testability - Integration tests may use ordered execution when stateful behavior requires it