matrix-alertbot/.gitlab-ci.yml

117 lines
2.3 KiB
YAML
Raw Normal View History

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
- publish
2022-08-08 17:29:03 +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:
2022-08-14 15:33:49 +02:00
- setup.cfg
- pyproject.toml
2022-08-08 17:29:03 +02:00
paths:
- .cache/pip
2022-08-08 17:38:53 +02:00
- ${VIRTUAL_ENV}
interruptible: true
allow_failure: false
2022-08-08 17:29:03 +02:00
2022-08-08 17:54:04 +02:00
install:
extends: .pip template
2022-08-08 17:29:03 +02:00
stage: install
script:
2022-08-14 15:52:40 +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:52:40 +02:00
- pip install .[test]
- pip install -U build twine
2022-08-08 17:29:03 +02:00
cache:
policy: pull-push
needs: []
2022-08-08 17:29:03 +02:00
2022-08-13 14:08:18 +02:00
linting:
extends: .pip template
2022-08-08 17:29:03 +02:00
stage: quality
script:
- isort -c --df .
2022-08-13 14:04:55 +02:00
- flake8 --count --show-source --statistics .
- black --check --diff .
cache:
policy: pull
needs:
- job: install
artifacts: false
2022-08-08 17:29:03 +02:00
tests:
extends: .pip template
2022-08-08 17:29:03 +02:00
stage: test
script:
2022-08-14 15:52:40 +02:00
- apk add --no-cache libstdc++
2024-04-17 16:30:09 +02:00
- pytest --junitxml report.xml
2022-08-08 17:29:03 +02:00
cache:
policy: pull
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
2024-04-17 16:30:09 +02:00
junit: report.xml
coverage: '/^TOTAL\s+\d+\s+\d+\s+([\d\.]+\%)$/'
needs:
2022-08-13 14:08:18 +02:00
- job: linting
artifacts: false
publish test:
extends: .pip template
stage: publish
script:
2022-08-14 15:32:43 +02:00
- apk add --no-cache git
- python -m build
2022-08-15 17:31:16 +02:00
- twine upload --skip-existing --repository-url "${TWINE_TEST_REPOSITORY_URL}" -u "${TWINE_TEST_USERNAME}" -p "${TWINE_TEST_PASSWORD}" ./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
- 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