Repository navigation
test: shellcheck every generated script; spawn:* tag round-trip contract (#689) - #1249
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ract (#689) shellcheck gate (#689 C): internal/shellcheckgate runs shellcheck -S warning on each rendered generator (and the scripts it writes through quoted heredocs). Generators are discovered from source by their shell shebang; one no test checks fails the build. Skips locally without shellcheck, fails under CI=true; the Test job installs v0.11.0 pinned by version and sha256. Baseline findings fixed: slurm conversions quote the job name and working dir and stop on a failed cd; EFA cds are checked; the unused TASK_ID in the wrapper is gone. Intentional patterns get scoped, reasoned disables. Tag contract (#689 A): every spawn:* key buildTags writes must be read somewhere and every key read must be written somewhere, both discovered structurally across the repo, with a named allowlist for keys written outside spawn's code. A Substrate round trip checks each launch tag lands in exactly one place on InstanceInfo and every tag-sourced field is filled.
scttfrdmn
force-pushed
the
test/689-shellcheck-tags
branch
from
October 20, 2026 20:11
67e84c1 to
59a3cce
Compare
…wn:instance-id via ElasticIPInstanceTagKey)
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.
Fixes #689
This covers parts A and C of #689. Part B (AL2023 container checks) is not done here: it needs a container runtime in CI and is not cheap. A comment on #689 explains why.
(a) shellcheck CI gate (#689 C)
internal/shellcheckgate.Check(t, id, script)runsshellcheck -S warning --shell=bash. It also checks every nested script the generated one writes through a quoted-delimiter heredoc (/tmp/spawn-command.shin the bootstrap, for example), because shellcheck treats a heredoc body as data. It skips when shellcheck isn't installed locally and fails underCI=true. The exception is Windows, where it skips: the windows-latest job doesn't install shellcheck, and the verdict on a Linux script doesn't depend on the GOOS the test runs on.BuildLinuxBootstrap, minimal and with every optional block onGenerateWrapper,GeneratePooledJobScript(host and container) andGenerateFlushScriptupgrade-spored, the terminate flush, SSM key injection, burst, and a composed job-array member (bootstrap + storage + MPI)TestEveryShellGeneratorIsShellchecked(root) parses every non-test .go file. Any function or var holding a string literal with a shell shebang at the start of a line is a generator, and someshellcheckgate.Checkcall must name it. It also fails on a Check id that names no declaration, and on an empty discovery.Test, pinned by version and sha256. The sha256 matches the GitHub release asset digest, and the install follows the same pattern as staticcheck.Findings from the baseline pass
cd <WorkingDir>was unquoted and unchecked, andexport SLURM_JOB_NAME=<name>was unquoted. Both are now shell-quoted, withcd ... || exit 1.TestGeneratedScripts_QuoteJobNameAndWorkingDirruns the scripts and fails against the old code.cd /tmpandcd aws-efa-installerare now checked explicitly. Failure stays fatal, as it already was under the bootstrap'sset -e.TASK_ID=in the task wrapper. Nothing read it, and it wasn't exported.if [ "{{.JobArrayIndex}}" -eq 0 ]: the rank is fixed at render time.for SPAWN_MP in '<one path>': a list of quoted mount points.sudo docker inspect ... > "$PROV_DIR/...": the wrapper user owns$PROV_DIR.(b) Tag round-trip contract (#689 A)
TestSpawnTagContract(root): writers and readers are discovered across every non-test .go file, nested lambdas included, and matched structurally.Tag{Key: ...}, a map-literal key, an assigned index, a set/append-style call arg, shellKey=spawn:x,.case,==, a get/lookup-style call arg, an EC2tag:filter orFilterTag, shellName=key,Values=spawn:x.tagprefix.Tag("x"), or string constants (e.g.spotrequest.TypeTag).pkg/aws.buildTagswrites is read nowhere, or when a key read is written nowhere. Family prefixes (spawn:param:,spawn:dns-) are handled. It also fails if an allowlist entry goes stale.spawn:stack/base/deprecated(user-set viacreate-ami --tag), legacyspawn:ttl-remaining(written before Stopped instances: 'spawn status' SSHes to ::1 (localhost) and fails; compute from earlier runs is dropped after restart; stop message says TTL pauses but it doesn't #928), and nine spored observability keys that no spawn path can set (filed as spored's metrics/tracing/idle-cpu tags can't be set by any spawn path; the monitoring doc's --tag example is refused #1244).TestLaunchTagsRoundTripThroughListInstances(pkg/aws): this is the test Testing: substrate tag round-trip contract, AL2023 container checks, shellcheck on rendered user-data #689 actually proposes. It runs the realbuildTagswith distinct values, then RunInstances into in-process Substrate, then the realListInstances. Every launch tag must land in exactly one of a named field,TagsorParameters, and every tag-sourcedInstanceInfostring field must be filled by some tag.Gates watched failing against compiling reverts
Check(t, "pkg/slurm.generateMPIScript", ...)with_ = generateMPIScript(job)and renamed another id. Result: "not shellchecked" for both generators, plus "not a declaration" for the renamed id.CI=true(clean PATH, through the hermetic wrapper) fails; withoutCIit skips.spawn:dcv-session-idin buildTags fails both directions. Renaming thecompletion-delayreader in pkg/provider fails both directions.spawn:sweep-sizecase inlistInstancesInRegionfails with "SweepSize is not filled by any tag". Also copyingspawn:job-array-idintoTags(the drainJobArray has never terminated anything: it filters on a tag that InstanceInfo.Tags never contains #683 shape) fails with "in both InstanceInfo.JobArrayID and Tags".Checks
make checkpasses exceptcheck-build-tags, which also fails on unmodified main because of /private/tmp paths. golangci-lint (root,--allow-parallel-runners) reports 0 issues; semgrep is clean. No help text or exported API changed.Limits
Follow-ups filed
spawn slurm convertoutput always failsspawn launch --params. Itsscriptparam contains newlines.--tag spawn:metrics-enabled=trueis refused.