Have multiple runners, use CMake to build tests, build and test stage have to run on same runner

BLUF: Is there a way to force just 2 stage to runner on the same runner but still allow it to be any of the 4 runners that are available?? I know about tags but tags would have the stage run on only one runner and make the others useless.

SITUATION: We are developing in C++ and are using CMake to build our project as well as build our unit tests. We are using CTest to execute those tests. We have a self managed instance of GitLab and now of the project up and running. I have my .gitlab-ci.yml with three stages build, test, deploy and it was developed in a Sandbox with a single runner and had no issues successfully completely the pipeline. Now that I am on the production project with 4 runners my test stage is failing. The reason test is now failing is the CMake generates the CTestTestfile.cmake file which are then used in the next stage of Test; however, the absolute path to the tests are from the build stage which if the test stage executes on a different runner then the test are in a different location as the session ID which is part of the path is not the same. I need to execute the tests with CTest so that the xml output file gets created.

Why not use project relative pathes? Or do you have a session number somewhere inside your project (and why?)? Even then you could just move the CTestTestfile.cmake to a folder which has a stable path(relative to the project location), make that an artifact and copy it back where you need it in the test step. Or are the constant path inside the cmake file? Then again the question is whether you can’t change the build script to make them relative.
I get that this is not what you asked for, but I think that relying on something arbitary a specific runner does is a bad idea from a portability point of view.

1 Like

CMake/CTest require the use of absolute paths. CMake Policy CMP 0076.

For now I just used the tagging

Looking at CMP0076 — CMake 3.21.20210722-gf858a3b Documentation it is not a requirement to use absolute path with CMake but a setting which decides how relative path are handled inside CMake.