Commit 6728d3eb authored by Mark Hewitt's avatar Mark Hewitt
Browse files

Merge branch 'feature/gitlab_ci_cd' into 'main'

Feature/gitlab ci cd

See merge request !2
parents 865ec916 0b55fb6a
Pipeline #69948 passed with stages
in 1 minute and 42 seconds
......@@ -112,4 +112,5 @@ ENV/
meshDeploy
#pycharm
.idea/
\ No newline at end of file
.idea/
nose2-junit.xml
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
# image: python:latest
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
LD_LIBRARY_PATH: "$CI_PROJECT_DIR/build"
DEFAULT_PYTHON: "3.9"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
stages:
- build
- test
- staging
- production
before_script:
# - python -V # Print out python version for debugging
build:info:
stage: build
image: docker.io/python:$DEFAULT_PYTHON
script:
# Print out python version for debugging
- python -V
# Print out version from source code
- ver=`cat src/osducli/__init__.py | grep __VERSION__ | grep -Eo [0-9]+\(.[0-9]+\)*`
- echo $ver
build:build:
stage: build
image: docker.io/python:$DEFAULT_PYTHON
script:
# Install additional deploy build dependencies
- pip install setuptools wheel twine
- python setup.py sdist bdist_wheel
artifacts:
paths:
- dist
tox:
stage: test
image: docker.io/python:$PYTHON_VERSIONS
parallel:
matrix:
- PYTHON_VERSIONS: [ "3.8-slim", "3.9-slim" ]
script:
# Print out python version for debugging
- python -V
# Upgrade pip
- python -m pip install --upgrade pip
# Install the package
- pip install --force-reinstall -f dist osducli
# Development dependencies
- pip install --force-reinstall -r requirements-dev.txt
- tox -e py
artifacts:
reports:
junit: nose2-junit.xml
cobertura: coverage.xml
deploy-to-staging:
stage: staging
dependencies:
- build:build
variables:
TWINE_USERNAME : __token__
TWINE_PASSWORD : $TEST_PYPI_API_KEY
TWINE_REPOSITORY : testpypi
before_script:
# Get the source version and check it matches the tag version
- ver=`cat src/osducli/__init__.py | grep __VERSION__ | grep -Eo [0-9]+\(.[0-9]+\)*`
- echo $ver
- echo $CI_COMMIT_TAG
- if [[ "v$ver" != "$CI_COMMIT_TAG" ]]; then echo "Source code and tag versions don't match" exit 1; fi
script:
- python -m twine upload dist/*
only:
- /^v[0-9]+(?:.[0-9]+)*$/ # run on tagged releases
deploy-to-production:
stage: production
dependencies:
- build:build
variables:
TWINE_USERNAME : __token__
TWINE_PASSWORD : $PYPI_API_KEY
TWINE_REPOSITORY : pypi
script:
- python -m twine upload dist/*
when: manual
only:
- /^v[0-9]+(?:.[0-9]+)*$/ # run on tagged releases
......@@ -19,4 +19,4 @@ commands =
pylint src/osducli --rcfile=pylintrc -r n
pylint ./scripts/license_verify.py --rcfile=pylintrc -r n
flake8 --statistics --append-config=.flake8 src
nose2 -v --with-coverage --coverage src
nose2 -v --with-coverage --coverage src --coverage-report xml --plugin nose2.plugins.junitxml --junit-xml
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment