diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24ada48e63446d2992d6b3bb9288f1cf26c9de31..db210e7b0317a30e9553c9c71db59a5ce9a359f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,16 +62,8 @@ variables: cache: {} image: ${DEVOPS_REGISTRY}usgs/conda:latest script: - # Add conda to path - - source /etc/profile.d/conda.sh - # Install Project Dependencies - - conda config --add channels conda-forge - - conda install python=${PYTHON_VERSION} obspy pycurl - - pip install pipenv - - pipenv --site-packages install --dev --pre --skip-lock - # Run Code Checks - - pipenv run black --check . - - pipenv run pytest --cov-report xml:cov.xml --cov=geomagio + - export PYTHON_VERSION=${PYTHON_VERSION:-3.8} + - scripts/ci_check_code.sh artifacts: paths: - cov.xml @@ -80,8 +72,6 @@ variables: stage: test tags: - development - variables: - PYTHON_VERSION: 3.8 .deploy: cache: {} @@ -134,20 +124,23 @@ variables: Check Python 3.6: extends: - .check_code - variables: - PYTHON_VERSION: '3.6' + script: + - export PYTHON_VERSION=3.6 + - scripts/ci_check_code.sh Check Python 3.7: extends: - .check_code - variables: - PYTHON_VERSION: '3.7' + script: + - export PYTHON_VERSION=3.7 + - scripts/ci_check_code.sh Check Python 3.8: extends: - .check_code - variables: - PYTHON_VERSION: '3.8' + script: + - export PYTHON_VERSION=3.8 + - scripts/ci_check_code.sh ## -------------------------------------------------- diff --git a/scripts/ci_check_code.sh b/scripts/ci_check_code.sh new file mode 100644 index 0000000000000000000000000000000000000000..14cd8be161fce8af43eb35051ea1f65b622bed56 --- /dev/null +++ b/scripts/ci_check_code.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +$PYTHON_VERSION=${PYTHON_VERSION:3.8} + + +if [ -f "/etc/profile.d/conda.sh" ]; then + # Add conda to path + source /etc/profile.d/conda.sh +fi + +# Install Project Dependencies +conda config --add channels conda-forge +conda install python=${PYTHON_VERSION} obspy pycurl +pip install pipenv +pipenv --site-packages install --dev --pre --skip-lock + +# Run Code Checks +pipenv run black --check . +pipenv run pytest --cov-report xml:cov.xml --cov=geomagio