Matrix configuration for Linux amd64 and Linux arm64 using same steps

Hello, I am attempting to create a matrix job where I run a testing step on an ARM machine and the same set of steps on an x86 machine. However, I’m getting some YAML syntax errors:

executors:
  ubuntu-2004-arm64:
    machine:
      image: ubuntu-2004:current
      resource_class: arm-medium
  ubuntu-2004-amd64:
    machine:
      image: ubuntu-2004:current

jobs:
  test-multi-arch:
    parameters: 
      machine-arch: 
        type: executor
      arch:
        type: string
    executor: << parameters.machine-arch >>
    environment:
      ARCH: << parameters.arch >>
      BRANCH: multi-arch-tests
    steps:
       - run: uname -a

The resource_class line does not accept arm-medium, but this is considered valid for running arm machines, and I can use it in non-matrix builds. Does the validator/linter on the circleci website need to be updated? It would be awesome if someone has an example of a matrix build with Linux amd64 and Linux arm64. Many of the examples in the documentation seem to focus on docker containers, not virtual machines.

For instance, this worked:

jobs:
  build-and-test-multi-arch:
    machine:
      image: ubuntu-2004:current
    resource_class: arm-medium
    environment:
      ARCH: arm64
      BRANCH: multi-arch-tests
    steps:
       - echo Hello world

Thank you!
James

When you say “The resource_class line does not accept arm-medium” do you mean just during the schema validation phase of your IDE/editor or during the running of a build job?

If it is from a schema validation, it is not clear who is maintaining the JSON schema file currently and there seems to be a few locations on the web that tools may retrieve such files from. I use the following as my reference (as I used IntelliJ tools)

                 https://json.schemastore.org/circleciconfig.json

I have much the same problem as I use self-hosted runners which means that my naming of resource_class entries can not fit within the enum: validation list, so I’m stuck with a warning message every time I push my project back to git.

Hi Roger, thanks for following up. I did get it figured out, so I’ll post a follow up here.

The warning about the ‘arm-medium’ resource_class was in the CircleCI web interface. This interface appears when a build fails and you click the option that lets you edit config.yml in the browser. The web interface has a yaml validator that validates the yaml as you type. Once I resolved other issues I had in the config file, the warning was still there, but I was able to execute the jobs.

Here is the configuration I put in place to get matrix working between an ubuntu arm runner and ubuntu x86 runner:

# .circleci/config.yml
version: 2.1

executors:
  ubuntu2004arm64:
    machine:
      image: ubuntu-2004:current
    resource_class: arm-medium
  ubuntu2004amd64:
    machine:
      image: ubuntu-2004:current
    resource_class: medium

jobs:
    test-multi-arch:
      parameters:
        machine-type:
          type: executor
      executor: << parameters.machine-type >>
      environment:
        BRANCH: qemu-user-static
        NAMESPACE: seleniarm
     steps:
       - run:  uname -a

workflows:
  build:
    jobs:
      - test-multi-arch:
          machine-type: ubuntu2004arm64
      - test-multi-arch:
          machine-type: ubuntu2004amd64

Hope this helps others!

I just realized this isn’t officially a “matrix”, but this works for me since it’s just two options. I went with this configuration when dealing with unrelated bugs in that web interface where it was complaining about matrix errors. When I removed matrix, it was still complaining about it and attempted to run my jobs on a large instance. Once I committed and pushed changes locally, everything came together.

I just took a look at that feature and yes it is doing the same check as I see within my editor and with the same result. As CircleCI web GUI is doing such validation I guess they need to update the schema with all their machine types.

Do you know how we can notify them?

It would be best to just open a support ticket, the speed of response is based on which package you take from them, but they do respond.