Skip to content

feat(ci): add env: support to .docstore/ci.yaml DSL#473

Merged
dlorenc merged 1 commit into
dlorenc:mainfrom
ajayk:feat/ci-env-vars
May 9, 2026
Merged

feat(ci): add env: support to .docstore/ci.yaml DSL#473
dlorenc merged 1 commit into
dlorenc:mainfrom
ajayk:feat/ci-env-vars

Conversation

@ajayk

@ajayk ajayk commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds top-level and per-check env: to .docstore/ci.yaml so non-secret environment variables can be declared once instead of inlined into every step. Per-check env: overrides top-level on key collision.
  • Auto-injects CI=true plus 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 context; ds ci run synthesizes local stubs.
  • ValidateEnv enforces POSIX env-name shape (^[A-Za-z_][A-Za-z0-9_]*$) and rejects the reserved DOCSTORE_ prefix and CI key (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.
  • LLB env injection iterates sorted keys for a deterministic cache digest.

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.md calls this out explicitly and points users at secrets: or in-step export for volatile values like build timestamps.

Test plan

  • go build ./... clean
  • go vet ./... clean
  • go test ./internal/executor/... ./internal/ciconfig/... ./internal/secrets/... pass
  • Unit tests for ValidateEnv (valid keys, bad shapes, reserved prefix, error aggregation, nil-safety) and BuildAutoEnv (always-on CI=true, full population, zero/empty omission) pass locally
  • BuildKit-backed integration tests (TestEnvReachesStep, TestAutoEnvBeatsUserAttemptToShadow) — skipped locally (no Docker daemon), will run in CI
  • Manual: ds ci run against a repo with a top-level + per-check env: block

🤖 Generated with Claude Code

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]>
@dlorenc dlorenc merged commit af1d1fc into dlorenc:main May 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants