ci: print how many Go and Android tests ran (#8372)
release / go (push) Successful in 1m51s
release / integration (push) Successful in 2m29s
release / web (push) Successful in 1m2s
release / govulncheck (push) Successful in 20s
release / android (push) Successful in 4m35s
release / Build signed APK (push) Successful in 4m49s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m51s
release / integration (push) Successful in 2m29s
release / web (push) Successful in 1m2s
release / govulncheck (push) Successful in 20s
release / android (push) Successful in 4m35s
release / Build signed APK (push) Successful in 4m49s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
The web lane's Vitest summary already says how many tests ran; the go, integration and android lanes said nothing, so a before-and-after had to count tests from source. - ci/testcount reads `go test -json` and prints what plain go test would (one line per package, the whole output of a failed test), then the pass/fail/skip counts for tests and subtests. Both Go lanes pipe through it and exit with go test's own status, kept in a file because the shell has no pipefail: the reader never decides the gate. - The android lane sums Gradle's JUnit reports after the unit tests, failure or not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,8 +166,14 @@ jobs:
|
||||
- name: golangci-lint
|
||||
run: golangci-lint run ./...
|
||||
|
||||
# ci/testcount prints what plain go test would, plus how many tests
|
||||
# ran. The step exits with go test's own status, kept aside in a file
|
||||
# because the shell has no pipefail.
|
||||
- name: go test (short, race)
|
||||
run: go test -short -race ./...
|
||||
run: |
|
||||
go build -o /tmp/testcount ./ci/testcount
|
||||
{ go test -short -race -json ./...; echo $? > /tmp/go-test-rc; } | /tmp/testcount
|
||||
exit "$(cat /tmp/go-test-rc)"
|
||||
|
||||
# Full `go test -race` against an ephemeral Postgres.
|
||||
#
|
||||
@@ -303,7 +309,11 @@ jobs:
|
||||
PKGS=$(sh ci/db-test-packages.sh)
|
||||
echo "database test packages: $(echo "$PKGS" | wc -l)"
|
||||
go test -race -run '^$' $PKGS
|
||||
go test -p 1 -race -timeout 20m $PKGS
|
||||
# ci/testcount prints the usual go test output plus how many tests
|
||||
# ran; the step exits with go test's own status (no pipefail).
|
||||
go build -o /tmp/testcount ./ci/testcount
|
||||
{ go test -p 1 -race -timeout 20m -json $PKGS; echo $? > /tmp/go-test-rc; } | /tmp/testcount
|
||||
exit "$(cat /tmp/go-test-rc)"
|
||||
|
||||
web:
|
||||
runs-on: go-ci
|
||||
@@ -380,6 +390,25 @@ jobs:
|
||||
- name: Unit tests
|
||||
run: ./gradlew testDebugUnitTest
|
||||
|
||||
# How many tests ran, summed from Gradle's JUnit reports. Runs after a
|
||||
# failure too, so a red run still says how much of the suite it reached.
|
||||
- name: Test count
|
||||
if: always()
|
||||
run: |
|
||||
set -- app/build/test-results/testDebugUnitTest/*.xml
|
||||
if [ ! -e "$1" ]; then echo "no unit test reports"; exit 0; fi
|
||||
awk '/<testsuite / {
|
||||
for (i = 1; i <= NF; i++)
|
||||
if (match($i, /^(tests|skipped|failures|errors)="[0-9]+"/)) {
|
||||
split($i, kv, "\"")
|
||||
n[substr($i, 1, index($i, "=") - 1)] += kv[2]
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf "tests: %d passed, %d failed, %d skipped\n",
|
||||
n["tests"] - n["failures"] - n["errors"] - n["skipped"], n["failures"] + n["errors"], n["skipped"]
|
||||
}' "$@"
|
||||
|
||||
# No debug APK is built or uploaded here: a debug build is signed by a
|
||||
# key regenerated in every container, which no install can update.
|
||||
# Phones get builds from android-release, signed with the one release
|
||||
|
||||
Reference in New Issue
Block a user