Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more commands to the encointer-client docker image and test them in CI #385

Merged
merged 36 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5ec505e
[CI] put all scripts into the docker container
clangenb Jan 14, 2025
1ea5bc6
[CI] fix bootstrap commant to run int docker
clangenb Jan 14, 2025
5e4f412
[CI] fix phase.py to work in docker
clangenb Jan 15, 2025
6149eb2
[CI] fix faucet.py to run in docker
clangenb Jan 15, 2025
378429a
[CI] add checking the botstats to the docker
clangenb Jan 15, 2025
1e0f3ca
try making the bot-community.py script work, but it fails to connect …
clangenb Jan 15, 2025
324a0cb
add some documentation
clangenb Jan 15, 2025
8421b29
fix connecting to the faucet
clangenb Jan 15, 2025
67d6d79
fix faucet
clangenb Jan 15, 2025
741944c
remove comment that it doesn't work
clangenb Jan 15, 2025
3c840b7
docker build now uses the current dir to look for the encointer-clien…
clangenb Jan 15, 2025
4e737e0
add integration tests for the docker
clangenb Jan 15, 2025
2511bbf
remove -ti flag for docker runs
clangenb Jan 15, 2025
4240b89
[CI] remove unnecessary steps
clangenb Jan 15, 2025
053c670
[CI] fix matrix
clangenb Jan 15, 2025
617c8d0
[CI] downgrade to ubuntu 22.04
clangenb Jan 15, 2025
2cda391
[CI] fix syntax
clangenb Jan 15, 2025
af47189
[CI] update rust cache actions
clangenb Jan 15, 2025
7d81727
remove unnecessary python setup
clangenb Jan 15, 2025
6a6f391
don't fail fast in docker integration tests
clangenb Jan 15, 2025
d27a3fc
try fixing the node command
clangenb Jan 15, 2025
7b07a3c
download past artifacts for debugging
clangenb Jan 15, 2025
622b845
disable previous steps
clangenb Jan 15, 2025
db111ef
fix CI run for artifact download
clangenb Jan 15, 2025
64c117d
fix docker build
clangenb Jan 15, 2025
1b3b56e
fix matrix tests
clangenb Jan 15, 2025
bf45398
try to avoid port collision
clangenb Jan 15, 2025
01420ee
unify interface of scripts regarding url
clangenb Jan 15, 2025
01b7dba
fix bootstrap script and disable business docker CI for now
clangenb Jan 15, 2025
bdf1b91
fix entry script
clangenb Jan 15, 2025
b665e6b
fix docker cache
clangenb Jan 15, 2025
e1742b2
fix new script interface
clangenb Jan 15, 2025
41abe4c
fix new script interface 2
clangenb Jan 15, 2025
a84b162
fix documentation and remove unnecessary port exposure
clangenb Jan 15, 2025
5fa8e22
document in which cases url accepts gesell as value
clangenb Jan 15, 2025
acb55ff
enable the rest of the CI again
clangenb Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 128 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ env:
jobs:
cancel_previous_runs:
name: Cancel Previous Runs
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
brenzi marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/checkout@v3

Expand All @@ -39,15 +39,9 @@ jobs:
- name: Setup Rust toolchain
run: rustup show

- name: Cache Rust Dependecies
uses: actions/cache@v3
- uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
enclave/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
shared-key: "release"

- name: Build
run: cargo build --release
Expand All @@ -63,7 +57,7 @@ jobs:
path: target/release/encointer-client-notee

build-try-runtime-and-benchmarks:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

Expand All @@ -75,15 +69,9 @@ jobs:
- name: Setup Rust toolchain
run: rustup show

- name: Cache Rust Dependecies
uses: actions/cache@v3
- uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
enclave/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
shared-key: "release"

- name: Build
run: cargo build --release --features try-runtime,runtime-benchmarks
Expand All @@ -100,7 +88,7 @@ jobs:

build-runtimes:
name: Build Runtimes
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
runtime: [ "encointer-node-notee" ]
Expand All @@ -115,6 +103,7 @@ jobs:
restore-keys: |
srtool-target-${{ matrix.runtime }}-
srtool-target-

- name: Srtool build
id: srtool_build
uses: chevdor/[email protected]
Expand Down Expand Up @@ -166,7 +155,6 @@ jobs:
${{ matrix.runtime }}-metadata.json
# ${{ matrix.runtime }}-diff.txt


- name: Upload ${{ matrix.runtime }} runtime
uses: actions/upload-artifact@v4
with:
Expand All @@ -176,7 +164,7 @@ jobs:
${{ steps.srtool_build.outputs.wasm_compressed }}

unit-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

Expand All @@ -188,15 +176,9 @@ jobs:
- name: Setup Rust toolchain
run: rustup show

- name: Cache Rust Dependecies
uses: actions/cache@v3
- uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
enclave/target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
shared-key: "debug"

- name: cargo test
run: cargo test --all
Expand All @@ -206,7 +188,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-22.04 ]
rust: [ stable ]
rust-target: [ x86_64-unknown-linux-gnu ]
check: [ +nightly fmt --all -- --check, clippy -p encointer-client-notee ]
Expand Down Expand Up @@ -235,13 +217,13 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.rust-target }}-${{ matrix.check }}
shared-key: "debug"

- name: ${{ matrix.check }}
run: cargo ${{ matrix.check }}

cargo-toml-fmt:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container: "tamasfe/taplo:0.7.0-alpine"
steps:
- uses: actions/checkout@v3
Expand All @@ -255,7 +237,7 @@ jobs:

integration-test:
name: ${{ matrix.test }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: build
strategy:
matrix:
Expand Down Expand Up @@ -310,10 +292,120 @@ jobs:
working-directory: ./scripts/ci
run: source ./init_env.sh && ./${{ matrix.test }}

integration-test-docker:
name: ${{ matrix.test }}
runs-on: ubuntu-22.04
needs: build
strategy:
fail-fast: false
matrix:
test:
- bootstrap_demo_community.py --signer //Bob --test
- bot-community-test -f http://host.docker.internal:5000/api
# Todo: #386
# - test-register-businesses -f http://host.docker.internal:5000/api
steps:
- uses: actions/checkout@v3

- name: download build artifacts
uses: actions/download-artifact@v4
with:
name: encointer-node-notee-${{ github.sha }}
# for debugging the integration tests, we can just download an image from a previous run
# name: encointer-node-notee-4d0313f614223edf63cd0a5f0ad3d5ce16b81e6c
# github-token: ${{ github.token }}
# run-id: 12787265993

- name: download build artifacts
uses: actions/download-artifact@v4
with:
name: encointer-client-notee-${{ github.sha }}
# for debugging the integration tests, we can just download an image from a previous run
# name: encointer-client-notee-4d0313f614223edf63cd0a5f0ad3d5ce16b81e6c
# github-token: ${{ github.token }}
# run-id: 12787265993

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-node
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Docker build client
run: |
docker build \
--cache-from=type=gha \
-t encointer-client-test .

- name: Docker build node
run: |
docker build \
--cache-from=type=gha \
-f Dockerfile-node \
-t encointer-node-test .

- name: Set up ipfs
uses: ibnesayeed/setup-ipfs@master
with:
run_daemon: true

- name: start dev node
run: |
docker run -p 30333:30333 -p 9944:9944 -p 9615:9615 \
encointer-node-test \
--dev \
--enable-offchain-indexing=true \
--rpc-methods=unsafe \
-lencointer=debug,parity_ws=warn \
--rpc-external &

- name: start faucet service
run: |
docker run -p 5000:5000 \
--add-host host.docker.internal:host-gateway \
encointer-client-test faucet.py \
-u ws://host.docker.internal \
--port 9944 &

- name: start phase accelerator service
run: |
docker run \
--add-host host.docker.internal:host-gateway \
encointer-client-test phase.py \
-u ws://host.docker.internal \
--port 9944 --idle-blocks 3 &

- name: Test ${{ matrix.test }}
run: |
docker run \
--add-host host.docker.internal:host-gateway \
encointer-client-test ${{ matrix.test }} \
-u ws://host.docker.internal \
--port 9944 \

release:
name: Draft Release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ build, unit-tests, check, integration-test ]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
Expand Down Expand Up @@ -357,7 +449,7 @@ jobs:

publish-runtimes:
name: Publish Runtimes
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ release, build-runtimes ]
strategy:
matrix:
Expand Down
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:22.04
LABEL description="This is the 2nd stage: a very small image where we copy the Substrate binary."

RUN apt-get update && \
RUN apt-get update && \
apt-get install -y jq python3 python3-pip

RUN python3 -m pip install --upgrade pip
Expand All @@ -24,9 +24,17 @@ COPY encointer-client-notee /

RUN mkdir /client
COPY client/py_client /py_client
COPY client/test-data /test-data

# all python scripts (some of them aren supported by the entryfile.sh yet).
COPY client/bootstrap_demo_community.py /
COPY client/bot-community.py /
COPY client/bot-stats-golden.csv /
COPY client/cli.py /
COPY client/test-data /test-data
COPY client/faucet.py /
COPY client/phase.py /
COPY client/typedefs.json /
COPY client/register-random-businesses-and-offerings.py /

RUN chmod +x /encointer-client-notee
#RUN chmod +x /usr/local/bin/healthcheck9933.sh
Expand All @@ -40,7 +48,7 @@ RUN ldd /encointer-client-notee && \
# rm -rf /usr/bin /usr/sbin /usr/share/man

#USER encointer
EXPOSE 30333 9933 9944 9615
EXPOSE 30333 9933 9944 9615 5000
VOLUME ["/data"]

ENTRYPOINT ["/entryscript.sh"]
19 changes: 11 additions & 8 deletions client/bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@
import os




@click.group()
@click.option('--cid', required=True, help='the community identifier of the community you want to register your business in (11 digits).')
@click.option('--cid', required=True,
help='the community identifier of the community you want to register your business in (11 digits).')
@click.option('--bizaccount', required=False, help='the account of the owner in ss58 format or raw_seed.')
@click.option('--price', default='0', help='price of your offering.')
@click.option('--client', default='../target/release/encointer-client-notee', help='Client binary to communicate with the chain.')
@click.option('--client', default='../target/release/encointer-client-notee',
help='Client binary to communicate with the chain.')
@click.option('--port', default='9944', help='ws-port of the chain.')
@click.option('-r', '--remote_chain', default=None, help='choose remote chain: gesell.')
@click.option('-u', '--url', default='ws://127.0.0.1', help='URL of the chain, or `gesell` alternatively.')
@click.pass_context
def cli(ctx, client, port, cid, bizaccount, price, remote_chain):
def cli(ctx, client, port, cid, bizaccount, price, url):
ctx.ensure_object(dict)
cl = set_local_or_remote_chain(client, port, remote_chain)
cl = set_local_or_remote_chain(client, port, url)
ctx.obj['client'] = cl
ctx.obj['port'] = port
ctx.obj['cid'] = cid
ctx.obj['bizaccount'] = bizaccount
# ctx.obj['ipfs_local'] = ipfs_local
ctx.obj['remote_chain'] = remote_chain
ctx.obj['url'] = url
ctx.obj['price'] = price


Expand Down Expand Up @@ -132,6 +132,7 @@ def register_offering(ctx, specfile):
except:
print("error creating an offering entry")


@cli.command()
@click.pass_obj
def list_businesses(ctx):
Expand All @@ -143,6 +144,7 @@ def list_businesses(ctx):
client = ctx['client']
print(client.list_businesses(ctx['cid']))


@cli.command()
@click.pass_obj
def list_offerings(ctx):
Expand All @@ -159,5 +161,6 @@ def list_offerings(ctx):
else:
print(client.list_offerings_for_business(ctx['cid'], ctx["bizaccount"]))


if __name__ == '__main__':
cli(obj={})
2 changes: 1 addition & 1 deletion client/bootstrap_demo_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def test_democracy(client, cid):
@click.option('--client', default='../target/release/encointer-client-notee',
help='Client binary to communicate with the chain.')
@click.option('--signer', help='optional account keypair creating the community')
@click.option('-u', '--url', default='ws://127.0.0.1', help='URL of the chain.')
@click.option('-u', '--url', default='ws://127.0.0.1', help='URL of the chain, or `gesell` alternatively.')
@click.option('-p', '--port', default='9944', help='ws-port of the chain.')
@click.option('-l', '--ipfs-local', is_flag=True, help='if set, local ipfs node is used.')
@click.option('-s', '--spec-file', default=f'{TEST_DATA_DIR}{TEST_LOCATIONS_MEDITERRANEAN}',
Expand Down
Loading
Loading