Search code examples
.net-coreautomated-testsyamlgitlab-cigitlab-ci-runner

GitLab Runner stopping after `dotnet restore` or `dotnet test`


I am new to CI and tried to add the following yaml to our project.

image: microsoft/dotnet:latest

stages:
  - test

test: 
  stage: test
  before_script:
    - 'echo Stage - Test started'
    - 'dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools'
  script:  
    - 'cd "./My Project"'  
    - 'dotnet test --settings:./Settings/CodeCoverage.runsettings --collect:"XPlat Code Coverage"'
    - './tools/reportgenerator "-reports:./Tests/*/TestResults/*/coverage.cobertura.xml" "-targetdir:Reports_Coverage" -reportTypes:TextSummary'
    - 'cat ./Reports_Coverage/Summary.txt'
  after_script:
    - 'echo Stage - Test finished'

On the job I get the following output:

Running with gitlab-runner 13.7.0 (943fc252) on ***
Resolving secrets
Preparing the "kubernetes" executor
Using Kubernetes namespace: gitlab-pipeline
Using Kubernetes executor with image microsoft/dotnet:latest ...
Preparing environment
Running on*** via ***...
Getting source from Git repository
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/***/.git/
Created fresh repository.
Checking out 07e98444 as ***...
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ echo Stage - Test started
Stage - Test started
$ dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
You can invoke the tool using the following command: reportgenerator
Tool 'dotnet-reportgenerator-globaltool' (version '4.8.4') was successfully installed.
$ cd "./My Project"
$ dotnet test --settings:./Settings/CodeCoverage.runsettings --collect:"XPlat Code Coverage"
Running after_script
Running after script...
$ echo Stage - Test finished
Stage - Test finished
Cleaning up file based variables
ERROR: Job failed: command terminated with exit code 1

I tinkered around a little bit and realized, that this minified yaml also fails:

image: microsoft/dotnet:latest

stages:
  - test

test: 
  stage: test
  before_script:
    - 'cd "./My Project"'  
    - 'dotnet restore'
  script:  
    - 'dotnet test --no-restore'

This generates an equal output, except it stops at dotnet restore. I honestly don't know what to do, since this is the most minified version of a test I found. Did I mess up something within the project, or is the problem within the GitLab Runner itself?

Project Version: .net Core App 3.1


Solution

  • Not a real solution, but I found the issue behind this. You can set the verbosity level of the dotnet test command (documentation). While doing so, I found out that you obviously cannot run a WPF project within a Linux based GitLab Runner.