diff --git a/.agents/rules/testing.md b/.agents/rules/testing.md index 1f6af36d68c..cb1b22538b2 100644 --- a/.agents/rules/testing.md +++ b/.agents/rules/testing.md @@ -143,7 +143,7 @@ Ignore = ["databricks.yml"] # parsed as EnvMatrix.Ignore, not top-level Ignore - `musterr CMD...`: run CMD and fail the whole test if it *succeeds*; on the expected failure the script continues. Use to assert a command must error. - `withdir DIR CMD...`: run CMD with the working directory set to DIR, restoring it afterwards. - `git-repo-init`: initialize a deterministic git repo (fixed user/email, no hooks) and commit `databricks.yml`. -- `uuid`, `sethome DIR`, `venv_activate`, `as-test-sp CMD...`, `readplanarg FILE`, `envsubst`: see `acceptance/script.prepare` for the full list and exact semantics. +- `uuid`, `sethome DIR`, `venv_activate`, `as-test-sp CMD...`, `readplanarg FILE`, `envsubst`, `unset_ci_env`: see `acceptance/script.prepare` for the full list and exact semantics. **RULE: Wrap commands whose invocation should be visible in `output.txt` with `trace`.** The `>>> ...` line ties each block of output to the command that produced it; without it the output is an unlabeled wall of text. diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index 86e0c4ccf69..a0343b728ab 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -66,7 +66,8 @@ title "in a Claude Code session the auth docker configure child adds no install # As in a Claude Code tool call, with no session id, so the session throttle # can't be what keeps the child quiet. The CI variables would drop the native # line in CI only. -unset CI GITHUB_ACTIONS GITLAB_CI JENKINS_URL TF_BUILD CIRCLECI TRAVIS BITBUCKET_BUILD_NUMBER PROJECT_ID CODEBUILD_BUILD_ARN TFC_RUN_ID CLAUDE_CODE_SESSION_ID +unset_ci_env +unset CLAUDE_CODE_SESSION_ID # A host CLAUDE_CONFIG_DIR would move the plugin lookup away from the isolated HOME. unset CLAUDE_CONFIG_DIR export CLAUDECODE=1 CLAUDE_CODE_CHILD_SESSION=1 diff --git a/acceptance/cmd/aitools/claude-config-dir/script b/acceptance/cmd/aitools/claude-config-dir/script index ad72ab82556..b6ffcaa61a3 100644 --- a/acceptance/cmd/aitools/claude-config-dir/script +++ b/acceptance/cmd/aitools/claude-config-dir/script @@ -3,8 +3,7 @@ export CLAUDECODE=1 # enables the native line; CI suppresses it. export CLAUDE_CODE_CHILD_SESSION=1 unset CLAUDE_CODE_SESSION_ID -# CI and the CI/CD provider markers the SDK detects (GitHub Actions sets both). -unset CI GITHUB_ACTIONS GITLAB_CI JENKINS_URL TF_BUILD CIRCLECI TRAVIS BITBUCKET_BUILD_NUMBER PROJECT_ID CODEBUILD_BUILD_ARN TFC_RUN_ID +unset_ci_env # Hint-exempt commands (aitools, auth, one-shot lookups such as version and current-user me, # completion) skip the install hint; clusters list exercises it against the fake server. diff --git a/acceptance/cmd/aitools/telemetry/hint/script b/acceptance/cmd/aitools/telemetry/hint/script index f1edd5eec54..0282ff401a4 100644 --- a/acceptance/cmd/aitools/telemetry/hint/script +++ b/acceptance/cmd/aitools/telemetry/hint/script @@ -3,8 +3,7 @@ sethome home export CLAUDECODE=1 # As inside Claude Code: enables the native line (not in CI). export CLAUDE_CODE_CHILD_SESSION=1 -# CI and the CI/CD provider markers the SDK detects (GitHub Actions sets both). -unset CI GITHUB_ACTIONS GITLAB_CI JENKINS_URL TF_BUILD CIRCLECI TRAVIS BITBUCKET_BUILD_NUMBER PROJECT_ID CODEBUILD_BUILD_ARN TFC_RUN_ID +unset_ci_env unset CLAUDE_CODE_SESSION_ID # A host CLAUDE_CONFIG_DIR would move the plugin file away from the isolated HOME. unset CLAUDE_CONFIG_DIR diff --git a/acceptance/script.prepare b/acceptance/script.prepare index 506e03ce2be..ffe6f1a18ba 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -197,3 +197,12 @@ readplanarg() { printf "" fi } + +# unset_ci_env clears CI and the CI/CD provider markers, so a test behaves the +# same in CI as on a laptop. The provider list mirrors listCiCdProviders in the +# Go SDK's useragent/cicd.go (read by useragent.CiCdProvider()); keep it in +# sync when the SDK adds a provider. PROJECT_ID alone defeats the Google Cloud +# Build check, which requires all of its variables. +unset_ci_env() { + unset CI GITHUB_ACTIONS GITLAB_CI JENKINS_URL TF_BUILD CIRCLECI TRAVIS BITBUCKET_BUILD_NUMBER PROJECT_ID CODEBUILD_BUILD_ARN TFC_RUN_ID +}