Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Python Package
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON Templates
Python Package
Commits
52b61297
Commit
52b61297
authored
2 years ago
by
Klaas Kliffen
Browse files
Options
Downloads
Patches
Plain Diff
Initial tox in CI/CD
parent
5b480fd9
No related branches found
No related tags found
1 merge request
!5
Resolve CWG-11 "Features/ add tox"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+12
-20
12 additions, 20 deletions
.gitlab-ci.yml
tox.ini
+1
-41
1 addition, 41 deletions
tox.ini
with
13 additions
and
61 deletions
.gitlab-ci.yml
+
12
−
20
View file @
52b61297
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
...
...
This diff is collapsed.
Click to expand it.
tox.ini
+
1
−
41
View file @
52b61297
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment