matrix-alertbot/.gitlab-ci.yml
2022-08-13 14:04:55 +02:00

108 lines
2.1 KiB
YAML

workflow:
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
VIRTUAL_ENV: "$CI_PROJECT_DIR/.venv"
FF_USE_FASTZIP: "true"
stages:
- install
- quality
- test
.pip cache template:
cache:
key:
files:
- setup.py
- requirements.txt
paths:
- .cache/pip
- ${VIRTUAL_ENV}
before_script:
- export PATH="${VIRTUAL_ENV}/bin:$PATH"
install:
extends: .pip cache template
image: python:3.10-alpine
stage: install
script:
- apk add --no-cache gcc g++ yaml-dev python3-dev
- python3 -m venv "${VIRTUAL_ENV}"
- pip install -r requirements.txt
- pip install .
cache:
policy: pull-push
interruptible: true
needs: []
isort linting:
extends: .pip cache template
image: python:3.10-alpine
stage: quality
script:
- isort -c --df .
cache:
policy: pull
interruptible: true
needs:
- job: install
artifacts: false
flake8 linting:
extends: .pip cache template
image: python:3.10-alpine
stage: quality
script:
- flake8 --count --show-source --statistics .
cache:
policy: pull
interruptible: true
needs:
- job: install
artifacts: false
black linting:
extends: .pip cache template
image: python:3.10-alpine
stage: quality
script:
- black --check --diff .
cache:
policy: pull
interruptible: true
needs:
- job: install
artifacts: false
tests:
extends: .pip cache template
image: python:3.10-alpine
stage: test
script:
- apk add --no-cache libstdc++
- coverage run --source matrix_alertbot -m pytest --junitxml=report.xml
- coverage report --precision 2
- coverage xml -o coverage.xml
cache:
policy: pull
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
coverage: '/^TOTAL\s+\d+\s+\d+\s+(\d+\.\d+\%)$/'
interruptible: true
needs:
- job: isort linting
artifacts: false
- job: flake8 linting
artifacts: false
- job: black linting
artifacts: false