Configuration of CI/CD pipeline for multi platform C++ builds like arm64,amd64 & win64

How to configure CI/CD for multiple platforms and runners?

To keep it really simple I have a hello-world application (4 lines of code) in C++ using the CMake tool.

I have registered multiple runners in shell mode.

  • Ubuntu Server 22.04 LTS (x86_64)
  • Ubuntu Server 20.04 LTS (x86_64)
  • Raspberry Pi4 Rasbian (aarch64/arm64)
  • Windows 10 Professional

So how do I configure the GitLab project, gitlab-runners and the .gitlab-ci.yml file?

This in order to:

  1. Trigger multiple runners for each targeted OS to run a pipeline.
  2. Only the jobs for that target OS are executed which are configured .gitlab-ci.yml.

I’m new at this CI/CD stuff and it is probably very simple to do since multi-platform is very common :slight_smile: today.

Update: Got it working … but is this the way to go?

Below the main gitlab-ci configuration file (see here on my own server) Because you cannot define an individual pipeline file per branch in GitLab I created multiple branches.

  • dev-lnx-arm64
  • dev-lnx-amd64
  • dev-win-amd64 (still a work in progress)

So the pipe line is triggered for protected branches only and jobs are included depending on the postfix of the branch name.

Variables are used to set the global tags for jobs in section default:tags to select right runner for linux arm64 or amd64.

image

workflow:
  # Only run pipeline on protected branches.
  rules:
    # Rule boolean needs to be evaluated this way ?!
    - if: '$CI_COMMIT_REF_PROTECTED == "true"'

include:
  # Include variables for Linux amd64.
  - local: ".gitlab/lnx-amd64.gitlab-ci.yml"
    rules:
      - if: '$CI_COMMIT_BRANCH =~ /^.+-lnx-amd64$/'
  # Include variables for Linux arm64.
  - local: ".gitlab/lnx-arm64.gitlab-ci.yml"
    rules:
      - if: '$CI_COMMIT_BRANCH =~ /^.+-lnx-arm64$/'
  # Include common jobs for all branches.
  - local: ".gitlab/common-c++.gitlab-ci.yml"
  # Include GNU compiler jobs for Linux for branches amd64 and arm64.
  - local: ".gitlab/gnu-main.gitlab-ci.yml"
    rules:
      - if: '$CI_COMMIT_BRANCH =~ /^.+-lnx-(arm64|amd64)$/'
  # Include GW compiler jobs for Linux specific amd64 branches.
  - local: ".gitlab/gw-main.gitlab-ci.yml"
    rules:
      - if: '$CI_COMMIT_BRANCH =~ /^.+-lnx-amd64$/'

# Additional variables needed for this file.
variables:
  SF_TEST_TARGET: "hello-world-test"
  SF_RUN_TARGET: "hello-world"

# Defaults for all jobs.
default:
  # Tags determine the selection of a runner.
  tags:
    # Variables 'SF_TARGET_OS' and 'SF_TARGET_ARCH' depends on the include-file
    # which on its turn depends on the commit branch name.
    - "${SF_TARGET_OS}"
    - "${SF_TARGET_ARCH}"
    - cplusplus

# Obligatory in this setup of jobs depending on or needs it.
# Reports the environment vars set for the job.
job-check:
  # Common template job.
  extends: .tpl-env-dump
  stage: check

There are a lot of CI/CD templates available but I’ve not been able to find any dealing with this.

@arjanvo welcome to the forum!

using the parrallel:matrix keyword should do what you are looking to do. This documentation page has a simple example to choose different runner tags for each job.

I hope this helps!

-James H, GitLab Product Manager, Verify:Pipeline Execution

I appreciate your reply

Yes, I have seen the parallel:matrix solution but I’m not sure if it is applicable since job:scripts are for the Windows gitlab-runner in PowerShell and for Linux in Bash.
Maybe if I get the bash.exe from the Window Git install working from the runner that would be great since then it for all OS-platforms the same.

Another thing is that testing the pipeline for a single OS gets a sh*tload of jobs because of the matrix.
But then again the matrix could be put in template job like .tpl-matrix: which is in a separate file and is conditionally included depending on the branch name post-fix i.e. .

Currently my working GitLab-CI solution has a README on how mine is working.
(Visual studio is a work in progress)

For the whole project there also a README.

My conclusion is that Windows as a development environment is real hell.
Allowing symbolic-links for all users and setting up GitLab-Runner as a service running under other user then SYSTEM so you can debug the CI errors under actual conditions.
Visual Studio does not support CMake well and only application targets are visible.
And do not forget the “amount of clicking” to get simple stuff done in VS.

Sorry about the Windows ranting.
When you’re a JetBrains’s CLion user then you know what I’m talking about.

If you have any remarks/pointers don’t hesitate.