nucypher/.circleci/config.yml

610 lines
17 KiB
YAML
Raw Normal View History

version: 2.1
orbs:
codecov: codecov/codecov@1.0.4
workflows:
version: 2
test_build_deploy:
jobs:
- pipenv_install_36:
filters:
tags:
only: /.*/
- pip_install_36:
filters:
tags:
only: /.*/
- pipenv_install_37:
filters:
tags:
only: /.*/
- pip_install_37:
filters:
tags:
only: /.*/
- contracts:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- basics:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- network:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
2018-12-06 01:44:25 +00:00
- character:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- agents:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- actors:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- deployers:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- cli:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- pipenv_install_36
- tests_ok:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- basics
- network
- character
- cli
- deployers
# - agents # These jobs are left out to not block execution of workflow
# - actors
# - contracts
- finnegans_wake_demo:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- tests_ok
- heartbeat_demo:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- tests_ok
# - mypy: # Disable mypy for the moment as it was wasting a CircleCI container for nothing
# context: "NuCypher Tests"
# filters:
# tags:
# only: /.*/
# requires:
# - tests_ok
- estimate_gas:
context: "NuCypher Tests"
filters:
tags:
only: /.*/
requires:
- tests_ok
2019-01-30 01:20:15 +00:00
- build_docs:
filters:
tags:
only: /.*/
requires:
- tests_ok
- test_build:
filters:
tags:
only: /.*/
requires:
2019-01-30 01:20:15 +00:00
- build_docs
- heartbeat_demo
- finnegans_wake_demo
- build_docker:
filters:
tags:
only: /v[0-9]+.*/
branches:
ignore: /.*/
requires:
- test_build
- test_deploy:
context: "NuCypher PyPI"
requires:
- test_build
filters:
tags:
only: /v[0-9]+.*/
branches:
ignore: /.*/
- request_publication_approval:
type: approval
requires:
- test_deploy
- build_docker
filters:
tags:
only: /v[0-9]+.*/
branches:
ignore: /.*/
- publish_pypi:
context: "NuCypher PyPI"
requires:
- request_publication_approval
filters:
tags:
only: /v[0-9]+.*/
branches:
ignore: /.*/
- publish_docker:
context: "NuCypher Docker"
requires:
- request_publication_approval
filters:
tags:
only: /v[0-9]+.*/
branches:
ignore: /.*/
2018-12-04 07:08:55 +00:00
python_36_base: &python_36_base
2018-12-14 23:39:59 +00:00
parallelism: 1
working_directory: ~/nucypher
2018-12-14 23:39:59 +00:00
docker:
- image: circleci/python:3.6
python_37_base: &python_37_base
2018-12-14 23:39:59 +00:00
parallelism: 1
working_directory: ~/nucypher
2018-12-14 23:39:59 +00:00
docker:
- image: circleci/python:3.7
2018-12-04 07:08:55 +00:00
commands:
pipenv_install:
description: "Install Python dependencies with Pipenv"
steps:
- checkout
- run:
name: Install Python Dependencies with Pipenv
2019-02-10 16:39:48 +00:00
command: |
pipenv sync --dev
pipenv uninstall --skip-lock ethpm
- run:
name: Install Solidity Compiler (Pipenv Entrypoint)
command: pipenv run install-solc
- run:
name: Check NuCypher Python API Entrypoint
command: pipenv run python3 -c "import nucypher; print(nucypher.__version__)"
- run:
name: Check NuCypher CLI Entrypoint
command: pipenv run nucypher --help
check_nucypher_entrypoints:
description: "Ensure both the python API and CLI entrypoints are usable"
steps:
- run:
name: Check NuCypher Python API Entrypoint
command: python3 -c "import nucypher; print(nucypher.__version__)"
- run:
name: Check NuCypher CLI Entrypoint
command: |
export PATH=~/.local/bin:$PATH
source ~/.bashrc
nucypher --help
pip_install:
description: "Install NuCypher with Pip"
steps:
- checkout
- run:
name: Install Python Dependencies with Pip
command: pip3 install --user .
- check_nucypher_entrypoints # Ensure Standard Installation Entry-points Work
- run:
name: Install Python Development Dependencies with Pip
command: pip3 install -r dev-requirements.txt --user .
- run:
name: Install Solidity Compiler
command: ./scripts/installation/install_solc.sh
- check_nucypher_entrypoints
pip_install_no_dev:
description: "Install NuCypher with Pip (no development dependencies)"
steps:
- checkout
- run:
name: Install Python Dependencies with Pip
command: pip3 install --user .
- check_nucypher_entrypoints # Ensure Standard Installation Entry-points Work
- run:
name: Install Solidity Compiler
command: ./scripts/installation/install_solc.sh
- check_nucypher_entrypoints
2018-12-17 20:32:28 +00:00
prepare_environment:
description: "Checkout application code and Attach the Workspace"
steps:
- checkout
- attach_workspace:
at: ~/.local/share/virtualenvs/
- run:
name: "Create directory for test reports"
command: mkdir reports
codecov:
description: "Upload Coverage Report To codecov.io"
steps:
- codecov/upload:
file: reports/coverage.xml
capture_test_results:
description: "Store and Upload test results; Follow-up step for tests"
steps:
- codecov
- store_test_results:
path: reports
jobs:
# Python 3.6
pip_install_36:
<<: *python_36_base
steps:
- pip_install
pipenv_install_36:
<<: *python_36_base
steps:
- pipenv_install
- persist_to_workspace:
root: ~/.local/share/virtualenvs/
paths:
- nucypher-*
# Python 3.7
pip_install_37:
<<: *python_37_base
steps:
- pip_install
pipenv_install_37:
<<: *python_37_base
steps:
- pipenv_install
agents:
<<: *python_36_base
parallelism: 4
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Blockchain Agent Tests
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/blockchain/eth/entities/agents/**/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
actors:
<<: *python_36_base
parallelism: 2
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Blockchain Actor Tests
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/blockchain/eth/entities/actors/**/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
deployers:
<<: *python_36_base
parallelism: 4
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Contract Deployer Tests
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/blockchain/eth/entities/deployers/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
contracts:
<<: *python_36_base
parallelism: 5
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Ethereum Contract Unit Tests
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/blockchain/eth/contracts/**/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
basics:
<<: *python_36_base
parallelism: 1
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Tests for Blockhain interfaces, Crypto functions, Node Configuration and Keystore
2018-11-28 05:24:17 +00:00
command: |
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/config/**/test_*.py" "tests/crypto/**/test_*.py" "tests/keystore/**/test_*.py" "tests/blockchain/eth/interfaces/**/test_*.py" "tests/blockchain/eth/clients/test_mocked_clients.py" | circleci tests split --split-by=timings)
- capture_test_results
network:
<<: *python_36_base
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Network Tests
2018-11-28 05:24:17 +00:00
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/network/**/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
character:
<<: *python_36_base
2018-12-01 21:08:08 +00:00
parallelism: 4
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Character Tests
2018-11-28 05:24:17 +00:00
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/characters/**/test_*.py" "tests/learning/**/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
cli:
<<: *python_36_base
parallelism: 6
steps:
- prepare_environment
- run:
name: Nucypher CLI Tests
command: |
2019-05-13 08:30:33 +00:00
pipenv run pytest --durations=0 --cov=nucypher --cov-report xml:reports/coverage.xml $(circleci tests glob "tests/cli/**/test_*.py" | circleci tests split --split-by=timings)
- capture_test_results
tests_ok:
<<: *python_36_base
steps:
- run:
name: Nucypher CLI Tests
command: echo "Test modules succeeded"
heartbeat_demo:
<<: *python_36_base
steps:
- checkout
- pip_install_no_dev
- run:
name: Run demo Ursula fleet, Alicia and the Doctor
command: ./scripts/demos/run_heartbeat_demo.sh
- store_artifacts:
path: /tmp/ursulas-logs
finnegans_wake_demo:
<<: *python_36_base
steps:
- checkout
- pip_install_no_dev
- run:
name: Run demo Ursula fleet, Finnegans wake Demo code
command: |
./scripts/demos/run_finnegans_wake_demo.sh || true
sleep 5
./scripts/demos/run_finnegans_wake_demo.sh
- store_artifacts:
path: /tmp/ursulas-logs
mypy:
<<: *python_36_base
steps:
2018-12-17 20:32:28 +00:00
- prepare_environment
- run:
name: Install mypy
command: |
pipenv run pip install lxml
pipenv run pip install mypy
- run:
name: Run Mypy Static Type Checks (Always Succeed)
command: |
mkdir ./mypy_reports ./mypy_results
export MYPYPATH=./nucypher
2018-12-01 21:08:08 +00:00
pipenv run mypy ./nucypher --config-file=mypy.ini --xslt-html-report ./mypy_reports/html/ --linecount-report ./mypy_reports/linecount || true
- store_artifacts:
path: ./mypy_reports
estimate_gas:
<<: *python_36_base
steps:
- checkout
- attach_workspace:
at: ~/.local/share/virtualenvs/
- run:
name: Estimate Gas
command: |
pipenv run python tests/metrics/estimate_gas.py
- store_artifacts:
path: tests/metrics/results/
2019-01-30 01:20:15 +00:00
build_docs:
<<: *python_36_base
steps:
- checkout
- attach_workspace:
at: ~/.local/share/virtualenvs/
2019-01-30 01:20:15 +00:00
- run:
name: Install Documentation Build Dependencies
command: pip3 install --user sphinx recommonmark sphinx-rtd-theme aafigure
2019-01-30 01:20:15 +00:00
- run:
name: Build Sphinx Documentation
command: |
cd docs
make html
- store_artifacts:
path: docs/build
2019-01-30 01:20:15 +00:00
test_build:
<<: *python_36_base
steps:
- checkout
- pip_install
- run:
name: Install Twine
command: pip install --user twine
- run:
name: Build Python Distribution Wheel
command: |
pipenv run python setup.py sdist
pipenv run python setup.py bdist_wheel
build_docker:
working_directory: ~/nucypher
docker:
- image: docker:18.06.1-ce-git
steps:
- checkout
- setup_remote_docker
- restore_cache:
keys:
- v1-{{ .Branch }}
paths:
- ~/docker/nucypher.tar
- run:
name: Load Docker Image Layer Cache
command: |
set +o pipefail
docker load -i ~/docker/nucypher.tar | true
- run:
name: Build Docker Image
command: |
docker build -f deploy/docker/Dockerfile --cache-from=nucypher -t nucypher/nucypher:$CIRCLE_TAG .
- run:
name: Save Docker Image Layer Cache
command: |
mkdir -p ~/docker
docker save -o ~/docker/nucypher.tar nucypher/nucypher:$CIRCLE_TAG
- save_cache:
key: v1-{{ .Branch }}-{{ epoch }}
paths:
- ~/docker/nucypher.tar
test_deploy:
<<: *python_36_base
steps:
- checkout
- pip_install
- run:
name: Install Twine
command: pip3 install --user twine
- run:
name: Verify git tag == __version__ (Test Deploy)
command: python setup.py verify
- run:
name: Initialize .pypirc (Test Deploy)
command: |
echo -e "[distutils]" >> ~/.pypirc
echo -e "index-servers = " >> ~/.pypirc
echo -e " pypi" >> ~/.pypirc
echo -e " testpypi" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[testpypi]" >> ~/.pypirc
echo -e "repository: https://test.pypi.org/legacy/" >> ~/.pypirc
echo -e "username: $TEST_PYPI_USERNAME" >> ~/.pypirc
echo -e "password: $TEST_PYPI_PASSWORD" >> ~/.pypirc
- run:
name: Build Python Wheel (Test Deploy)
command: |
python3 setup.py sdist
python3 setup.py bdist_wheel
- run:
name: upload to TestPyPI
command: python3 -m twine upload --repository testpypi dist/* --verbose
- run:
name: pip install from TestPyPI
command: |
pip3 install --user --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple nucypher --verbose
python3 -c "import nucypher; print(nucypher.__version__)"
publish_pypi:
<<: *python_36_base
steps:
- checkout
- pip_install
- run:
name: Install Twine
command: pip3 install --user twine
- run:
name: Verify git tag == __version__
command: python3 setup.py verify
- run:
name: Initialize .pypirc
command: |
echo -e "[distutils]" >> ~/.pypirc
echo -e "index-servers = " >> ~/.pypirc
echo -e " pypi" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = $PYPI_USERNAME" >> ~/.pypirc
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- run:
name: Build Python Wheel
command: |
python3 setup.py sdist
python3 setup.py bdist_wheel
- deploy:
name: Upload to PyPI
command: python3 -m twine upload dist/* --verbose
publish_docker:
working_directory: ~/nucypher
docker:
- image: docker:18.06.1-ce-git
steps:
- checkout
- setup_remote_docker
- restore_cache:
keys:
- v1-{{ .Branch }}
paths:
- ~/docker/nucypher.tar
- run:
name: Load Docker Image Layer Cache
command: |
set +o pipefail
docker load -i ~/docker/nucypher.tar | true
- deploy:
name: Push NuCypher Docker Image
command: |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
docker push nucypher/nucypher:$CIRCLE_TAG