From fb742232d42eb945a807412be9261798df1780c6 Mon Sep 17 00:00:00 2001 From: Lupusalix Date: Fri, 21 Jan 2022 12:32:49 +0000 Subject: [PATCH] Devcontainers Signed-off-by: Lupusalix Co-authored-by: Wade Barnes --- .devcontainer/Dockerfile | 81 +++++++++++++++++++ .devcontainer/devcontainer.json | 32 ++++++++ .../workflows/build/Dockerfile.ubuntu-2004 | 2 +- .gitpod.Dockerfile | 73 +++++++++++++++++ .gitpod.yml | 27 +++++++ .vscode/settings.json | 12 +++ README.md | 15 ++++ pytest.ini | 11 +++ 8 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitpod.Dockerfile create mode 100644 .gitpod.yml create mode 100644 .vscode/settings.json create mode 100644 pytest.ini diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..acf167678b --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,81 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ubuntu/.devcontainer/base.Dockerfile + +# [Choice] Ubuntu version (use hirsuite or bionic on local arm64/Apple Silicon): hirsute, focal, bionic +ARG VARIANT="focal" +FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT} + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +RUN apt-get update -y && apt-get install -y \ + # common stuff + git \ + wget \ + gnupg \ + apt-transport-https \ + ca-certificates \ + apt-utils \ + curl \ + jq + + +# ======================================================================================================== +# Update repository signing keys +# -------------------------------------------------------------------------------------------------------- + # Hyperledger +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9692C00E657DDE61 && \ + # Sovrin + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 +# ======================================================================================================== + + +# Plenum +# - https://github.com/hyperledger/indy-plenum/issues/1546 +# - Needed to pick up rocksdb=5.8.8 +RUN echo "deb https://hyperledger.jfrog.io/artifactory/indy focal dev" >> /etc/apt/sources.list && \ + echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list && \ + echo "deb https://repo.sovrin.org/deb bionic master" >> /etc/apt/sources.list && \ + echo "deb https://repo.sovrin.org/sdk/deb bionic master" >> /etc/apt/sources.list + +RUN apt-get update -y && apt-get install -y \ + # Python + python3-pip \ + python3-nacl \ + # rocksdb python wrapper + rocksdb=5.8.8 \ + libgflags-dev \ + libsnappy-dev \ + zlib1g-dev \ + libbz2-dev \ + liblz4-dev \ + libgflags-dev \ + # zstd is needed for caching in github actions pipeline + zstd \ + # fpm + ruby \ + ruby-dev \ + rubygems \ + gcc \ + make \ + # Indy Node and Plenum + libssl1.0.0 \ + ursa=0.3.2-1 \ + # Indy SDK + libindy=1.15.0~1625-bionic \ + # Need to move libursa.so to parent dir + && mv /usr/lib/ursa/* /usr/lib && rm -rf /usr/lib/ursa + +RUN pip3 install -U \ + # Required by setup.py + setuptools==50.3.2 \ + # Linting tools + pep8==1.7.1 \ + pep8-naming==0.6.1 \ + flake8==3.8.4 + + +# install rake +RUN gem install --no-document rake +## install fpm; needs to be pinned to 1.13.1 because some packages cannot be built with the newest release 1.14.0 +RUN gem install --no-document fpm -v 1.13.1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..52896fe80f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ubuntu +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic + // Use hirsute or bionic on local arm64/Apple Silicon. + "args": { "VARIANT": "focal" } + }, + + // Set *default* container specific settings.json values on container create. + "settings": {}, + + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "mhutchie.git-graph", + "eamodio.gitlens", + "ms-python.python" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // pip 20.0.2 will complain about version mismatches but will install indy sdk correctly. Newer versions of pip will need to use the `--use-deprecated legacy-resolver`. See https://github.com/hyperledger/indy-sdk/issues/2473 + "postCreateCommand": "pip install .[tests]", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} \ No newline at end of file diff --git a/.github/workflows/build/Dockerfile.ubuntu-2004 b/.github/workflows/build/Dockerfile.ubuntu-2004 index d611b3c0f2..2eff009d42 100644 --- a/.github/workflows/build/Dockerfile.ubuntu-2004 +++ b/.github/workflows/build/Dockerfile.ubuntu-2004 @@ -26,7 +26,7 @@ RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9692C00E657DDE61 && # Plenum # - https://github.com/hyperledger/indy-plenum/issues/1546 # - Needed to pick up rocksdb=5.8.8 -RUN echo "deb https://hyperledger.jfrog.io/artifactory/indy focal dev" >> /etc/apt/sources.list && \ +RUN echo "deb https://hyperledger.jfrog.io/artifactory/indy focal dev" >> /etc/apt/sources.list && \ echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list && \ echo "deb https://repo.sovrin.org/deb bionic master" >> /etc/apt/sources.list && \ echo "deb https://repo.sovrin.org/sdk/deb bionic master" >> /etc/apt/sources.list diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000000..d08ef9d532 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,73 @@ +FROM gitpod/workspace-full as base + +USER gitpod + + +RUN sudo apt-get update -y && sudo apt-get install -y \ + # common stuff + git \ + wget \ + gnupg \ + apt-transport-https \ + ca-certificates \ + apt-utils \ + curl \ + jq + +# ======================================================================================================== +# Update repository signing keys +# -------------------------------------------------------------------------------------------------------- +# Hyperledger +RUN sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9692C00E657DDE61 && \ + # Sovrin + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 +# ======================================================================================================== + +# Plenum +# - https://github.com/hyperledger/indy-plenum/issues/1546 +# - Needed to pick up rocksdb=5.8.8 +RUN sudo add-apt-repository 'deb https://hyperledger.jfrog.io/artifactory/indy focal dev' && \ + sudo add-apt-repository 'deb http://security.ubuntu.com/ubuntu bionic-security main' && \ + sudo add-apt-repository 'deb https://repo.sovrin.org/deb bionic master' && \ + sudo add-apt-repository 'deb https://repo.sovrin.org/sdk/deb bionic master' + +RUN sudo apt-get update -y && sudo apt-get install -y \ + # Python + python3-pip \ + python3-nacl \ + # rocksdb python wrapper + rocksdb=5.8.8 \ + libgflags-dev \ + libsnappy-dev \ + zlib1g-dev \ + libbz2-dev \ + liblz4-dev \ + libgflags-dev \ + # zstd is needed for caching in github actions pipeline + zstd \ + # fpm + ruby \ + ruby-dev \ + rubygems \ + gcc \ + make \ + # Indy Node and Plenum + libssl1.0.0 \ + ursa=0.3.2-1 \ + # Indy SDK + libindy=1.15.0~1625-bionic \ + # Need to move libursa.so to parent dir + && sudo mv /usr/lib/ursa/* /usr/lib && sudo rm -rf /usr/lib/ursa + +RUN pip3 install -U \ + # Required by setup.py + setuptools==50.3.2 \ + # Linting tools + pep8==1.7.1 \ + pep8-naming==0.6.1 \ + flake8==3.8.4 + +# install rake +RUN sudo gem install --no-document rake +## install fpm; needs to be pinned to 1.13.1 because some packages cannot be built with the newest release 1.14.0 +RUN sudo gem install --no-document fpm -v 1.13.1 \ No newline at end of file diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000000..e72f72306e --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,27 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - name: Pip installs + #Deprecated Legacy Resolver neeeded because of https://github.com/hyperledger/indy-sdk/issues/2473 + init: pip install --use-deprecated legacy-resolver .[tests] + +github: + prebuilds: + # enable for the master/default branch (defaults to true) + master: false + # enable for all branches in this repo (defaults to false) + branches: false + # enable for pull requests coming from this repo (defaults to true) + pullRequests: false + # enable for pull requests coming from forks (defaults to false) + pullRequestsFromForks: false + # add a "Review in Gitpod" button as a comment to pull requests (defaults to true) + addComment: false + # add a "Review in Gitpod" button to pull requests (defaults to false) + addBadge: false + # add a label once the prebuild is ready to pull requests (defaults to false) + addLabel: false + +vscode: + extensions: ["mhutchie.git-graph", "eamodio.gitlens","ms-python.python" ] \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..b1ac01a9dc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true, + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.linting.mypyEnabled": false, + "python.testing.pytestArgs": [ + "-c", + "pytest.ini" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index e01ef8efa6..d5e7dab54d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ ![logo](indy-logo.png) +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://gitpod.io/#https://github.com/hyperledger/indy-plenum/tree/ubuntu-20.04-upgrade) + + * [Plenum Byzantine Fault Tolerant Protocol](#plenum-byzantine-fault-tolerant-protocol) * [Technical Overview of Indy Plenum](#technical-overview-of-indy-plenum) * [Other Documentation](#other-documentation) @@ -84,6 +87,18 @@ Use project name `INDY`. ## How to Start Working with the Code +The preferred method of setting up the development environment is to use the devcontainers. +All configuration files for VSCode and [Gitpod](https://gitpod.io) are already placed in this repository. +If you are new to the concept of devcontainers in combination with VSCode [here](https://code.visualstudio.com/docs/remote/containers) is a good article about it. + +Simply clone this repository and VSCode will most likely ask you to open it in the devcontainer, if you have the correct extension("ms-vscode-remote.remote-containers") installed. +If VSCode didn't ask to open it, open the command palette and use the `Remote-Containers: Rebuild and Reopen in Container` command. + +If you want to use Gitpod simply use this [link](https://gitpod.io/#https://github.com/hyperledger/indy-plenum/tree/ubuntu-20.04-upgrade) +or if you want to work with your fork, prefix the entire URL of your branch with `gitpod.io/#` so that it looks like `https://gitpod.io/#https://github.com/hyperledger/indy-plenum/tree/ubuntu-20.04-upgrade`. + +**Note**: Be aware that the config files for Gitpod and VSCode are currently only used in the `ubuntu-20.04-upgrade` branch! + Please have a look at [Dev Setup](https://github.com/hyperledger/indy-node/blob/master/docs/setup-dev.md) in indy-node repo. It contains common setup for both indy-plenum and indy-node. diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000..64911d5a1e --- /dev/null +++ b/pytest.ini @@ -0,0 +1,11 @@ +[pytest] +asyncio_mode = auto +testpaths = + plenum + common + crypto + ledger + state + storage + stp_core + stp_zmq \ No newline at end of file