Fork of go-task/task (v3.49.1) with opinionated changes focused on build-system reliability: deterministic fingerprinting, distributed caching and locking, and setup tasks.
Source: github.com/wallix/task
- Remote taskfiles --
http://andgit://includes are no longer supported. Related CLI flags (--download,--offline,--insecure,--timeout,--clear-cache,--trusted-hosts,--expiry,--remote-cache-dir,--cacert,--cert,--cert-key) have been removed. - Timestamp fingerprinting -- only checksum-based fingerprinting remains. The
methodfield on tasks is removed. nonefingerprint method -- tasks either use checksum fingerprinting or have nosources.
A new setup field runs tasks unconditionally and sequentially before deps and fingerprint checks. Unlike deps, setup tasks always run regardless of whether the parent is up-to-date, and they do not affect the parent's fingerprint. Use run: once to avoid re-executing shared setup tasks.
tasks:
enforce-version:
run: once
cmds:
- date +%Y-%m-%d > version.txt
build:
setup:
- enforce-version
sources:
- version.txt
- src/**/*.go
generates:
- bin/app
cmds:
- go build -ldflags "-X main.buildDate=$(cat version.txt)" -o bin/app .For large generated directories where hashing every file is expensive, a generates entry can specify a fingerprint file -- a single representative file used for checksum-based up-to-date detection instead of hashing every file matched by the glob. The full glob is still used for cache operations (save/restore), so all files are archived correctly.
Four YAML forms are supported in sources and generates:
generates:
# Scalar: simple glob pattern (hashes all matched files)
- "build/**/*"
# Exclude: negated pattern
- exclude: "build/tmp/**"
# Glob + fingerprint: the glob defines the full set of files for caching,
# while fingerprint names a single file for up-to-date checks.
- glob: "node_modules/**/*"
fingerprint: "node_modules/.yarn-state.yml"
# From: inherit entries from related tasks (see "Inherited sources/generates")
- from: depsExample: yarn install with fingerprint
tasks:
install:
sources:
- package.json
- yarn.lock
generates:
- glob: "node_modules/**/*"
fingerprint: "node_modules/.yarn-state.yml"
cmds:
- yarn install --immutableHere node_modules/ may contain thousands of files, but only .yarn-state.yml is hashed for staleness checks. When caching is enabled, the full node_modules/**/* glob (plus the fingerprint dotfile) is archived.
Example: mixed generates with caching
tasks:
build:
sources:
- src/**/*.ts
- package.json
generates:
- "dist/**/*"
- glob: "node_modules/**/*"
fingerprint: "node_modules/.yarn-state.yml"
- exclude: "dist/tmp/**"
cache:
url: 'file:///tmp/cache/build-{{.CHECKSUM}}.zip'
cmds:
- npm run buildWrapper tasks can inherit sources and generates from their dependencies or cmd task-calls using the from: directive. This avoids duplicating glob patterns across tasks and ensures cache keys reflect the full input/output set. Entries are deduplicated automatically.
from: deps — copies entries from all direct dependencies:
tasks:
all:
sources:
- from: deps
generates:
- from: deps
cache:
url: 'file:///tmp/cache/all-{{.CHECKSUM}}.zip'
deps:
- build-a
- build-b
build-a:
sources: [src/a/**/*.go]
generates: [bin/a]
cmds: [go build -o bin/a ./cmd/a]
build-b:
sources: [src/b/**/*.go]
generates: [bin/b]
cmds: [go build -o bin/b ./cmd/b]from: cmds — copies entries from all cmd task-calls:
tasks:
build:
sources:
- from: cmds
generates:
- from: cmds
cmds:
- task: compile
- task: link
compile:
sources: [src/**/*.c]
generates: [build/**/*.o]
cmds: [make compile]
link:
sources: [build/**/*.o]
generates: [bin/app]
cmds: [make link]Literal globs and from: entries can be mixed freely:
sources:
- config.yml # own source
- from: deps # plus all dep sourcesCache generated files so that subsequent runs (or other machines) can skip execution entirely. The url and lock fields are Go templates with access to all task variables plus {{.CHECKSUM}} (SHA256 of sources, commands, and generates).
tasks:
build:
sources:
- src/**/*.go
generates:
- bin/app
cache:
enabled: '{{ne .REDIS_URL ""}}' # optional, template bool
url: 'file:///tmp/cache/build-{{.CHECKSUM}}.zip'
lock: 'redis://{{.REDIS_URL}}/lock:build-{{.CHECKSUM}}'
cmds:
- go build -o bin/app .Tasks with sources and generates automatically acquire a POSIX advisory file lock (stored in .task/). The lock key is taskname:sourcehash, so different source states don't contend on the same lock.
When cache.lock evaluates to a redis:// URL, locking is distributed across machines using Redis SET NX EX with TTL-based heartbeat renewal.
{{urlsafe .TASK}} percent-encodes a string for use in URLs, replacing special characters like colons from namespaced task names. Useful in cache URLs:
cache:
url: echo "redis://$REDIS_URL/cache:{{urlsafe .TASK}}/$TASK_CACHE_HASH"Show fingerprint status of tasks without running them:
task --status build # human-readable
task --status --json build # machine-readablePortable fingerprint state for CI/CD pipelines:
# On build machine
task --export-cache state.zip build test
# On CI machine
task --import-cache state.zipExports checksum state and generated files for up-to-date tasks as a ZIP archive.
--forceis now gentle by default ----forceonly forces the directly called task; dependent tasks still check their status. Use--force-allto force everything (previously the default--forcebehavior). TheTASK_X_GENTLE_FORCEexperiment flag has been removed.
- Richer fingerprints -- checksums now include serialized commands and variable data, not just file contents.
- Separate staleness reporting --
sourcesandgeneratesstaleness is tracked and reported independently.
setup tasks (unconditional, sequential)
-> acquire lock (file or redis)
-> run deps (parallel)
-> check fingerprint (sources + generates, including from: resolution)
-> try restore from cache (file:// or redis://)
-> if miss: execute task, then save to cache
-> release lock