coverage/pytest and gitlab CI not running

103 Views Asked by At

I am currently having two issues involving coverage/pytest and gitlab CI.

The bigger and more recent one is that pytest and coverage do nothing at all when i call them in the gitlab CI. I do not get any output or error message at all. Only at the end does the job return with a non-zero exit code and fail. It used to work previously but i after updating some of our dependencies i have been getting this issue.

Calling coverage --help does work normally and show the help message. However calling coverage run ... gives no output what so ever.

The other, less severe but older, problem is that coverage returns with a 0 exit code even for test failures. However i have not been able to reproduce this locally and thus do not have an idea where to start on how to resolve these two issues.

Maybe someone has seen something like that previously or has any idea what might be causing them?

Here is a cut down version of my .gitlab-ci.yml

workflow:
    rules:
        - if: $CI_COMMIT_REF_PROTECTED == "true"
        - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

default:
    tags:
        # Make you job be executed in a shared runner that has CVMFS mounted
        - cvmfs
    before_script:
        - set +e
        - alias python3="python"
        - sudo mv CommonAnalysisFramework ..
        - export CAFPATH="$PWD/.."
        - ln -s templates/UserSettingsGuideline.py UserSettings.py
        - source $CAFPATH/CommonAnalysisFramework/${SETUP_SCRIPT}

variables:
    SETUP_SCRIPT: setup_root628.sh

image: atlas/centos7-atlasos-dev

stages:
  - build
  - run
  - check
  - lint

test:
    stage: check
    before_script:
        - set +e
        - alias python3="python"
        - sudo mv CommonAnalysisFramework ..
        - export CAFPATH="$PWD/.."
        - ln -s templates/UserSettingsGuideline.py UserSettings.py
        - source $CAFPATH/CommonAnalysisFramework/${SETUP_SCRIPT}
        - source /cvmfs/sft.cern.ch/lcg/releases/LCG_104/pytest/7.4.0/x86_64-centos7-gcc12-opt/pytest-env.sh
        - source /cvmfs/sft.cern.ch/lcg/releases/LCG_104/pytest_cov/3.0.0/x86_64-centos7-gcc12-opt/pytest_cov-env.sh
        - unalias python3
    script:
        - set +e
        - echo " in main script"
        - coverage run --branch --source="." --omit="*config*,test/*.py,*UserSettings*,templates/*,*__init__.py" -m pytest test
        - coverage report -m --ignore-errors
        - coverage html --ignore-errors
    artifacts:
        paths:
            - .coverage
            - htmlcov

This is the output

Getting source from Git repository
00:02
Fetching changes...
Initialized empty Git repository in /builds/atlas-germany-dresden-vbs-group/CAF-Scripts/.git/
Created fresh repository.
Checking out 3f716e4e as detached HEAD (ref is Root628)...
Skipping Git submodules setup
Downloading artifacts
00:01
Downloading artifacts for compile (32909051)...
Downloading artifacts from coordinator... ok        host=gitlab.cern.ch OK
Downloading artifacts for run_USGuideline (32909052)...
Downloading artifacts from coordinator... ok        host=gitlab.cern.ch OK
Executing "step_script" stage of the job script
00:16
$ # INFO: Lowering limit of file descriptors for backwards compatibility. ffi: https://cern.ch/gitlab-runners-limit-file-descriptors # collapsed multi-line command
$ set +e
$ alias python3="python"
$ sudo mv CommonAnalysisFramework ..
$ export CAFPATH="$PWD/.."
$ ln -s templates/UserSettingsGuideline.py UserSettings.py
$ source $CAFPATH/CommonAnalysisFramework/${SETUP_SCRIPT}
lsetup               lsetup <tool1> [ <tool2> ...] (see lsetup -h):
 lsetup asetup        (or asetup) to setup an Athena release
 lsetup astyle        ATLAS style macros
 lsetup atlantis      Atlantis: event display
 lsetup eiclient      Event Index 
 lsetup emi           EMI: grid middleware user interface 
 lsetup ganga         Ganga: job definition and management client
 lsetup lcgenv        lcgenv: setup tools from cvmfs SFT repository
 lsetup panda         Panda: Production ANd Distributed Analysis
 lsetup pyami         pyAMI: ATLAS Metadata Interface python client
 lsetup root          ROOT data processing framework
 lsetup rucio         distributed data management system client
 lsetup scikit        python data analysis ecosystem
 lsetup views         Set up a full LCG release
 lsetup xcache        XRootD local proxy cache
 lsetup xrootd        XRootD data access
advancedTools        advanced tools menu
diagnostics          diagnostic tools menu
helpMe               more help
printMenu            show this menu
showVersions         show versions of installed software
 
06 Mar 2023 
centos7: setupATLAS is python3 environment by default (same as setupATLAS -3).
         If you need the previous python2 environment, do setupATLAS -2.
     We strongly encourage API users to migrate their scripts to python3.
          * * * This environment has been setup as python3. * * *
$ source /cvmfs/sft.cern.ch/lcg/releases/LCG_104/pytest/7.4.0/x86_64-centos7-gcc12-opt/pytest-env.sh
$ source /cvmfs/sft.cern.ch/lcg/releases/LCG_104/pytest_cov/3.0.0/x86_64-centos7-gcc12-opt/pytest_cov-env.sh
$ unalias python3
$ set +e
$ echo " in main script"
 in main script
$ coverage run --branch --source="." --omit="*config*,test/*.py,*UserSettings*,templates/*,*__init__.py" -m pytest test
$ coverage report -m --ignore-errors
No data to report.
$ coverage html --ignore-errors
No data to report.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: command terminated with exit code 1

And one of the files in the test folder is this

#!/bin/env python
"""Test that the nominal cut is part of the cut list.

Also requires it to not be commented out for tables."""

import templates.WZUserSettings as us

def test_cutNames():
    cutnames = us.cutNames
    defaultCut = us.defaultCut.replace("*", "")
    assert defaultCut in cutnames

Cheers

0

There are 0 best solutions below