feat(ci): add env: support to .docstore/ci.yaml DSL#473
Merged
Conversation
Adds top-level and per-check `env:` maps so users can set non-secret environment variables without inlining `export` commands into every step. Per-check entries override top-level for the same key. Auto-injects per-check: CI=true, DOCSTORE_RUN_ID, DOCSTORE_REPO, DOCSTORE_BRANCH, DOCSTORE_SEQUENCE, DOCSTORE_EVENT, DOCSTORE_BASE_BRANCH, DOCSTORE_PROPOSAL_ID, DOCSTORE_CHECK_NAME — sourced from the worker's job + trigger metadata. ds ci run synthesizes local stubs. ValidateEnv enforces POSIX env-name shape and rejects the reserved DOCSTORE_ prefix and CI key (case-insensitive) at config load. AutoEnv is applied last in the merge so its values cannot be silently shadowed even if validation is bypassed. Note: BuildKit env vars ARE part of the cache key (unlike secret mounts). docs/ci.md spells this out and points users at secrets: or in-step export for volatile values. Co-Authored-By: Claude Opus 4.7 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
env:to.docstore/ci.yamlso non-secret environment variables can be declared once instead of inlined into every step. Per-checkenv:overrides top-level on key collision.CI=trueplusDOCSTORE_RUN_ID,DOCSTORE_REPO,DOCSTORE_BRANCH,DOCSTORE_SEQUENCE,DOCSTORE_EVENT,DOCSTORE_BASE_BRANCH,DOCSTORE_PROPOSAL_ID,DOCSTORE_CHECK_NAME. Sourced from the worker's job + trigger context;ds ci runsynthesizes local stubs.ValidateEnvenforces POSIX env-name shape (^[A-Za-z_][A-Za-z0-9_]*$) and rejects the reservedDOCSTORE_prefix andCIkey (case-insensitive) at config load. AutoEnv is applied last in the merge, so its values are immune to user shadowing even if validation is bypassed.Cache-key footgun (documented)
Unlike
secrets:(BuildKit secret mounts, excluded from the cache key),env:values are part of the BuildKit cache key.docs/ci.mdcalls this out explicitly and points users atsecrets:or in-stepexportfor volatile values like build timestamps.Test plan
go build ./...cleango vet ./...cleango test ./internal/executor/... ./internal/ciconfig/... ./internal/secrets/...passValidateEnv(valid keys, bad shapes, reserved prefix, error aggregation, nil-safety) andBuildAutoEnv(always-onCI=true, full population, zero/empty omission) pass locallyTestEnvReachesStep,TestAutoEnvBeatsUserAttemptToShadow) — skipped locally (no Docker daemon), will run in CIds ci runagainst a repo with a top-level + per-checkenv:block🤖 Generated with Claude Code