fix(coverage): add TESTFLAGS support and fix grep typo in scripts/coverage.sh, Enhanced build-test.yml to:

- Add flaky test detection step with -shuffle=on -count=5 -v.
- Upload test output as an artifact for debugging.

Signed-off-by: Victor <ubahakweemeka@gmail.com>
pull/30953/head
Victor 4 months ago
parent f9ebe18dae
commit ebbb4cf80f

@ -1,4 +1,5 @@
name: build-test
name: Build and Test
on:
push:
branches:
@ -28,7 +29,22 @@ jobs:
check-latest: true
- name: Test source headers are present
run: make test-source-headers
- name: Run unit tests
- name: Run unit tests with coverage
run: make test-coverage
- name: Run unit tests with shuffle for flaky test detection
env:
TESTFLAGS: -shuffle=on -count=5 -v
run: |
./scripts/coverage.sh | tee test_output.txt
if grep -B 5 "FAIL" test_output.txt; then
echo "Flaky tests detected. Please review test_output.txt for details."
exit 1
fi
- name: Upload test output for debugging
if: always()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # pin@v4.4.0
with:
name: test-output
path: test_output.txt
- name: Test build
run: make build
run: make build

@ -21,10 +21,10 @@ coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX)
profile="${coverdir}/cover.out"
generate_cover_data() {
for d in $(go list ./...) ; do
for d in $(go list ./...); do
(
local output="${coverdir}/${d//\//-}.cover"
go test -coverprofile="${output}" -covermode="$covermode" "$d"
go test -coverprofile="${output}" -covermode="$covermode" ${TESTFLAGS:-} "$d"
)
done
@ -39,5 +39,4 @@ case "${1-}" in
--html)
go tool cover -html "${profile}"
;;
esac
esac
Loading…
Cancel
Save