Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Update GitLab-CI config
· 623005fd
Dom Sekotill
authored
Jun 18, 2024
623005fd
Switch CI unit tests to py.test
· ebc99895
Dom Sekotill
authored
Jun 18, 2024
ebc99895
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
ebc99895
...
...
@@ -3,18 +3,17 @@
# SAFETY_API_KEY:
# Set to your API key for accessing up-to-date package security information
stages
:
-
build
-
test
-
publish
workflow
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_OPEN_MERGE_REQUESTS
-
if
:
$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when
:
never
-
when
:
always
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
-
if
:
$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$$/
variables
:
PUSH_PACKAGE
:
"
true"
-
if
:
$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/
-
if
:
$CI_COMMIT_BRANCH
.python
:
...
...
@@ -44,7 +43,6 @@ Pin:
# Pin dependencies in requirements.txt for reproducing pipeline results
stage
:
test
extends
:
[
.python
]
needs
:
[]
script
:
-
pip install --prefer-binary -e .
-
pip freeze --exclude-editable | tee requirements.txt
...
...
@@ -62,7 +60,7 @@ Dependency Check:
Code Checks
:
stage
:
test
stage
:
.pre
image
:
docker.kodo.org.uk/ci-images/pre-commit:2.15.0-1
needs
:
[]
variables
:
...
...
@@ -84,10 +82,12 @@ Unit Tests:
extends
:
[
.python
]
needs
:
[
Pin
]
script
:
-
pip install -r requirements.txt -e . coverage[toml] nose
-
coverage run -m nose tests
-
pip install -r requirements.txt -e .
coverage[toml]
pytest
-
coverage run -m pytest tests
--verbose
--
with-xunit --xunit-file
=results/xunit.xml
--
junit-xml
=results/xunit.xml
after_script
:
-
coverage report
-
coverage json
...
...
@@ -108,7 +108,7 @@ Check Tag:
extends
:
[
.python
]
needs
:
[
"
Build
Package"
]
rules
:
-
if
:
$CI_COMMIT_TAG
=~ /^v[0-9]/
-
if
:
$CI_COMMIT_TAG
script
:
-
pip install packaging pkginfo
-
|
...
...
@@ -119,16 +119,17 @@ Check Tag:
wheel_path = glob("dist/*.whl")[0]
wheel = Wheel(wheel_path)
assert Version("$CI_COMMIT_TAG") == Version(wheel.version)
assert Version("$CI_COMMIT_TAG").release == Version(wheel.version).release, \
f"Pkg version {wheel.version} does not match tag"
END
Upload Package
:
stage
:
publish
Upload Package
(Test)
:
stage
:
deploy
extends
:
[
.python
]
need
s
:
[
"
Build
Package"
]
dependencie
s
:
[
"
Build
Package"
]
rules
:
-
if
:
$CI_COMMIT_TAG
=~ /^v[0-9]/
-
if
:
$CI_COMMIT_TAG
script
:
-
pip install twine
-
TWINE_USERNAME=gitlab-ci-token
...
...
@@ -138,3 +139,20 @@ Upload Package:
--non-interactive
--repository-url $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/pypi
dist/*
Upload Package (PyPI)
:
stage
:
deploy
extends
:
[
.python
]
dependencies
:
[
"
Build
Package"
]
rules
:
-
if
:
$PYPI_TOKEN && $PUSH_PACKAGE
when
:
manual
script
:
-
pip install twine
-
TWINE_USERNAME=__token__
TWINE_PASSWORD=$PYPI_TOKEN
twine upload
--verbose
--non-interactive
dist/*