I’m writing a matrix job definition for running integration tests against multiple platforms (windows
, mac
, linux
). The integration tests are defined as individual commands (test_foo
, test_bar
, etc.):
# jobs
integration_test:
parameters:
platform:
# type: string rather than executor; otherwise the conditions used below won't work
# See https://discuss.circleci.com/t/condition-on-executor-type/39711
type: string
test:
type: steps
executor: << parameters.platform >>
steps:
# various test setup steps omitted for brevity
- steps: << parameters.test >>
# workflows.<workflow>.jobs
- integration_test:
matrix:
platform: [linux, mac, windows]
test:
- [test_foo]
- [test_bar]
Unfortunately, my integration test commands take in a parameter to know whether they’re running on Windows or not*. I’m passing in my integrations tests as step
parameters, otherwise there is no way of running them; the following is invalid syntax:
steps:
# various test setup steps omitted for brevity
- << parameters.test >>
If there’s a way to reference commands by name, I’m not finding it in the documentation. Something like:
steps:
# various test setup steps omitted for brevity
- command: << parameters.test >>
The issue is that I can not alter passed in steps (to add the platform parameter). I can add parameters to the steps in the matrix definition, but those cannot reference the matrix parameters:
# workflows.<workflow>.jobs
- integration_test:
matrix:
platform: [linux, mac, windows]
test:
- [test_foo: { platform: << parameters.platform >> }]
- [test_bar: { platform: << parameters.platform >> }]
# Error: Error expanding: integration_test: matrix
# Arguments referenced without declared parameters: platform
* I’m not finding a better way of getting this information. In GitHub actions, I’d use the runner context ( ${{ runner.os }}
), but I’m not finding an equivalent in CircleCI. I see there’s a circleci/os-detect
orb, but it’s currently lacking Windows support… If I could get access to the platform info in my commands without needing to explicitly pass that in, then I wouldn’t have to pass in parameters in the first place.