From 9759c900b3e69393749aede00063408834a71245 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Fri, 4 Sep 2020 18:37:14 -0600 Subject: [PATCH] Update check_code to run script, to allow local gitlab-runner exec --- .gitlab-ci.yml | 29 +++++++++++------------------ scripts/ci_check_code.sh | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 scripts/ci_check_code.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24ada48e6..db210e7b0 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 000000000..14cd8be16 --- /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 -- GitLab