fix: close two defects that shipped past every guard #18
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: CI | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| # The exact toolchain used for tests and releases. go.mod declares a | |
| # minimum - this is the pin. Raising it can change generated bytes, so the | |
| # byte stability guard has to be green before it moves. | |
| GO_VERSION: "1.26.5" | |
| jobs: | |
| test: | |
| name: test on ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| # The engine, the command line and the tests build without CGO on every | |
| # system. Only the desktop window needs a C compiler, and it is built | |
| # separately. | |
| CGO_ENABLED: "0" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| check-latest: false | |
| # Keyed on go.sum. The one dependency is the YAML parser behind the | |
| # recipe - see docs/STACK.md. | |
| cache: true | |
| - name: formatting | |
| run: | | |
| test -z "$(gofmt -l .)" || { echo "gofmt found unformatted files:"; gofmt -l .; exit 1; } | |
| shell: bash | |
| - name: vet | |
| run: go vet ./... | |
| - name: the dependency list has not grown by accident | |
| # Every dependency is a licence question and a byte stability question. | |
| # A new one arriving as somebody's transitive import has to be visible | |
| # rather than discovered later. | |
| run: | | |
| set -euo pipefail | |
| expected="github.com/goccy/go-yaml" | |
| actual=$(go list -m -f '{{.Path}}' all | grep -v '^github.com/donislawdev/TestingFilesGenerator$' | sort) | |
| if [ "$actual" != "$expected" ]; then | |
| echo "the module list changed." | |
| echo "expected: $expected" | |
| echo "actual : $actual" | |
| exit 1 | |
| fi | |
| echo "dependencies unchanged: $actual" | |
| shell: bash | |
| - name: test | |
| run: go test ./... -count=1 | |
| - name: build the command line binary | |
| run: go build ./cmd/tfg | |
| coverage: | |
| name: coverage gate | |
| runs-on: ubuntu-latest | |
| env: | |
| CGO_ENABLED: "0" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| check-latest: false | |
| # Keyed on go.sum. The one dependency is the YAML parser behind the | |
| # recipe - see docs/STACK.md. | |
| cache: true | |
| - name: measure | |
| # -coverpkg is not optional here. The guard tests live in their own | |
| # package, and by default Go credits coverage only to the package | |
| # under test - which reports 0.0% and makes the gate meaningless. | |
| # Measured, not assumed. | |
| run: > | |
| go test ./... -count=1 -covermode=atomic | |
| -coverpkg=./internal/...,./cmd/... | |
| -coverprofile=coverage.out | |
| - name: gate | |
| # The threshold lives in exactly one place, .github/coverage-threshold. | |
| # It rises with coverage and is never lowered to turn a red run green. | |
| # Lowering it is a decision for the owner, not a way to get unblocked. | |
| run: | | |
| set -euo pipefail | |
| threshold=$(tr -d '[:space:]' < .github/coverage-threshold) | |
| actual=$(go tool cover -func=coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}') | |
| echo "coverage ${actual}% - threshold ${threshold}%" | |
| awk -v a="$actual" -v t="$threshold" 'BEGIN { exit (a+0 >= t+0) ? 0 : 1 }' \ | |
| || { echo "coverage ${actual}% is below the threshold ${threshold}%"; exit 1; } | |
| shell: bash |