This repository has been archived by the owner on Jan 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from CasperLabs/release-v0.20
Merge Release v0.20 to master
- Loading branch information
Showing
107 changed files
with
10,266 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.tox/ | ||
.eggs/ | ||
.pytest_cache/ | ||
casperlabs_client/proto/ | ||
dist/ | ||
casperlabs_client.egg-info/ | ||
manual-test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
--- | ||
platform: | ||
os: linux | ||
arch: amd64 | ||
|
||
# Begin | ||
clone: | ||
git-clone: | ||
commands: | | ||
set -ex | ||
git clone -b ${DRONE_TAG:-$DRONE_BRANCH} $DRONE_REMOTE_URL . | ||
if [ x$DRONE_PULL_REQUEST != x ]; then | ||
git fetch origin refs/pull/$DRONE_PULL_REQUEST/head | ||
EMAIL=ci git merge --no-edit FETCH_HEAD | ||
fi | ||
git rev-parse HEAD | ||
image: "casperlabs/buildenv" | ||
|
||
# NOTE: Anchors are per document | ||
# Anchor for default buildenv | ||
__buildenv: &buildenv | ||
image: "casperlabs/buildenv:latest" | ||
|
||
kind: pipeline | ||
name: build | ||
|
||
steps: | ||
- name: update-test-version | ||
<<: *buildenv | ||
commands: | ||
- "VERSION=`cat casperlabs_client/VERSION`" | ||
- "echo $VERSION.$DRONE_BUILD_NUMBER > casperlabs_client/VERSION" | ||
- sed -i 's/NAME = \"casperlabs_client\"/NAME = \"casperlabs_client_test\"/g' setup.py | ||
|
||
- name: build-python-client | ||
<<: *buildenv | ||
commands: | ||
- "make clean" | ||
- "make build" | ||
depends_on: | ||
- update-test-version | ||
|
||
- name: test-python-client | ||
<<: *buildenv | ||
commands: | ||
- "make clean-make" | ||
- "make test-all" | ||
depends_on: | ||
- build-python-client | ||
|
||
- name: test-pypi-publish | ||
image: tvasile1012/pypi:latest | ||
failure: "ignore" | ||
settings: | ||
username: | ||
from_secret: test_pypi_user | ||
password: | ||
from_secret: test_pypi_pass | ||
repository: "https://test.pypi.org/legacy/" | ||
setupfile: "./setup.py" | ||
dist_dir: "./dist/" | ||
skip_build: true | ||
when: | ||
branch: | ||
- dev | ||
event: | ||
- push | ||
depends_on: | ||
- build-python-client | ||
|
||
trigger: | ||
branch: | ||
- dev | ||
- master | ||
- trying | ||
- staging | ||
|
||
--- | ||
# Anchor for default buildenv | ||
__buildenv: &buildenv | ||
image: "casperlabs/buildenv:latest" | ||
|
||
kind: pipeline | ||
name: on-tag | ||
|
||
steps: | ||
- name: build-python-client-tag | ||
<<: *buildenv | ||
commands: | ||
- "make clean" | ||
- "make build" | ||
|
||
- name: pypi-publish-tag | ||
image: tvasile1012/pypi:latest | ||
failure: "ignore" | ||
settings: | ||
username: | ||
from_secret: pypi_user | ||
password: | ||
from_secret: pypi_pass | ||
setupfile: "./setup.py" | ||
dist_dir: "./dist/" | ||
skip_build: true | ||
depends_on: | ||
- build-python-client-tag | ||
|
||
- name: github-publish-tag | ||
settings: | ||
api_key: | ||
from_secret: github_token | ||
checksum: | ||
- sha256 | ||
- md5 | ||
files: | ||
- "./dist/*.gz" | ||
prerelease: | ||
- true | ||
image: plugins/github-release | ||
depends_on: | ||
- build-python-client-tag | ||
|
||
trigger: | ||
ref: | ||
- refs/tags/v* | ||
|
||
--- | ||
kind: pipeline | ||
name: failed-build-alert | ||
|
||
clone: | ||
disable: true | ||
|
||
steps: | ||
- name: notify | ||
image: plugins/slack | ||
settings: | ||
webhook: | ||
from_secret: slack_webhook | ||
template: | ||
- | | ||
client-py build status: *{{ uppercasefirst build.status }}* | ||
Author: {{ build.author }} | ||
Drone Build: <{{ build.link }}|#{{ build.number }}> | ||
Commit Link: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 10 }}> | ||
trigger: | ||
status: | ||
- failure | ||
branch: | ||
- dev | ||
- master | ||
- trying | ||
- staging | ||
|
||
depends_on: | ||
- build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: debug-statements | ||
- id: check-docstring-first | ||
- id: trailing-whitespace | ||
- id: fix-encoding-pragma | ||
- id: flake8 | ||
args: | ||
- --ignore=E203, E501, W503, E402 | ||
- --exclude=(\*_pb2.py|\*_pb2_grpc.py) | ||
- repo: https://github.com/psf/black | ||
rev: stable | ||
hooks: | ||
- id: black | ||
language_version: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Building the Python Client | ||
|
||
Python 3.7+ is the required version for the client. The `Pipenv` and `Pipenv.lock` is using | ||
Python 3.7. | ||
|
||
### Requirements | ||
|
||
Compilation is needed for some of the cryptography dependencies for the client, so `python3.7-dev` should be installed | ||
with `sudo apt install python3.7-dev`. | ||
|
||
We use `pipenv` for the virtual environment. This isolates installed packages for the client from your system | ||
python install. This can be installed on Debian based systems with `sudo apt install pipenv`. | ||
|
||
`pipenv` is installed to the user's `.local/bin` folder. This will not be accessible without adding your | ||
`~/.local/bin` folder to `$PATH` in `.bashrc` or with other means. | ||
|
||
### Initialize pipenv | ||
|
||
`pipenv sync` will install all packages needed from the `Pipenv.lock` file. | ||
|
||
`pipenv shell` will open a shell inside the virtual environment. | ||
|
||
### Setup git precommit hooks | ||
|
||
This repo uses the python `pre-commit` package for pre-commit hooks. This package and `flake8` should be installed | ||
during the `pipenv sync` above. | ||
|
||
Inside the `pipenv`, run `python -m pre-commit install`. | ||
|
||
To run the hook outside of git triggered events, you can use: | ||
|
||
`pre-commit run` or `pre-commit run --all-files`. This are also available as part of the Makefile. | ||
|
||
### Makefile | ||
|
||
Many functions are available in the Makefile. To see all commands use `make help`. | ||
|
||
### CasperLabs repo dependency | ||
|
||
Building this package depends on the `proto` files available in the CasperLabs repo. This is expected | ||
to be in the same level directory of `client-py` repo. | ||
|
||
For running tests inside `manual-test`, the `CasperLabs/hack/docker` network stand-up is used. This expects | ||
all of the prerequisites to run `make docker-build-all` in the root of `CasperLabs` repo as well as | ||
`make contracts-rs` in `CasperLabs/execution-engine` for some `.wasm` contracts that are used in testing. | ||
|
||
### Building Distribution package | ||
|
||
`python setup.py sdist` will build the Python Client for distributing into `dist/casperlabs_client-X.X.X.tar.gz`. | ||
`make build` performs this command. | ||
|
||
The package can be installed for testing with `python -m pip install dist/casperlabs_client-X.X.X.tar.gz`. | ||
|
||
If run outside of the pipenv, use `python3.7 -m pip install dist/casperlavs_client-X.X.X.tar.gz` | ||
|
||
### Building Development package | ||
|
||
It is best practice to test the installed version of a Python package. The tests have been created to run on the installed version. | ||
|
||
Inside the pipenv, run `python setup.py develop` or `make develop`. This makes the `casperlabs_client` library and CLI available, but | ||
will also reference actual source in the package. So changes to source files immediately affect the installed package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM python:3.8-slim-buster | ||
MAINTAINER "CasperLabs, LLC. <[email protected]>" | ||
|
||
USER root | ||
WORKDIR /opt/docker | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends g++ protobuf-compiler make \ | ||
&& apt-get clean | ||
|
||
ENTRYPOINT ["casperlabs_client"] | ||
|
||
# COPY and run pip install before other source, so cached with src changes. | ||
COPY requirements.txt /src/requirements.txt | ||
RUN cd /src \ | ||
&& pip install -r requirements.txt | ||
|
||
COPY . /src | ||
|
||
RUN cd /src \ | ||
&& python setup.py sdist \ | ||
&& python -m pip install dist/casperlabs_client* \ | ||
&& pytest tests |
Oops, something went wrong.