Skip to content
Snippets Groups Projects
Commit 52b61297 authored by Klaas Kliffen's avatar Klaas Kliffen :satellite:
Browse files

Initial tox in CI/CD

parent 5b480fd9
No related branches found
No related tags found
1 merge request!5Resolve CWG-11 "Features/ add tox"
default:
image: python:3.7 # minimum supported version
# Make sure each step is executed in a virtual environment with some basic dependencies present
before_script:
- python --version # For debugging
- python -m venv venv
- source venv/bin/activate
- python -m pip install --upgrade pip
# install common packages required for linting, building, docs etc.
- pip install --upgrade black build flake8 pylint setuptools sphinx twine wheel
- pip install --upgrade tox twine
cache:
paths:
- .cache/pip
- venv/
# Do not cache .tox, to recreate virtualenvs for every step
stages:
- lint
......@@ -29,22 +25,19 @@ variables:
run_black:
stage: lint
script:
- python -m black --version
- python -m black --check --diff .
- tox -e black
allow_failure: true
run_flake8:
stage: lint
script:
- python -m flake8 --version
- python -m flake8 map
- tox -e pep8
allow_failure: true
run_pylint:
stage: lint
script:
- python -m pylint --version
- python -m pylint map
- tox -e pylint
allow_failure: true
# build_extensions:
......@@ -55,8 +48,7 @@ run_pylint:
run_unit_tests:
stage: test
script:
- pip install -r requirements.txt
- echo "run python unit tests /w coverage"
- tox -e py37,py38,py39,py310
package_files:
stage: package
......@@ -65,7 +57,7 @@ package_files:
paths:
- dist/*
script:
- python -m build # or something similar
- tox -e build
package_docs:
stage: package
......@@ -95,11 +87,11 @@ publish_on_gitlab:
- if: $CI_COMMIT_TAG
script:
- echo "run twine for gitlab"
# - |
# TWINE_PASSWORD=${CI_JOB_TOKEN} \
# TWINE_USERNAME=gitlab-ci-token \
# python -m twine upload \
# --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
- |
TWINE_PASSWORD=${CI_JOB_TOKEN} \
TWINE_USERNAME=gitlab-ci-token \
python -m twine upload \
--repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
publish_on_test_pypi:
stage: publish
......
......@@ -16,7 +16,6 @@ deps =
-r{toxinidir}/tests/requirements.txt
commands =
{envpython} --version
stestr run {posargs}
# Use generative name and command prefixes to reuse the same virtualenv
# for all linting jobs.
......@@ -29,47 +28,8 @@ commands =
black: {envpython} -m black --version
black: {envpython} -m black --check --diff .
pylint: {envpython} -m pylint --version
pylint: {envpython} -m pylint lofar_station_client
[testenv:debug]
commands = {envpython} -m testtools.run {posargs}
[testenv:coverage]
; stestr does not natively support generating coverage reports use
; `PYTHON=python -m coverage run....` to overcome this.
setenv =
PYTHON={envpython} -m coverage run --source lofar_station_client --omit='*tests*' --parallel-mode
commands =
{envpython} -m coverage erase
{envpython} -m stestr run {posargs}
{envpython} -m coverage combine
{envpython} -m coverage html -d cover --omit='*tests*'
{envpython} -m coverage xml -o coverage.xml
{envpython} -m coverage report --omit='*tests*'
pylint: {envpython} -m pylint map
[testenv:build]
usedevelop = False
commands = {envpython} -m build
[testenv:docs]
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/docs/requirements.txt
commands = sphinx-build -b html -W docs/source docs/build/html
[testenv:integration]
# Do no install the lofar station client package, force packaged version install
skip_install = true
# Intentionally break import paths if not installed from package
changedir={toxinidir}/integration
# Allow bash for wheel file substitution
allowlist_external =
bash
commands =
# We need the bash substitutions here
bash -ec 'pip install --force-reinstall {toxinidir}/dist/*.whl'
{envpython} -m stestr run --serial {posargs}
[flake8]
filename = *.py
exclude=.tox,.egg-info
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment