Closed mokagio closed 1 year ago
I'm wondering if you need IMAGE_ID for your purpose? Maybe you can check if the pipeline is running on a Mac? Like
[[ $(uname) == 'Darwin' ]] && brew install xcodes
I don't know how to test an executable target
So..mostly you can't, which is why I made the libhostmgr
package, from which things are easy to test – IMHO ideally the hostmgr
tool would just be the CLI bits wrapping the actual functionality in libhostmgr
.
WDYT?
@jkmassel
So..mostly you can't, which is why I made the libhostmgr package, from which things are easy to test – IMHO ideally the hostmgr tool would just be the CLI bits wrapping the actual functionality in libhostmgr.
WDYT
Yeah, that setup seems like a good approach to build a CLI. Functional, testable, fat core; imperative, untested, thin shell. I made a suggestion in #48 about it.
With xcodes
being part of the tools available in the CI images starting 14.1, h/t @crazytonyli , the need for this is purely "just in case, for the future".
Closing.
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:https://github.com/Automattic/hostmgr/blob/40287d22e53a6c593d37a37b3479bd2459eab94e/Tests/libhostmgrTests/BuildkiteScriptBuilderTests.swift#L62-L69
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
.