Dockerized molecule (#132)

* Dockerized molecule

* Moved testing.md to subfolder.

* Updated readme

* Readme.
This commit is contained in:
Przemyslaw Rzad 2019-07-08 09:15:17 +02:00 committed by GitHub
parent 47a0a7c0f5
commit 86fe89d3ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 25 deletions

@ -126,14 +126,7 @@ jobs:
docker_layer_caching: true
steps:
- checkout
- run: git submodule update --init
- run: sudo add-apt-repository ppa:jonathonf/python-3.6 -y
- run: sudo apt-get update
- run: sudo apt-get install python3.6 -y
- run: sudo apt-get install python3-pip python3.6-dev -y
- run: cd deployment && virtualenv -p python3.6 venv
- run: cd deployment && source venv/bin/activate && pip install -r requirements.txt
- run: cd deployment && source venv/bin/activate && molecule test
- run: deployment/molecule/molecule.sh default
workflows:
version: 2
tokenbridge:

@ -16,7 +16,7 @@ Please refer to [Execution](./EXECUTION.md).
## Testing
Please refer to [Testing](./TESTING.md).
Please refer to [Testing](./molecule/TESTING.md).
## Contributing

@ -0,0 +1,4 @@
FROM python:3.7-stretch
RUN curl -fsSL https://get.docker.com | sh
RUN pip3 install docker molecule==2.22rc1 molecule[docker] flake8
COPY . .

@ -2,15 +2,6 @@
The deployment playbooks are tested using [Molecule](https://molecule.readthedocs.io).
## Prepare virtual python environment
```
command -v virtualenv || pip3 install virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
```
## Push remote branch
The deployment playbooks are cloning the monorepository on target hosts, using your current local git branch name. If the branch does not exists on remote, you need to push it.
@ -22,7 +13,7 @@ git push
Alternatively, if there are no changes except the playbooks, you can use the `master` branch:
```
CIRCLE_BRANCH=master molecule test
CIRCLE_BRANCH=master ./molecule.sh <scenario_name>
```
In this case `master` branch will be used as a codebase for Monitor, UI, Oracle and Contracts deployed by your local playbook.
@ -30,11 +21,11 @@ In this case `master` branch will be used as a codebase for Monitor, UI, Oracle
## Run the tests
```
molecule test
CIRCLE_BRANCH=master ./molecule.sh <scenario_name>
```
## Exit the virtual environment
Available scenarios:
```
deactivate
```
Scenario | Description
--- | ---
default | Deploys oracle on Ubuntu host and checks some assertions

@ -30,7 +30,7 @@ provisioner:
oracle-host:
VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
syslog_server_port: "udp://127.0.0.1:514"
bridge_repo_branch: ${CIRCLE_BRANCH-$(git symbolic-ref --short HEAD)}
bridge_repo_branch: $CODEBASE_BRANCH
verifier:
name: testinfra
lint:

@ -0,0 +1,11 @@
version: '3.0'
services:
molecule_runner:
build:
context: ..
dockerfile: molecule/Dockerfile
restart: 'no'
privileged: true
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock

11
deployment/molecule/molecule.sh Executable file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
cd $(dirname $0)
set -e # exit when any command fails
CODEBASE_BRANCH=${CIRCLE_BRANCH-$(git symbolic-ref --short HEAD)}
while [ "$1" != "" ]; do
docker-compose build && docker-compose run -e CODEBASE_BRANCH=$CODEBASE_BRANCH molecule_runner /bin/bash -c "molecule test --scenario-name $1"
shift # Shift all the parameters down by one
done