.circleci/config.yml
version: 2.1
parameters:
upstream_repo_name:
type: string
default: ""
upstream_build_num:
type: integer
default: 0
workflows:
build:
jobs:
- build:
context: karr_lab
jobs:
build:
working_directory: /root/project
docker:
- image: karrlab/wc_env_dependencies:latest
steps:
# Clone repository
- checkout
# Load packages from cache
- restore_cache:
keys:
- v2-{{ arch }}-{{ .Branch }}-{{ checksum "/etc/docker-image-tag" }}-{{ checksum "requirements.txt" }}
# Python 3 installation tasks
- run:
name: Install pkg_utils (Python 3)
command: python3 -m pip install -U git+https://github.com/KarrLab/pkg_utils.git#egg=pkg_utils
- run:
name: Install karr_lab_build_utils (Python 3)
command: |
python3 -m pip install -U git+https://github.com/KarrLab/sphinxcontrib-googleanalytics.git#egg=sphinxcontrib_googleanalytics
python3 -m pip install -U git+https://github.com/KarrLab/wc_utils.git#egg=wc_utils[all]
python3 -m pip install -U git+https://github.com/KarrLab/karr_lab_build_utils.git#egg=karr_lab_build_utils[all]
- run:
name: Install package configuration files including credentials
command: karr_lab_build_utils3 download-install-package-config-files
- run:
name: Setup Python environment
command: |
if [[ -f .circleci/requirements.txt ]]; then
while IFS="" read -r line || [ -n "$line" ]; do
if [[ ! -z "$line" ]] && [[ ! "$line" =~ ^# ]]; then
python3 -m pip install -U "$line"
fi
done < .circleci/requirements.txt
fi
- run:
name: Install package (Python 3)
command: python3 -m pip install -U -e .[all]
# Save packages to cache
- save_cache:
key: v2-{{ arch }}-{{ .Branch }}-{{ checksum "/etc/docker-image-tag" }}-{{ checksum "requirements.txt" }}
paths:
- /usr/local/lib/python3.7/site-packages
# Test code
- run:
name: Test code
environment:
PYTHONFAULTHANDLER: 1
command: |
set +e
karr_lab_build_utils3 run-tests --with-xunit --with-coverage
TEST_EXIT_CODE_PY3=$?
# Calculate exit code and save to file for reading by the next step
if [[ $TEST_EXIT_CODE_PY3 -eq 0 ]]; then
echo "0" > TEST_EXIT_CODE
exit 0
else
echo "0" > TEST_EXIT_CODE
exit 1
fi
# Generate reports, archive results, and send notifications
- run:
name: Generate reports, archive results, and send notifications
when: always
environment:
UPSTREAM_REPONAME: << pipeline.parameters.upstream_repo_name >>
UPSTREAM_BUILD_NUM: << pipeline.parameters.upstream_build_num >>
command: |
if [[ -f TEST_EXIT_CODE ]]; then
INSTALLATION_EXIT_CODE=0
TEST_EXIT_CODE=$(<TEST_EXIT_CODE)
else
INSTALLATION_EXIT_CODE=1
TEST_EXIT_CODE=1
fi
karr_lab_build_utils3 do-post-test-tasks $INSTALLATION_EXIT_CODE $TEST_EXIT_CODE
- store_test_results:
path: /root/project/tests/reports
- store_artifacts:
path: /root/project/tests/reports
destination: reports
- store_artifacts:
path: /root/.wc/log
destination: log
- store_artifacts:
path: /root/project/docs/_build/html
destination: docs