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. Setup tasks' sources and commands are merged into the parent task's fingerprint.
tasks:
enforce-version:
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 .Cache generated files so that subsequent runs (or other machines) can skip execution entirely. The url and lock fields are shell commands evaluated at runtime; TASK_CACHE_HASH (SHA256 of sources) is injected automatically.
tasks:
build:
sources:
- src/**/*.go
generates:
- bin/app
cache:
enabled: test -n "$REDIS_URL" # optional, bool or shell
url: echo "file:///tmp/cache/$TASK_CACHE_HASH.zip"
lock: echo "redis://$REDIS_URL/lock:build"
cmds:
- go build -o bin/app .Tasks with sources and generates automatically acquire a POSIX advisory file lock (stored in .task/) to prevent concurrent execution of the same task.
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.
- 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)
-> merge setup fingerprints into parent sources
-> acquire lock (file or redis)
-> run deps (parallel)
-> check fingerprint
-> try restore from cache (file:// or redis://)
-> if miss: execute task, then save to cache
-> release lock