Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
86 lines (76 loc) · 3.79 KB
/
Copy pathTaskfile.yml
File metadata and controls
86 lines (76 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# go-tools - the Go the spin-stack repositories build with, and nothing any of them ships.
#
# task test the Go tests, under the race detector, held to a coverage floor
# task lint golangci-lint with spin's rules, at spin's version, this repository's own
# gates run on itself: ctxlife, testquality, refs, and actionlint over .github/
# task mutate break what the change against BASE (origin/main) touched, and ask the tests
# task versions which pins in versions.yaml are behind; task bump NAME=... moves one
version: '3'
silent: true
vars:
OUT: '{{.ROOT_DIR}}/_output'
VERSIONS: go run ./cmd/versions
OWNER:
sh: echo "$(id -u):$(id -g)"
tasks:
test:
desc: The Go tests, under the race detector, with their coverage in coverage.out and held to a floor.
vars:
# Below today's 61.4%. Raise it when the number has moved up and stayed; never lower it to
# let a change through, or it is a gate that reports whatever it is given.
COVERAGE_FLOOR: 60
cmds:
- go test -race -covermode=atomic -coverprofile=coverage.out ./...
# The anchor makes it the total line, not a function with "total" in its name.
- |
total=$(go tool cover -func=coverage.out | awk '/^total:/ {print $3}' | tr -d '%')
awk -v got="$total" -v floor={{.COVERAGE_FLOOR}} 'BEGIN {
if (got + 0 < floor + 0) { printf "coverage is %s%%, below the floor of %s%%\n", got, floor; exit 1 }
printf "coverage: %s%% (floor %s%%)\n", got, floor
}'
lint:
desc: golangci-lint with spin's rules (.golangci.yml), at spin's version, over the Go.
cmds:
# As this user, on this host's module and build caches: the container fetches nothing a
# build here has not, and leaves nothing root's behind. Its own cache is under _output.
- mkdir -p {{.OUT}}/golangci-lint
- >-
docker run --rm -u {{.OWNER}} -v {{.ROOT_DIR}}:/work -w /work
-v "$(go env GOMODCACHE)":/go/pkg/mod -v "$(go env GOCACHE)":/cache/go-build
-e GOMODCACHE=/go/pkg/mod -e GOCACHE=/cache/go-build -e GOLANGCI_LINT_CACHE=/work/_output/golangci-lint
-e HOME=/tmp
$({{.VERSIONS}} ref golangci-lint) golangci-lint run ./...
# What this repository gives the others, held to itself first.
- go run ./cmd/ctxlife
- go run ./cmd/testquality ./...
- go run ./cmd/refs
- go run ./cmd/mutate -stale-exempts
- task: lint:workflows
lint:workflows:
desc: actionlint over .github/, and every action pinned by its commit.
cmds:
# -shellcheck= because actionlint runs whatever shellcheck is on PATH: a runner has one and
# a laptop may not, and a gate whose answer depends on the machine is not a gate.
- go run github.com/rhysd/actionlint/cmd/actionlint@$({{.VERSIONS}} version actionlint) -shellcheck=
# A tag is whatever its owner points it at; the comment is the version Dependabot moves.
- cmd: |
if grep -rnE '^\s*(- )?uses: [^./][^ ]*@' .github | grep -vE '@[0-9a-f]{40} # v[0-9]'; then
echo "an action above is used by a tag its owner can move: pin it by commit SHA, with '# vX.Y.Z' after it"
exit 1
fi
mutate:
desc: Break what the change against BASE touched and fail on an edit no test refuses (BASE=origin/main).
vars:
BASE: '{{.BASE | default "origin/main"}}'
cmds:
- go run ./cmd/mutate -base {{.BASE}} -max 200
versions:
desc: Say which of versions.yaml's pins are behind their upstream (exits 1 when any is).
cmds:
- '{{.VERSIONS}} check'
bump:
desc: Pin one entry of versions.yaml at a version, the newest by default (task bump NAME=golangci-lint [VERSION=v2.14.0]).
requires:
vars: [NAME]
cmds:
- '{{.VERSIONS}} bump {{.NAME}} {{.VERSION}}'