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.

I had a similar environment in my CI pipeline and always met sporadic issue: cannot find a requested file in test phase when 2 pipelines are running in 2 runners concurrently.

My environment:

  • cmake in build job,*
  • ctest in test job,*
  • pipelines ran on 2 gitlab-runners (version 15.6)
  • executor is our own docker windows.

What works for me is, I finally combined build job and test job into one job. In this way, the test part will directly reuse the artifacts generated by the build part in the same job. Otherwise, in my understanding of how gitlab runner works, the test job will always have to download the artifacts from the gitlab-helper container into our own container. My best guess is, somewhere went wrong exactly in this downloading step that is invisible to us. It seemingly has nothing to do with absolute path.

I tried several approaches to fix this problem, like set the GIT_CLEAN_FLAGS: -ffdx globally and set GIT_CLEAN_FLAGS: none in the test job, like set the ARTIFACT_DOWNLOAD_ATTEMPTS: 2 in test job to ensure the artifacts can be downloaded successfully. They all failed. The failure per see is funny. Because the test jobs will all pass successfully but no tests were executed. Simply no tests were found in the artifact directory by ctest. It looks like empty tests.

I would appreciate if someone can share his or her experience what exactly the problem is in our situation.