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 — sqlb/Taskfile.yml at main · ubgo/sqlb Expand file tree/ Copy pathTaskfile.ymlMore file actions 399 lines (343 loc) · 14.4 KB / Copy pathTaskfile.ymlFile metadata and controls399 lines (343 loc) · 14.4 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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 version: '3' # Reusable command runner for the ubgo/sqlb repo. `task --list` shows them all. # # The repo holds several Go modules: the zero-dependency core at the root, and # one module per driver under contrib/. MODULES is the list every gate walks, # so adding a contrib module means adding one line here and one matrix entry # in .github/workflows/test.yml. vars: MODULES: . contrib/driver-sqlite contrib/driver-sqlite/enginetest contrib/driver-pgx contrib/driver-pgx/enginetest contrib/driver-mysql contrib/driver-mysql/enginetest contrib/vet contrib/vet/enginetest contrib/vet/cmd/sqlb contrib/migrate contrib/migrate/enginetest contrib/debug contrib/structbind contrib/structbind/enginetest tasks: default: desc: Show available tasks cmds: - task --list check: desc: The gate - every module formatted, vetted and tested, plus the core's own gates cmds: - task: names:check - task: check:modules - task: typecheck - task: zerodep - task: deps:check - task: reuse:check - task: tasks:check - task: docs:check check:modules: desc: fmt, vet and test in every module cmds: - for: { var: MODULES } task: module:check vars: { DIR: '{{.ITEM}}' } module:check: internal: true dir: '{{.DIR}}' cmds: - echo "--- {{.DIR}}" - test -z "$(gofmt -l .)" || (gofmt -l . && exit 1) - go vet ./... - go test ./... test: desc: Run every test in every module cmds: - for: { var: MODULES } task: module:test vars: { DIR: '{{.ITEM}}' } module:test: internal: true dir: '{{.DIR}}' cmds: - go test ./... test:race: desc: Run every test with the race detector cmds: - for: { var: MODULES } task: module:race vars: { DIR: '{{.ITEM}}' } module:race: internal: true dir: '{{.DIR}}' cmds: - go test -race -count=2 ./... cover: desc: Print total coverage per module cmds: - for: { var: MODULES } task: module:cover vars: { DIR: '{{.ITEM}}' } test:cover: desc: Write a coverage profile per module and print each total cmds: - for: { var: MODULES } task: module:cover vars: { DIR: '{{.ITEM}}' } test:cover:html: desc: Open an HTML coverage report for the core module cmds: - go test -coverpkg=./... -coverprofile=cover.out -covermode=atomic ./... - go tool cover -html=cover.out -o cover.html - 'echo "wrote cover.html"' test:uncovered: desc: List every statement with zero coverage, per module, worst file first cmds: - for: { var: MODULES } task: module:uncovered vars: { DIR: '{{.ITEM}}' } # Writes a profile, prints the module's total, and removes the profile. The # -coverpkg flag is the whole point: most of the core is exercised from the # catalogues under examples/, which are external test packages, so the # default per-package measure credits none of that work to the core. See # COVERAGE.md. module:cover: internal: true dir: '{{.DIR}}' cmds: - python3 {{.ROOT_DIR}}/scripts/covmerge.py cover.out - 'echo "{{.DIR}}: $(go tool cover -func=cover.out | tail -1 | awk ''{print $NF}'')"' - rm -f cover.out module:uncovered: internal: true dir: '{{.DIR}}' cmds: - python3 {{.ROOT_DIR}}/scripts/covmerge.py cover.out - 'echo "--- {{.DIR}}"' - sh {{.ROOT_DIR}}/scripts/uncovered.sh cover.out typecheck: desc: FAIL unless every deliberately wrong statement in examples/typecheck is rejected by the compiler, line by line cmds: - python3 scripts/check-typecheck.py zerodep: desc: FAIL if the core module gained a third-party dependency cmds: - | if grep -E '^[[:space:]]+[^/[:space:]]+\.[^/[:space:]]+/' go.mod | grep -v 'github.com/ubgo'; then echo "the sqlb core has a third-party dependency - it belongs in contrib/"; exit 1 fi echo "zerodep: the core imports nothing outside the standard library" # The dependency rule: an app never downloads a module it does not import. # Every released module (a 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 # enginetest module beside it. deps:check: desc: FAIL if 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 an enginetest module) cmds: - | mods=$(find . -name go.mod -exec dirname {} \; | sort | while read -r d; do grep -qs '^internal: true' "$d/.volt.yml" || echo "$d"; done) go run ./internal/depcheck $mods docs:check: desc: Verify the markdown - links resolve, anchors match, no rules, no hard wraps cmds: - python3 scripts/check-docs.py - task: docs:setup - task: docs:names - task: docs:commands - task: docs:not-built docs:setup: desc: FAIL if a per-package page's Setup block does not compile cmds: - python3 scripts/check-doc-setup.py docs:names: desc: FAIL if a documentation snippet names a symbol that does not exist cmds: - python3 scripts/check-doc-names.py - task: docs:coverage docs:coverage: desc: Fail when a package's exports are not named in the documentation cmds: - python3 scripts/check-doc-coverage.py reuse:check: desc: FAIL if a function taking a statement is not covered by the reuse test cmds: - python3 scripts/check-reuse-coverage.py tasks:check: desc: FAIL if a package has fewer end-to-end task tests than its floor cmds: - python3 scripts/check-task-tests.py detector:pg: desc: Re-read Postgres's command list and ALTER TABLE grammar from a live server into pg/testdata (psql must reach it; PG_MAJOR names the files) vars: PG_MAJOR: '{{.PG_MAJOR | default "17"}}' cmds: - psql -X -c '\h' > pg/testdata/commands-{{.PG_MAJOR}}.txt - psql -X -c '\h ALTER TABLE' > pg/testdata/alter-table-{{.PG_MAJOR}}.txt - go test ./pg/ -run TestDetector -v detector:sqlite: desc: Re-fetch SQLite's grammar index into sqlite/testdata/lang-index.txt and run the detector cmds: - curl -sS --fail --max-time 30 https://sqlite.org/lang.html | python3 scripts/sqlite-lang-index.py > sqlite/testdata/lang-index.txt.new - mv sqlite/testdata/lang-index.txt.new sqlite/testdata/lang-index.txt - go test ./sqlite/ -run TestDetector -v # The engine proofs. SQLite needs nothing; Postgres and MySQL need a server, # and each driver module's tests skip loudly without one. These tasks make a # throwaway server, point the tests at it and take it away again. The # defaults below are what the scratch servers use; override any on the # command line, e.g. task test:mysql MYSQL_DSN='user:pw@tcp(host:3306)/db'. # The test commands set SQLB_*_DSN inline rather than under env: because Task # lets an exported shell variable beat a task's env: block, so a shell that # exports SQLB_PG_DSN (a dev box's secrets file) would silently point # test:pg18 at that database instead of the scratch container. engines:mysql:up: desc: Start a throwaway MySQL 8.4 container on 127.0.0.1:{{.MYSQL_PORT}} and wait until it accepts queries vars: MYSQL_PORT: '{{.MYSQL_PORT | default "33069"}}' MYSQL_IMAGE: '{{.MYSQL_IMAGE | default "mysql:8.4"}}' cmds: - docker run -d --rm --name sqlb-mysql-scratch -e MYSQL_ROOT_PASSWORD=sqlb -e MYSQL_DATABASE=sqlb -p 127.0.0.1:{{.MYSQL_PORT}}:3306 {{.MYSQL_IMAGE}} - task: engines:mysql:wait engines:mysql:wait: desc: Wait up to two minutes for the scratch MySQL to accept queries (its first start initialises the data directory) cmds: - | for i in $(seq 1 60); do if docker exec sqlb-mysql-scratch mysql -uroot -psqlb -e 'SELECT 1' sqlb >/dev/null 2>&1; then echo "mysql ready"; exit 0 fi sleep 2 done echo "mysql did not become ready"; exit 1 engines:mysql:down: desc: Stop the scratch MySQL container, which --rm then removes with its data cmds: - docker stop sqlb-mysql-scratch engines:pg:up: desc: Create the scratch Postgres database {{.PG_DB}} on the local server psql reaches vars: PG_DB: '{{.PG_DB | default "sqlb_scratch"}}' cmds: - createdb {{.PG_DB}} engines:pg:down: desc: Drop the scratch Postgres database {{.PG_DB}} vars: PG_DB: '{{.PG_DB | default "sqlb_scratch"}}' cmds: - dropdb --if-exists {{.PG_DB}} engines:pg18:up: desc: Start a throwaway Postgres 18 container on 127.0.0.1:{{.PG18_PORT}} and wait until it accepts queries, for the constructs that need 18 vars: PG18_PORT: '{{.PG18_PORT | default "54318"}}' PG18_IMAGE: '{{.PG18_IMAGE | default "postgres:18"}}' cmds: - docker run -d --rm --name sqlb-pg18-scratch -e POSTGRES_PASSWORD=sqlb -p 127.0.0.1:{{.PG18_PORT}}:5432 {{.PG18_IMAGE}} - | for i in $(seq 1 60); do if docker exec sqlb-pg18-scratch pg_isready -U postgres >/dev/null 2>&1; then exit 0; fi sleep 2 done echo "sqlb-pg18-scratch did not accept queries within two minutes" >&2 exit 1 engines:pg18:down: desc: Stop the scratch Postgres 18 container cmds: - docker rm -f sqlb-pg18-scratch >/dev/null 2>&1 || true test:pg18: desc: Run the Postgres proof against the scratch Postgres 18 container, which is what covers the constructs 17 refuses - virtual generated columns, NOT ENFORCED constraints, the wider ALTER CONSTRAINT and temporal keys vars: PG18_DSN: '{{.PG18_DSN | default "postgres://postgres:[email protected]:54318/postgres?sslmode=disable"}}' cmds: - SQLB_PG_DSN='{{.PG18_DSN}}' go test -race -count=1 ./contrib/driver-pgx/... ./contrib/driver-pgx/enginetest/... ./contrib/vet/... ./contrib/vet/enginetest/... ./contrib/migrate/... ./contrib/migrate/enginetest/... test:sqlite: desc: Run the SQLite proof - the conformance suite and every sqlite construct and DDL statement - with the race detector dir: contrib/driver-sqlite/enginetest cmds: - go test -race -count=1 ./... test:pg: desc: Run the Postgres proof against PG_DSN (default the scratch database) with the race detector - driver-pgx, vet's catalogue and drift checks, and the migration ledger vars: PG_DSN: '{{.PG_DSN | default "postgres:///sqlb_scratch?sslmode=disable"}}' cmds: - SQLB_PG_DSN='{{.PG_DSN}}' go test -race -count=1 ./contrib/driver-pgx/... ./contrib/driver-pgx/enginetest/... ./contrib/vet/... ./contrib/vet/enginetest/... ./contrib/migrate/... ./contrib/migrate/enginetest/... test:mysql: desc: Run the MySQL proof against MYSQL_DSN (default the scratch container) with the race detector - driver-mysql, vet's catalogue and drift checks, and the migration ledger vars: MYSQL_DSN: '{{.MYSQL_DSN | default "root:sqlb@tcp(127.0.0.1:33069)/sqlb"}}' cmds: - SQLB_MYSQL_DSN='{{.MYSQL_DSN}}' go test -race -count=1 ./contrib/driver-mysql/... ./contrib/driver-mysql/enginetest/... ./contrib/vet/... ./contrib/vet/enginetest/... ./contrib/migrate/... ./contrib/migrate/enginetest/... test:engines: desc: Start every scratch server, run the SQLite, Postgres 17, Postgres 18 and MySQL proofs, and remove the servers even when a proof fails cmds: - task: engines:pg:up - task: engines:pg18:up - task: engines:mysql:up - defer: { task: engines:mysql:down } - defer: { task: engines:pg18:down } - defer: { task: engines:pg:down } - task: test:sqlite - task: test:pg - task: test:pg18 - task: test:mysql detector:mysql: desc: Re-read MySQL's DDL statement list from the scratch container into mysql/testdata and run the detector cmds: - | { echo "# MySQL $(docker exec sqlb-mysql-scratch mysql -uroot -psqlb -N -e 'SELECT version()' 2>/dev/null): HELP 'Data Definition', captured $(date +%Y-%m-%d) from the scratch container." docker exec sqlb-mysql-scratch mysql -uroot -psqlb -N -e "HELP 'Data Definition'" 2>/dev/null | tail -n +2 | sed 's/^ *//' } > mysql/testdata/ddl-8.4.txt - go test ./mysql/ -run TestDetector -v detector: desc: Run every DDL detector against its checked-in list, without refetching cmds: - go test ./pg/ ./sqlite/ ./mysql/ -run TestDetector -v docs:commands: desc: FAIL if COMMANDS.md does not describe every task in this Taskfile exactly; regenerate with python3 scripts/gen-commands-doc.py cmds: - python3 scripts/gen-commands-doc.py --check docs:commands:gen: desc: Regenerate the task reference in COMMANDS.md from this Taskfile cmds: - python3 scripts/gen-commands-doc.py docs:not-built: desc: FAIL if docs/ddl/not-built.md lacks a section for a partial or left-out detector entry, or its appendix is stale cmds: - python3 scripts/gen-not-built.py --check docs:not-built:gen: desc: Regenerate the detector appendix in docs/ddl/not-built.md cmds: - python3 scripts/gen-not-built.py docs:reference: desc: Regenerate the reference table in each engine package's page cmds: - python3 scripts/regen-reference.py lint: desc: Run golangci-lint in every module cmds: - for: { var: MODULES } task: module:lint vars: { DIR: '{{.ITEM}}' } module:lint: internal: true dir: '{{.DIR}}' cmds: - golangci-lint run ./... fmt: desc: Format every Go file cmds: - gofmt -w . tidy: desc: Tidy every module cmds: - for: { var: MODULES } task: module:tidy vars: { DIR: '{{.ITEM}}' } module:tidy: internal: true dir: '{{.DIR}}' cmds: - go mod tidy cookbook: desc: Print the cookbook recipes with their rendered SQL cmds: - go test ./examples/cookbook -run Example -v surface: desc: Print the Postgres surface catalogue with its rendered SQL cmds: - go test ./examples/pgsurface/... -run Example -v names:check: desc: Fail if a tracked file or commit message holds a private name (list read from ~/.config/names-guard/terms.txt, never stored here) cmds: - bash scripts/check-names.sh hooks:install: desc: Use the repo hooks in .githooks (private-name guard on commit and push) for this clone cmds: - git config --local core.hooksPath .githooks |
| 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. |