2022-08-08 17:29:03 +02:00
|
|
|
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"
|
2022-08-08 17:38:53 +02:00
|
|
|
VIRTUAL_ENV: "$CI_PROJECT_DIR/.venv"
|
2022-08-08 17:29:03 +02:00
|
|
|
FF_USE_FASTZIP: "true"
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- install
|
|
|
|
- quality
|
|
|
|
- test
|
2022-08-14 15:20:49 +02:00
|
|
|
- publish
|
2022-08-08 17:29:03 +02:00
|
|
|
|
2022-08-14 15:20:49 +02:00
|
|
|
.pip template:
|
|
|
|
image: python:3.10-alpine
|
|
|
|
before_script:
|
|
|
|
- export PATH="${VIRTUAL_ENV}/bin:$PATH"
|
2022-08-08 17:29:03 +02:00
|
|
|
cache:
|
|
|
|
key:
|
|
|
|
files:
|
|
|
|
- setup.py
|
|
|
|
paths:
|
|
|
|
- .cache/pip
|
2022-08-08 17:38:53 +02:00
|
|
|
- ${VIRTUAL_ENV}
|
2022-08-14 15:20:49 +02:00
|
|
|
interruptible: true
|
|
|
|
allow_failure: false
|
2022-08-08 17:29:03 +02:00
|
|
|
|
2022-08-08 17:54:04 +02:00
|
|
|
install:
|
2022-08-14 15:20:49 +02:00
|
|
|
extends: .pip template
|
2022-08-08 17:29:03 +02:00
|
|
|
stage: install
|
|
|
|
script:
|
2022-08-14 15:24:01 +02:00
|
|
|
- apk add --no-cache gcc g++ yaml-dev python3-dev git
|
2022-08-08 17:38:53 +02:00
|
|
|
- python3 -m venv "${VIRTUAL_ENV}"
|
2022-08-14 15:32:43 +02:00
|
|
|
- pip install .[all]
|
2022-08-14 15:20:49 +02:00
|
|
|
- pip install -U build twine
|
2022-08-08 17:29:03 +02:00
|
|
|
cache:
|
|
|
|
policy: pull-push
|
2022-08-13 14:00:40 +02:00
|
|
|
needs: []
|
2022-08-08 17:29:03 +02:00
|
|
|
|
2022-08-13 14:08:18 +02:00
|
|
|
linting:
|
2022-08-14 15:20:49 +02:00
|
|
|
extends: .pip template
|
2022-08-08 17:29:03 +02:00
|
|
|
stage: quality
|
|
|
|
script:
|
2022-08-13 14:00:40 +02:00
|
|
|
- isort -c --df .
|
2022-08-13 14:04:55 +02:00
|
|
|
- flake8 --count --show-source --statistics .
|
2022-08-13 14:00:40 +02:00
|
|
|
- black --check --diff .
|
|
|
|
cache:
|
|
|
|
policy: pull
|
|
|
|
needs:
|
|
|
|
- job: install
|
|
|
|
artifacts: false
|
2022-08-08 17:29:03 +02:00
|
|
|
|
|
|
|
tests:
|
2022-08-14 15:20:49 +02:00
|
|
|
extends: .pip template
|
2022-08-08 17:29:03 +02:00
|
|
|
stage: test
|
|
|
|
script:
|
2022-08-08 18:11:10 +02:00
|
|
|
- apk add --no-cache libstdc++
|
2022-08-08 22:57:49 +02:00
|
|
|
- coverage run --source matrix_alertbot -m pytest --junitxml=report.xml
|
2022-08-08 22:54:12 +02:00
|
|
|
- coverage report --precision 2
|
2022-08-08 17:29:03 +02:00
|
|
|
- coverage xml -o coverage.xml
|
|
|
|
cache:
|
|
|
|
policy: pull
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
coverage_report:
|
|
|
|
coverage_format: cobertura
|
|
|
|
path: coverage.xml
|
|
|
|
junit: report.xml
|
2022-08-08 23:03:11 +02:00
|
|
|
coverage: '/^TOTAL\s+\d+\s+\d+\s+(\d+\.\d+\%)$/'
|
2022-08-13 14:00:40 +02:00
|
|
|
needs:
|
2022-08-13 14:08:18 +02:00
|
|
|
- job: linting
|
2022-08-13 14:00:40 +02:00
|
|
|
artifacts: false
|
2022-08-14 15:20:49 +02:00
|
|
|
|
|
|
|
publish test:
|
|
|
|
extends: .pip template
|
|
|
|
stage: publish
|
|
|
|
script:
|
2022-08-14 15:32:43 +02:00
|
|
|
- apk add --no-cache git
|
2022-08-14 15:20:49 +02:00
|
|
|
- python -m build
|
|
|
|
- twine upload --repository testpypi ./dist/*
|
|
|
|
cache:
|
|
|
|
policy: pull
|
|
|
|
artifacts:
|
|
|
|
name: $CI_JOB_NAME
|
|
|
|
paths:
|
|
|
|
- dist
|
|
|
|
expire_in: 1 week
|
|
|
|
rules:
|
2022-08-14 15:21:47 +02:00
|
|
|
- if: $CI_DEFAULT_BRANCH == $CI_COMMIT_BRANCH
|
2022-08-14 15:20:49 +02:00
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
environment:
|
|
|
|
name: test
|
|
|
|
url: https://test.pypi.org/project/matrix-alertbot
|
|
|
|
needs:
|
|
|
|
- job: tests
|
|
|
|
artifacts: false
|
|
|
|
|
|
|
|
publish prod:
|
|
|
|
extends: .pip template
|
|
|
|
stage: publish
|
|
|
|
script:
|
|
|
|
- twine upload ./dist/*
|
|
|
|
cache:
|
|
|
|
policy: pull
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
when: manual
|
|
|
|
environment:
|
|
|
|
name: prod
|
|
|
|
url: https://pypi.org/project/matrix-alertbot
|
|
|
|
needs:
|
|
|
|
- job: publish test
|
|
|
|
artifacts: true
|