mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
Measured on recent green runs, shards take 10m49s to 13m47s, so the slowest had about a minute of margin under a 15 minute ceiling. Shard 1 timed out twice on an unrelated PR because of exactly that. timeout-minutes is a kill switch for a hung job rather than a budget. Actions bills the minutes a job actually uses, so raising the ceiling costs nothing while runs stay the length they are, and it stops a slow runner or a contended queue turning a passing suite into a red build. This does not make anything faster, and it is not a substitute for the work in #3963: it removes the failure mode while the suite sits where it sits. Per shard that is about 1m15s compiling, 2.3 to 3.2 min building one application per distinct test profile, and 7.2 to 8.2 min running test classes, with the class time spread too flat to have a hot spot left. ci-summary keeps its 10 minute ceiling; it finishes in seconds.
176 lines
7.4 KiB
YAML
176 lines
7.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'src/**'
|
|
- 'pom.xml'
|
|
- '.github/ci/**'
|
|
- '.github/workflows/ci.yml'
|
|
- '.github/workflows/pr-draft-gate.yml'
|
|
pull_request:
|
|
# ready_for_review is not a default type: without it, marking a draft ready
|
|
# would not start the run the draft skipped.
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
paths:
|
|
- 'src/**'
|
|
- 'pom.xml'
|
|
- '.github/ci/**'
|
|
- '.github/workflows/ci.yml'
|
|
- '.github/workflows/pr-draft-gate.yml'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
# Hardcoded on purpose: strategy.job-total counts EVERY matrix job, so adding an
|
|
# unrelated matrix entry later would change the modulus and silently leave part
|
|
# of the suite running in no shard. Keep in sync with the matrix below.
|
|
SHARD_TOTAL: 4
|
|
|
|
jobs:
|
|
# Drafts skip the suite to spare runners; it runs once the PR is ready for review.
|
|
draft-gate:
|
|
uses: ./.github/workflows/pr-draft-gate.yml
|
|
|
|
test:
|
|
name: Build and Test (shard ${{ matrix.shard }})
|
|
runs-on: ubuntu-latest
|
|
# Shards run 10m49s to 13m47s, so 15 left the slowest about a minute of margin and a slow
|
|
# runner spent it. This is a runaway-job kill switch, not a budget: Actions bills the minutes a
|
|
# job actually uses, so a higher ceiling costs nothing until something hangs.
|
|
timeout-minutes: 20
|
|
needs: draft-gate
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4]
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
|
with:
|
|
java-version: '25'
|
|
distribution: 'temurin'
|
|
# no `cache: maven` - broken in this release line (restore misses, save
|
|
# fails with Path Validation Error); explicit cache steps below.
|
|
|
|
# Restore on every shard; save from shard 1 only. With a combined cache step
|
|
# all four shards would race the same save key: one wins, three spend
|
|
# post-job time reserving-then-failing plus redundant multi-hundred-MB uploads.
|
|
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: maven-${{ runner.os }}-${{ hashFiles('pom.xml') }}
|
|
restore-keys: |
|
|
maven-${{ runner.os }}-
|
|
|
|
# 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 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
|
|
# An empty includesFile makes surefire fall back to its default includes
|
|
# 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"
|
|
|
|
- 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: >
|
|
./mvnw surefire:test -B
|
|
-Dsurefire.includesFile="$GITHUB_WORKSPACE/shard.txt"
|
|
-Dsurefire.failIfNoTests=true
|
|
|
|
# Save from main only, and from shard 1 only. Actions caches are ref-scoped:
|
|
# a pull_request run's write lands in refs/pull/N/merge where no other PR can
|
|
# read it, so every open PR was storing a ~201 MB byte-identical duplicate of
|
|
# the copy main already publishes under this exact key — 1.61 GB across 8 PRs
|
|
# when measured, against a 10 GB repo budget. PRs restore main's copy instead
|
|
# (verified: four sampled PR runs all restored maven-Linux-a80d20aaec, the key
|
|
# main holds), and main gets ~15 qualifying pushes a day so it stays fresh.
|
|
#
|
|
# Trade-off: a PR that edits pom.xml misses this exact key, falls back to the
|
|
# restore-keys prefix for the bulk, and re-downloads its delta on each re-run
|
|
# rather than caching it. pom.xml changed 21 times in 30 days, so that is a
|
|
# small minority of PRs paying a small delta.
|
|
- uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
if: always() && matrix.shard == 1 && github.event_name == 'push'
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: maven-${{ runner.os }}-${{ hashFiles('pom.xml') }}
|
|
|
|
- name: Upload shard manifest and results
|
|
if: always()
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: shard-${{ matrix.shard }}
|
|
path: |
|
|
shard.txt
|
|
all-classes.txt
|
|
target/surefire-reports/
|
|
if-no-files-found: error
|
|
|
|
# The enforced completeness gate: fails on any shard failure, any class assigned
|
|
# to two shards, or any class assigned to none - checked against the same
|
|
# commit's own class list, never a hardcoded count. Intended to become the one
|
|
# required status check; its name stays stable across re-sharding.
|
|
ci-summary:
|
|
name: CI summary
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
needs: [draft-gate, test]
|
|
# Without the gate check, always() would run this on a draft and fail on the skipped shards.
|
|
if: always() && needs.draft-gate.result == 'success'
|
|
steps:
|
|
- name: Fail if any shard failed
|
|
if: needs.test.result != 'success'
|
|
run: |
|
|
echo "shard matrix concluded: ${{ needs.test.result }}"
|
|
exit 1
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
pattern: shard-*
|
|
path: shards
|
|
|
|
- name: Verify shard partition is disjoint and complete
|
|
run: |
|
|
set -euo pipefail
|
|
ls -d shards/shard-*
|
|
ref=$(ls -d shards/shard-* | head -1)
|
|
for d in shards/shard-*; do
|
|
cmp -s "$ref/all-classes.txt" "$d/all-classes.txt" \
|
|
|| { echo "::error::$d computed a different class list than $ref"; exit 1; }
|
|
done
|
|
dups=$(cat shards/shard-*/shard.txt | LC_ALL=C sort | uniq -d)
|
|
[ -z "$dups" ] || { echo "::error::classes assigned to more than one shard:"; echo "$dups"; exit 1; }
|
|
cat shards/shard-*/shard.txt | LC_ALL=C sort > union.txt
|
|
cmp -s union.txt "$ref/all-classes.txt" \
|
|
|| { echo "::error::shard union differs from the full class list:"; diff union.txt "$ref/all-classes.txt" | head -50; exit 1; }
|
|
echo "partition verified: $(wc -l < union.txt) classes across $(ls -d shards/shard-* | wc -l) shards"
|
|
|
|
- name: Test summary
|
|
uses: test-summary/action@37b508cfee6d4d080eedd00b5bb240a6a784a6a5 # v2
|
|
with:
|
|
paths: 'shards/shard-*/target/surefire-reports/TEST-*.xml,shards/shard-*/surefire-reports/TEST-*.xml'
|