GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — workflow/Taskfile.yml at main · ubgo/workflow Expand file tree/ Copy pathTaskfile.ymlMore file actions 257 lines (225 loc) · 13.5 KB / Copy pathTaskfile.ymlFile metadata and controls257 lines (225 loc) · 13.5 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 version: '3' # A test piped into grep or tee still fails the task. set: [pipefail] # Temporary files (go build work dirs, t.TempDir, mktemp) go to disk when # /tmp is a tmpfs: a full gate makes hundreds of thousands of files, which # can exhaust a tmpfs's inodes or space while other jobs share it ("no space # left on device" from t.TempDir). WF_TMPDIR names the directory; else, with # a tmpfs /tmp, it is the user cache dir's ubgo-workflow/tmp; else TMPDIR as # it is. A TMPDIR set in the caller's environment wins over all of this. env: TMPDIR: sh: 'if [ -n "${WF_TMPDIR:-}" ]; then d=$WF_TMPDIR; elif [ "$(findmnt -no FSTYPE /tmp 2>/dev/null)" = tmpfs ]; then d=${XDG_CACHE_HOME:-$HOME/.cache}/ubgo-workflow/tmp; else d=${TMPDIR:-/tmp}; fi; mkdir -p "$d" && echo "$d"' # The Hatchet driver's own tasks, runnable from the root as hatchet:<task> # (hatchet:test:live runs the conformance suite against the shared stack's # Hatchet engine). vars: # LOCK prefixes the heavy commands: `testlock` (the machine-wide lock the # maintainers use so two suites never run at once on one machine) when it # is on PATH, otherwise empty, so the command runs directly. LOCK: sh: 'command -v testlock >/dev/null 2>&1 && echo testlock || true' includes: hatchet: taskfile: ./hatchet/Taskfile.yml dir: ./hatchet # The SQL driver's tasks, runnable as sqlstore:<task> (sqlstore:test:pg # adds the host Postgres to the SQLite run). sqlstore: taskfile: ./sqlstore/Taskfile.yml dir: ./sqlstore # The run recorder's tasks, runnable as recorder:<task> (recorder:e2e:all # runs it against throwaway Postgres, MySQL, Redis and Hatchet). recorder: taskfile: ./recorder/Taskfile.yml dir: ./recorder # The heavy tasks (test, vet, check) run under the machine-wide `testlock` # when it is on PATH (the LOCK var above), so two suites never run at once # on this machine; a nested call passes straight through. Without it the # command runs directly. Each public task takes the lock and runs its # internal :run twin. Every module in go.work is covered: `go list -m` lists # the workspace modules and each gets a /... pattern. tasks: build: desc: Compile every package of every module in go.work cmds: ['go build $(go list -m | sed "s|$|/...|")'] test: desc: Run the tests of every module in go.work with the race detector (the Hatchet live suite skips without a token; see hatchet:test:live) cmds: ['{{.LOCK}} task test:run'] # Called through testlock by the public task above; no desc keeps it off task --list. # -race because the drivers and the fake clock are concurrent code. # -timeout 30m: the SQLite engine suite ran past Go's 10-minute default # on a loaded machine (13 to 23 minutes in one process); split into shard # processes (sqlstore/enginetest/shards) its longest package takes about # 5, and the timeout keeps the margin for a machine loaded further. test:run: cmds: ['go test -race -timeout 30m $(go list -m | sed "s|$|/...|")'] vet: desc: Run go vet over every module in go.work cmds: ['{{.LOCK}} task vet:run'] # Called through testlock by the public task above; no desc keeps it off task --list. vet:run: cmds: ['go vet $(go list -m | sed "s|$|/...|")'] fmt: desc: Format every Go file with gofmt cmds: ['gofmt -w .'] fmt:check: desc: Fail when any Go file is not gofmt clean cmds: ['test -z "$(gofmt -l .)" || (gofmt -l . && exit 1)'] # A `go build` inside a folder with a main package writes a program named # after the folder; .gitignore lists every such folder, and this catches # the one a new folder's missing line lets through, before it is # committed. It reads the first bytes of each file git tracks or would # track, so it costs about a second. bin:check: desc: Fail when a file git tracks or would track is a compiled program (ELF, Mach-O, PE or WebAssembly), such as the binary a go build in a main folder leaves behind cmds: - git ls-files --cached --others --exclude-standard -z | xargs -0 go run ./examples/internal/bincheck gomin: desc: Vet every module, test files included, under the Go toolchain its go.mod declares (core, sqlstore and its pgnotify, pgxtx and enginetest modules, admin, redis and cli go 1.24.0, otel, otel/sdktest and sentry go 1.25.0, hatchet, bench and examples go 1.26.0), so a stated minimum is proven rather than claimed; downloads a missing toolchain once cmds: ['{{.LOCK}} task gomin:run'] # Called through testlock by the public task above; no desc keeps it off task --list. # go.work declares the highest version (1.26.0), which an older toolchain # refuses, so each module gets a temporary go.work at its own version # holding the module and every module of this repo it requires: a module # is vetted against the core and siblings in this tree, which are released # with it, not against their last tags (a core API change would otherwise # fail here until the core is tagged). Whether a released go.mod is tidy # without go.work is deps:check's job. gomin:run: cmds: - | root=$(pwd) find . -name go.mod -not -path './.cover/*' | sort | while read -r f; do d=$(dirname "$f"); v=$(awk '/^go /{print $2}' "$f") case $v in *.*.*) ;; *) v=$v.0 ;; esac echo "go$v $d" self=$(cd "$d" && pwd); uses=$self for p in $(GOWORK=off go mod edit -json "$f" | awk -F'"' '/"Path": "github.com\/ubgo\/workflow/{print $4}' | sort -u); do rel=${p#github.com/ubgo/workflow}; rel=${rel#/} dir=$(cd "$root/$rel" 2>/dev/null && pwd) || continue if [ "$dir" != "$self" ] && [ -f "$dir/go.mod" ] && [ "$(awk '/^module /{print $2}' "$dir/go.mod")" = "$p" ]; then uses="$uses $dir" fi done w=$(mktemp -d) { printf 'go %s\n\nuse (\n' "$v"; for u in $uses; do printf '\t%s\n' "$u"; done; printf ')\n'; } > "$w/go.work" (cd "$d" && GOWORK="$w/go.work" GOTOOLCHAIN=go$v go vet ./...); rc=$? rm -rf "$w" [ $rc -eq 0 ] || exit 1 done check: desc: The gate - gofmt check, no compiled program in the tree (bin:check), vet, race tests of every module (the examples module included), the Go minimum per module, the dependency rule (deps:check), then the doc checks (wrap, links, snippets, words, drift) cmds: ['{{.LOCK}} task check:run'] # Called through testlock by the public task above; no desc keeps it off task --list. check:run: cmds: - task: fmt:check - task: bin:check - task: vet:run - task: test:run - task: gomin:run - task: deps:check - task: docs:wrap - task: docs:links - task: docs:snippets - task: docs:words - task: docs:drift # The Redis driver against a throwaway Redis 8 from the root compose.yml # (profile redis, 127.0.0.1:36379), removed after the run pass or fail. # Without WFTEST_REDIS_URL its live tests skip, so `task test` and `check` # need no Redis. -count=1 because the result depends on a live service, not # only on the code. redis:test: desc: Redis driver race tests against a throwaway Redis (compose.yml redis profile), each test under its own key prefix; WFTEST_REDIS_URL set to a URL runs against that Redis instead and starts nothing cmds: ['{{.LOCK}} task redis:test:run'] # Called through testlock by the public task above; no desc keeps it off # task --list. The defer is registered BEFORE the profile starts. With # WFTEST_REDIS_URL set by the caller (e.g. the Mac shared stack, # redis://localhost:7012/0) no container is started. redis:test:run: dir: redis cmds: - defer: {task: redis:down} - | if [ -z "$WFTEST_REDIS_URL" ]; then up_redis() { for i in 1 2 3 4 5; do docker compose -f ../compose.yml --profile redis up -d --wait && return 0; docker compose -f ../compose.yml --profile redis down -v --remove-orphans >/dev/null 2>&1; sleep 3; done; return 1; } # retried: rootless Docker can report a just-freed port as in use up_redis || exit 1 export WFTEST_REDIS_URL=redis://127.0.0.1:36379/0 fi go test -race -count=1 ./... redis:down: desc: Remove the throwaway Redis (redis:test already does this after every run) cmds: ['docker compose -f compose.yml --profile redis down -v --remove-orphans'] # Not part of check: benchmarks measure, they do not gate, and a run # takes minutes against several services. Run it on a quiet machine. bench: desc: Run the benchmarks (memory, sqlstore on SQLite, Postgres and Postgres with LISTEN/NOTIFY, Redis, Hatchet) one system at a time and print a results table; STACK_ENV (required) is the local stack's .env path, or empty to take HATCHET_CLIENT_TOKEN and REDIS_PASSWORD from the environment; REDIS_ADDR overrides the Redis address; see docs/reference/benchmarks.md dir: bench cmds: ['sh ./run.sh {{.CLI_ARGS}}'] # The library rule: an app never downloads a module it does not import. # Every released module (any go.mod whose .volt.yml does not say # internal: true) must be tidy on its own and require only modules its # library packages import; what only tests need lives in a never-released # test module beside it (sqlstore/enginetest, otel/sdktest). deps:check: desc: Fail when a released module's go.mod is not tidy without go.work, or requires a module none of its library packages import (test-only requires belong in a never-released test module) cmds: - | mods=$(find . -name go.mod -not -path './.cover/*' -exec dirname {} \; | sort | while read -r d; do grep -qs '^internal: true' "$d/.volt.yml" || echo "$d"; done) go run ./examples/internal/depcheck $mods docs:drift: desc: docsync - fail when code a doc sentence cites (ds:block links) changed since the sentence was acked; needs the ds CLI (go install github.com/ubgo/docsync/cli/cmd/ds@latest) cmds: - 'command -v ds >/dev/null || { echo "docs:drift needs the ds CLI: go install github.com/ubgo/docsync/cli/cmd/ds@latest"; exit 1; }' - ds check docs:def: desc: 'Give a library declaration a docsync id for a ds:block citation and print it (task docs:def -- <file>#<Symbol> [stable|api] [--label <label>]); writes the //ds:def directive godoc hides, one writer at a time under flock; needs the ds CLI' cmds: - scripts/dsdef.sh {{.CLI_ARGS}} examples:test: desc: Vet and test the examples module (every program under examples/ and the doc checkers); task test covers it too, this runs it alone cmds: ['{{.LOCK}} task examples:test:run'] # Called through testlock by the public task above; no desc keeps it off task --list. examples:test:run: dir: examples cmds: - go vet ./... - go test ./... # The four doc checkers live in examples/internal/doccheck (no extra # module in go.work). Each takes repo-relative paths. docs:wrap: desc: Fail on hard-wrapped prose in any Markdown file git tracks or would track (every paragraph, bullet and table row is one physical line; ignored private overlays are skipped) cmds: - git ls-files --cached --others --exclude-standard -z -- '*.md' ':!.lore/*' | xargs -0 go run ./examples/internal/doccheck/mdwrap docs:links: desc: Fail when a relative link or #anchor in README.md, docs/ or examples/ does not resolve cmds: - go run ./examples/internal/doccheck/mdlinks -root . README.md docs examples docs:snippets: desc: 'Fail when a code block marked <!-- snippet: path#region --> in README.md, docs/ or examples/ differs from that region of the source file' cmds: - go run ./examples/internal/doccheck/snippets -root . README.md docs examples docs:screenshots: desc: Capture the admin UI screenshots of run reset, fork and waiting into docs/assets/admin-ui with a headless Chrome (scripts/admin-screenshots; needs Chrome or Chromium; never part of check) dir: scripts/admin-screenshots cmds: ['go run . -out ../../docs/assets/admin-ui'] docs:words: desc: Fail when a forbidden word appears in the Markdown under docs/ and examples/, the top-level public Markdown files or any Go file git tracks or would track (ignored private overlays such as docsi are skipped); the list comes from FORBIDDEN_WORDS or the private docsi/forbidden-words.txt (one word per line), and the check is skipped when neither exists # The list itself is private: writing the names here would publish the # very words the check keeps out of the public tree. It is read by the # shell and handed to the checker in DOCCHECK_WORDS, never through a # Task variable or an argument, because Task echoes each command with # its variables expanded (and --verbose prints them again), which put # the whole list into every log of `task check`. cmds: - | if [ -n "${FORBIDDEN_WORDS:-}" ]; then DOCCHECK_WORDS="$FORBIDDEN_WORDS" elif [ -f docsi/forbidden-words.txt ]; then DOCCHECK_WORDS=$(grep -v "^#" docsi/forbidden-words.txt | tr "\n" ",") else echo "docs:words: no word list (FORBIDDEN_WORDS or docsi/forbidden-words.txt), skipped"; exit 0; fi export DOCCHECK_WORDS git ls-files --cached --others --exclude-standard -z -- '*.go' 'docs/*.md' 'examples/*.md' README.md CHANGELOG.md CONTRIBUTING.md SECURITY.md | xargs -0 go run ./examples/internal/doccheck/words -words-env DOCCHECK_WORDS docs:snippets:sync: desc: Rewrite every stale marked code block in README.md, docs/ and examples/ from its source region cmds: - go run ./examples/internal/doccheck/snippets -root . -sync README.md docs examples |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |