pytest: move coverage flags from .gitlab-ci.yml to pytest.sh, add test_requirements.txt for pip

This commit is contained in:
InsanePrawn 2022-09-11 01:32:59 +02:00
parent 5c8f0acfcd
commit 3ea7e98a48
3 changed files with 6 additions and 3 deletions

View file

@ -27,12 +27,12 @@ pytest:
image: archlinux image: archlinux
before_script: before_script:
- pacman -Sy --noconfirm --needed archlinux-keyring && pacman -Su --noconfirm python python-pip sudo git base-devel - pacman -Sy --noconfirm --needed archlinux-keyring && pacman -Su --noconfirm python python-pip sudo git base-devel
- pip install pytest pytest-cov -r requirements.txt - pip install -r test_requirements.txt -r requirements.txt
- 'echo "kupfer ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/kupfer_all' - 'echo "kupfer ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/kupfer_all'
- useradd -m kupfer - useradd -m kupfer
- chmod 777 . - chmod 777 .
script: script:
- script -e -c 'su kupfer -s /bin/bash -c "./pytest.sh --cov=. --cov-branch --cov-report=term --cov-report=xml:coverage.xml"' - script -e -c 'su kupfer -s /bin/bash -c "./pytest.sh --junit-xml=pytest-report.xml --cov-report=xml:coverage.xml"'
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts: artifacts:
reports: reports:
@ -40,6 +40,7 @@ pytest:
coverage_report: coverage_report:
coverage_format: cobertura coverage_format: cobertura
path: coverage.xml path: coverage.xml
build_docker: build_docker:
stage: build stage: build
image: docker:latest image: docker:latest

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
sudo -v sudo -v
python -m pytest --junit-xml=pytest-report.xml -v "$@" ./*/test_*.py python -m pytest -v --cov=. --cov-branch --cov-report=term "$@" ./*/test_*.py

2
test_requirements.txt Normal file
View file

@ -0,0 +1,2 @@
pytest
pytest-cov