Forward IMAGE_ID
from Buildkite environment
#47
Closed
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.
I wanted to check if the agent had
IMAGE_ID =~ ^xcode
and runbrew install xcodes
if so in a pre-commit hook, but it turns out that env var is not available to the scripts.I tried to add tests for this change but run into a limitation with the setup.
I started by duplicating the test from
BuildkiteScriptBuilderTests
that verifies that allBUILDKITE_*
values are copied and modified it to useIMAGE_ID
from a new.env
file:hostmgr/Tests/libhostmgrTests/BuildkiteScriptBuilderTests.swift
Lines 62 to 69 in 40287d2
I was surprised to see it passed. I then realized that test verifies the ability of the method to copy all env vars matching the given pattern from the given file. It makes no assertion on whether we do copy
BUILDKITE_
env vars at runtime. The component responsible for that behavior isGenerateBuildkiteJobScript
from thehostmgr
executable target.I don't know how to test an executable target. As a matter of fact, we do have a draft of test for
hostmgr
which does not run because not configured inPackage.swift
,SyncVMImagesCommandTests
.I have a "solution" in mind, which I'll propose in a dedicated issue. But for the time being, this change does the job of forwarding
IMAGE_ID
.