nightly-test #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: nightly-test | |
| on: | |
| schedule: | |
| - cron: "50 2 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| go-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run tests (short baseline) | |
| run: go test -short ./... | |
| - name: Run tests (short integration) | |
| run: go test -count=1 -short ./test | |
| - name: Run tests (short coverage gates) | |
| run: | | |
| go test -count=1 -short -covermode=atomic -coverprofile=coverage.out ./internal/api/modules/amp | |
| total="$(go tool cover -func=coverage.out | awk '/^total:/{gsub("%","",$3); print $3}')" | |
| echo "nightly global coverage (scope: internal/api/modules/amp): ${total}%" | |
| awk -v c="${total}" 'BEGIN { if (c+0 < 80) { printf("nightly global coverage %.2f%% < 80%%\n", c+0); exit 1 } }' | |
| critical="$( | |
| go tool cover -func=coverage.out \ | |
| | awk 'index($1,"internal/api/modules/amp/proxy.go:")>0{gsub("%","",$3); sum+=$3; count+=1} END {if (count==0) exit 1; printf("%.2f", sum/count)}' | |
| )" | |
| echo "nightly critical coverage (internal/api/modules/amp/proxy.go): ${critical}%" | |
| awk -v c="${critical}" 'BEGIN { if (c+0 < 97) { printf("nightly critical coverage %.2f%% < 97%%\n", c+0); exit 1 } }' | |
| - name: Run tests (full coverage, long) | |
| run: | | |
| set -euo pipefail | |
| output_path="${RUNNER_TEMP}/nightly-go-cover.log" | |
| ( | |
| timeout 25m go test -covermode=atomic -coverprofile=coverage-full.out ./... \ | |
| 2>&1 | tee "${output_path}" | |
| ) & | |
| pid=$! | |
| while kill -0 "${pid}" 2>/dev/null; do | |
| echo "[heartbeat] nightly go coverage test still running at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| sleep 60 | |
| done | |
| wait "${pid}" | |
| full_total="$(go tool cover -func=coverage-full.out | awk '/^total:/{gsub("%","",$3); print $3}')" | |
| echo "nightly repo-wide coverage (report-only): ${full_total}%" | |
| - name: Run tests (race, long) | |
| run: | | |
| set -euo pipefail | |
| output_path="${RUNNER_TEMP}/nightly-go-race.log" | |
| ( | |
| timeout 25m go test -race ./... 2>&1 | tee "${output_path}" | |
| ) & | |
| pid=$! | |
| while kill -0 "${pid}" 2>/dev/null; do | |
| echo "[heartbeat] nightly go race test still running at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| sleep 60 | |
| done | |
| wait "${pid}" | |
| - name: Run fuzz smoke (thinking suffix parser) | |
| run: timeout 5m go test ./internal/thinking -run=^$ -fuzz=FuzzParseSuffix -fuzztime=15s | |
| - name: Install go-mutesting | |
| run: go install github.com/avito-tech/go-mutesting/cmd/go-mutesting@latest | |
| - name: Run mutation guard (thinking suffix parser) | |
| env: | |
| MAX_MUTATION_SCORE: "0.65" | |
| run: | | |
| set -euo pipefail | |
| output_path="${RUNNER_TEMP}/mutation-thinking-suffix.txt" | |
| ( | |
| timeout 20m "$(go env GOPATH)/bin/go-mutesting" ./internal/thinking/suffix.go --exec-timeout 30 \ | |
| | tee "${output_path}" | |
| ) & | |
| pid=$! | |
| while kill -0 "${pid}" 2>/dev/null; do | |
| echo "[heartbeat] mutation guard still running at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| sleep 30 | |
| done | |
| wait "${pid}" | |
| score="$(grep -Eo 'The mutation score is [0-9.]+' "${output_path}" | awk '{print $5}' | tail -1)" | |
| if [[ -z "${score}" ]]; then | |
| echo "failed to parse mutation score" | |
| exit 1 | |
| fi | |
| echo "mutation_score=${score} max_allowed=${MAX_MUTATION_SCORE}" | |
| awk -v score="${score}" -v max_allowed="${MAX_MUTATION_SCORE}" 'BEGIN { if (score <= max_allowed) exit 0; exit 1 }' | |
| - name: Upload mutation report | |
| if: always() | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: mutation-thinking-suffix | |
| path: ${{ runner.temp }}/mutation-thinking-suffix.txt | |
| - name: Upload nightly coverage artifacts | |
| if: always() | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: nightly-go-coverage | |
| path: | | |
| coverage.out | |
| coverage-full.out | |
| ${{ runner.temp }}/nightly-go-cover.log | |
| ${{ runner.temp }}/nightly-go-race.log |