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

wait for finalization #684

Merged
merged 34 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e71115d
wait for finalization
fbielejec Oct 26, 2022
75ed49b
say no to oncurrent jobs
fbielejec Oct 26, 2022
4319384
trigger, remove labels
fbielejec Oct 26, 2022
3eca2eb
OK
fbielejec Oct 26, 2022
3992fe2
Merge branch 'benjamin' into fix-e2e
fbielejec Oct 26, 2022
a01b1fd
wtf
fbielejec Oct 26, 2022
d8cd778
show networks
fbielejec Oct 26, 2022
8841ccc
rerun
fbielejec Oct 26, 2022
9e6f1ab
short lived wf
fbielejec Oct 26, 2022
6a39be2
run it
fbielejec Oct 26, 2022
86b52a4
need code
fbielejec Oct 26, 2022
2bcced3
just use host
fbielejec Oct 26, 2022
55aaaef
mhm
fbielejec Oct 26, 2022
c4f86a0
co tu sie
fbielejec Oct 26, 2022
b16e4fe
debug
fbielejec Oct 26, 2022
24cd7ed
get a shell
fbielejec Oct 26, 2022
2607a3d
add missing flag
fbielejec Oct 26, 2022
fe78a4f
aaaaaa
fbielejec Oct 26, 2022
b827a29
get shell
fbielejec Oct 26, 2022
44a72db
show me the logs
fbielejec Oct 26, 2022
3c4a3c7
docke rnet
fbielejec Oct 26, 2022
52d6a89
fixit
fbielejec Oct 26, 2022
ed450be
off you go
fbielejec Oct 26, 2022
0d767f6
yesh
fbielejec Oct 26, 2022
e363769
test workflow dispatch
fbielejec Oct 26, 2022
47c790a
deployment triggered by tests
fbielejec Oct 26, 2022
b83f7af
cleanup
fbielejec Oct 26, 2022
698428f
TODOs
fbielejec Oct 27, 2022
5aff6c1
try the trigger
fbielejec Oct 27, 2022
8d41a20
add dispatch trigger
fbielejec Oct 27, 2022
7fbae16
Blend contracts e2e tests and deployment workflows into one workflow
mikolajgs Oct 27, 2022
b1a7d6f
Oops! Remove duplicated workflow
mikolajgs Oct 27, 2022
6277e75
addressing comments
fbielejec Oct 27, 2022
6a282a6
Add triggering indexer deployment workflow
mikolajgs Oct 27, 2022
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
16 changes: 11 additions & 5 deletions .github/scripts/check_finalization.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/bash

RPC_HOST=127.0.0.1
RPC_PORT=9933
## USAGE
## .github/scripts/check_finalization.sh <rpc-host> <rpc-port>
## if <rpc-host> <rpc-port> <network> are empty default values will be used (127.0.0.1, 9933 and host)
##

RPC_HOST=${1:-127.0.0.1}
RPC_PORT=${2:-9933}
NETWORK=${3:-host}

LAST_FINALIZED=""
VALIDATOR=damian

while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do
block_hash=$(docker run --network container:$VALIDATOR appropriate/curl:latest \
block_hash=$(docker run --network $NETWORK appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getFinalizedHead"}' http://$RPC_HOST:$RPC_PORT | jq '.result')
ret_val=$?
Expand All @@ -15,7 +21,7 @@ while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do
continue
fi

finalized_block=$(docker run --network container:$VALIDATOR appropriate/curl:latest \
finalized_block=$(docker run --network $NETWORK appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params": ['$block_hash']}' http://$RPC_HOST:$RPC_PORT | jq '.result.block.header.number')

Expand Down
3 changes: 1 addition & 2 deletions .github/scripts/run_smartnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ docker run --rm -v $(pwd)/docker/data:/data --entrypoint "/bin/sh" -e RUST_LOG=d
export BOOTNODE_PEER_ID=$(docker run --rm -v $(pwd)/docker/data:/data --entrypoint "/bin/sh" -e RUST_LOG=info "${NODE_IMAGE}" -c "aleph-node key inspect-node-key --file /data/$NODE_ID/p2p_secret")

docker network create node-network || true
docker-compose -f docker/smartnet-compose.yml up --remove-orphans

docker-compose -f docker/smartnet-compose.yml up --remove-orphans
exit $?
Original file line number Diff line number Diff line change
@@ -1,40 +1,142 @@
name: Deploy The Button game
name: contracts-e2e-tests-and-deploy

on:
pull_request:
types: [labeled]
paths:
- 'contracts/**'
- '.github/**'
push:
paths:
- 'contracts/**'
- '.github/**'
branches:
- benjamin
paths:
- contracts/**

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

env:
CHECKOUT_REF: benjamin
CHECKOUT_BRANCH: benjamin
CACHE_KEY: fe-benjamin-button
CONTRACTS_ENVFILE: fe-benjamin
CARGOCONTRACT_REV: 2b1758756de59bd81e7bed5f8429d364f281cb9a
NODE_VERSION: 16
S3BUCKET_PATH: contracts/fe-benjamin-button
LABEL_DEPLOY_CONTRACTS: '[AZERO] DEPLOY-CONTRACTS'
LABEL_DESTROYED: 'DESTROYED'
LABEL_DEPLOYED: 'DEPLOYED'
LABEL_DEPLOYED_CONTRACTS: 'DEPLOYED-CONTRACTS'

jobs:
checkout_benjamin:
if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == '[AZERO] DEPLOY-CONTRACTS')
run-tests:
name: Run smart contracts test suite
runs-on: ubuntu-20.04
env:
RUST_BACKTRACE: full
steps:
- name: Install binaryen
run: |
wget https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz
tar xvzf binaryen-version_101-x86_64-linux.tar.gz
cd binaryen-version_101
sudo cp -r bin/* /bin
sudo cp -r include/* /usr/include
sudo cp -r lib64/* /lib64

- name: Display binaryen version
shell: bash
run: wasm-opt --version

- name: Checkout Source code
uses: actions/checkout@v3

- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1

- name: Install WASM target
run: rustup target add wasm32-unknown-unknown

- name: Install rust-src
run: rustup component add rust-src

- name: Restore cache
uses: ./.github/actions/restore-cache
with:
target-key: e2e-contracts
cargo-key: e2e-contracts
cache-version: v3
cargo-targets: e2e-tests-contracts/target/

- name: Install cargo-contract
run: |
cargo install cargo-dylint dylint-link --force
# revision merging Hans's PR changes [fix for node URL parsing ]
cargo install --git https://github.com/paritytech/cargo-contract.git --rev 2b1758756de59bd81e7bed5f8429d364f281cb9a --force

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

- name: Login to Public Amazon ECR
id: login-public-ecr
uses: docker/login-action@v1
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1

- name: Run one-node smartnet
shell: bash
run: |
.github/scripts/run_smartnet.sh &

- name: Display node logs
shell: bash
run: |
docker logs smartnode --follow &

# wait some while docker pulls the image and starts the node
- name: Wait for finalization
shell: bash
run: |
.github/scripts/check_finalization.sh
timeout-minutes: 1

- name: Run e2e tests
shell: bash
run: |
source ./contracts/env/dev && ./contracts/scripts/deploy.sh && ./contracts/scripts/test.sh

- name: Cleanup cache
uses: ./.github/actions/post-cache

slack:
name: Slack notification
runs-on: ubuntu-latest
needs: [run-tests]
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Send Slack message
uses: ./.github/actions/slack-notification
with:
notify-on: "failure"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

build_and_deploy_contracts:
name: Deploy contracts on feature environment
needs: [run-tests]
runs-on: ubuntu-20.04
#runs-on: self-hosted
steps:
- name: Checkout repo
uses: actions/checkout@v2.3.4
with:
ref: ${{ env.CHECKOUT_REF }}
ref: ${{ env.CHECKOUT_BRANCH }}

- name: Check if environment is reachable
shell: bash
Expand Down Expand Up @@ -103,15 +205,13 @@ jobs:
aws-region: ${{ env.AWS_REGION }}

- name: Get contracts' target directories cache from S3 bucket
if: (github.event_name == 'push') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, env.LABEL_DEPLOYED_CONTRACTS))
shell: bash
continue-on-error: true
run: |
aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/targets.tgz targets.tgz
tar -xzf targets.tgz

- name: Copy metadata.json and addresses.json files from S3 bucket
if: (github.event_name == 'push') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, env.LABEL_DEPLOYED_CONTRACTS))
shell: bash
run: |
aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json contracts/addresses.json
Expand Down Expand Up @@ -179,28 +279,17 @@ jobs:
contracts/access_control/target
aws s3 cp targets.tgz s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/targets.tgz

- name: Trigger Indexer deployment workflow
run: |
curl -X POST 'https://api.github.com/repos/Cardinal-Cryptography/indexer/actions/workflows/build-and-deploy-to-devnet.yml/dispatches' \
-H "Accept: application/vnd.github+json" \
-H 'Authorization: Bearer ${{ secrets.CI_GH_TOKEN }}' \
-d '{ "ref":"master" }'

- name: Trigger The Button deployment workflow
run: |
curl -X POST 'https://api.github.com/repos/Cardinal-Cryptography/the-button/actions/workflows/main.yaml/dispatches' \
-H "Accept: application/vnd.github+json" \
-H 'Authorization: Bearer ${{ secrets.CI_GH_TOKEN }}' \
-d '{ "ref":"main", "inputs": { "buildImage": "false", "deployImage": "true" }}'

- name: Add label to mark that contracts have been deployed
uses: actions-ecosystem/action-add-labels@v1.1.0
with:
labels: ${{ env.LABEL_DEPLOYED_CONTRACTS }}
github_token: ${{ secrets.CI_GH_TOKEN }}

- name: Remove request label if exists
if: contains(github.event.pull_request.labels.*.name, env.LABEL_DEPLOY_CONTRACTS)
uses: actions-ecosystem/action-remove-labels@v1.3.0
with:
labels: ${{ env.LABEL_DEPLOY_CONTRACTS }}
github_token: ${{ secrets.CI_GH_TOKEN }}

- name: Create empty target directory so that restore-cache does not fail
run: |
mkdir -p target
touch target/emptyfile

111 changes: 0 additions & 111 deletions .github/workflows/e2e-tests-contracts.yml

This file was deleted.

1 change: 0 additions & 1 deletion contracts/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ ACCESS_CONTROL_PUBKEY=$(docker run --rm --entrypoint "/bin/sh" "${NODE_IMAGE}" -
echo "access control contract address: $ACCESS_CONTROL"
echo "access control contract public key \(hex\): $ACCESS_CONTROL_PUBKEY"


# --- UPLOAD CONTRACTS CODES

upload_contract TICKET_TOKEN_CODE_HASH ticket_token
Expand Down
2 changes: 2 additions & 0 deletions docker/smartnet-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
- WS_PORT=9943
- BOOT_NODES=/ip4/127.0.0.1/tcp/30333/p2p/$BOOTNODE_PEER_ID
- PUBLIC_ADDR=/ip4/127.0.0.1/tcp/30333
- VALIDATOR_PORT=30343
- PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30343
volumes:
- ./data/:/data/
expose:
Expand Down