From e71115dd4832019a6b3b396c7f7105b57d6c7beb Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 10:19:15 +0200 Subject: [PATCH 01/33] wait for finalization --- .github/scripts/check_finalization.sh | 15 ++++++++++----- .github/workflows/deploy-the-button.yaml | 3 +-- .github/workflows/e2e-tests-contracts.yml | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/scripts/check_finalization.sh b/.github/scripts/check_finalization.sh index 36d21ad191..f5f0ed9fb0 100755 --- a/.github/scripts/check_finalization.sh +++ b/.github/scripts/check_finalization.sh @@ -1,12 +1,17 @@ #!/bin/bash -RPC_HOST=127.0.0.1 -RPC_PORT=9933 +## USAGE +## .github/scripts/check_finalization.sh +## if are empty default values will be used (127.0.0.1 and 9933) +## + +RPC_HOST=${1:-127.0.0.1} +RPC_PORT=${2:-9933} + 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 host 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=$? @@ -15,7 +20,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 host 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') diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index 0d0d3179d3..5a7d98a765 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -26,7 +26,7 @@ env: LABEL_DEPLOYED_CONTRACTS: 'DEPLOYED-CONTRACTS' jobs: - checkout_benjamin: + build_and_deploy_contracts: if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') runs-on: ubuntu-20.04 #runs-on: self-hosted @@ -203,4 +203,3 @@ jobs: run: | mkdir -p target touch target/emptyfile - diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 0840531f52..4510728128 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -82,9 +82,9 @@ jobs: run: ./.github/scripts/run_smartnet.sh & # wait some while docker pulls the image and starts the node - - name: Sleep for a while + - name: Wait for finalization shell: bash - run: sleep 2 + run: ./.github/scripts/check_finalization.sh - name: Run e2e tests shell: bash From 75ed49b6c380a4ad66a02a4761e367aa9145fc5c Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 10:25:16 +0200 Subject: [PATCH 02/33] say no to oncurrent jobs --- .github/workflows/deploy-the-button.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index 5a7d98a765..5f12c41f3a 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -9,9 +9,10 @@ on: paths: - contracts/** +# allow only once run instance of this workflow ever concurrency: group: ${{ github.workflow }} - cancel-in-progress: true + cancel-in-progress: false env: CHECKOUT_REF: benjamin From 4319384796bc44e0d2234b9882ae659e0dcf018c Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 11:19:43 +0200 Subject: [PATCH 03/33] trigger, remove labels --- .github/workflows/deploy-the-button.yaml | 51 +++++++++++------------ .github/workflows/e2e-tests-contracts.yml | 4 ++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index 5f12c41f3a..36e4905ada 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -1,13 +1,11 @@ name: Deploy The Button game +# triggered by the e2e-tests-contracts on: - pull_request: - types: [labeled] - push: - branches: - - benjamin - paths: - - contracts/** + workflow_run: + workflows: [e2e-tests-contracts] + types: + - completed # allow only once run instance of this workflow ever concurrency: @@ -21,16 +19,15 @@ env: 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' + # LABEL_DEPLOY_CONTRACTS: '[AZERO] DEPLOY-CONTRACTS' + # LABEL_DESTROYED: 'DESTROYED' + # LABEL_DEPLOYED: 'DEPLOYED' + # LABEL_DEPLOYED_CONTRACTS: 'DEPLOYED-CONTRACTS' jobs: build_and_deploy_contracts: - if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') + # if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') runs-on: ubuntu-20.04 - #runs-on: self-hosted steps: - name: Checkout repo uses: actions/checkout@v2.3.4 @@ -104,7 +101,7 @@ 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)) + # 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: | @@ -112,7 +109,7 @@ jobs: 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)) + # 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 @@ -187,18 +184,18 @@ jobs: -H 'Authorization: Bearer ${{ secrets.CI_GH_TOKEN }}' \ -d '{ "ref":"main", "inputs": { "buildImage": "false", "deployImage": "true", "buildFEBenjaminImage": "true", "deployFEBenjaminImage": "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: 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: | diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 4510728128..024fb051c7 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -4,9 +4,13 @@ on: pull_request: paths: - 'contracts/**' + - '.github/**' push: + branches: + - benjamin paths: - 'contracts/**' + - '.github/**' workflow_dispatch: concurrency: From 3eca2eb71e418dfe9be76faf465a5e16148f415c Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 11:52:33 +0200 Subject: [PATCH 04/33] OK --- .github/scripts/check_finalization.sh | 7 +++--- .github/workflows/deploy-the-button.yaml | 26 ++++------------------- .github/workflows/e2e-tests-contracts.yml | 11 +++++----- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/.github/scripts/check_finalization.sh b/.github/scripts/check_finalization.sh index f5f0ed9fb0..aa27fefe9d 100755 --- a/.github/scripts/check_finalization.sh +++ b/.github/scripts/check_finalization.sh @@ -2,16 +2,17 @@ ## USAGE ## .github/scripts/check_finalization.sh -## if are empty default values will be used (127.0.0.1 and 9933) +## if 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="" while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do - block_hash=$(docker run --network host 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=$? @@ -20,7 +21,7 @@ while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do continue fi - finalized_block=$(docker run --network host 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') diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index 36e4905ada..5ae1be03dc 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -6,6 +6,8 @@ on: workflows: [e2e-tests-contracts] types: - completed + branches: + - benjamin # allow only once run instance of this workflow ever concurrency: @@ -13,26 +15,21 @@ concurrency: cancel-in-progress: false 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: build_and_deploy_contracts: - # if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') runs-on: ubuntu-20.04 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 @@ -101,7 +98,6 @@ 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: | @@ -109,7 +105,6 @@ jobs: 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 @@ -184,19 +179,6 @@ jobs: -H 'Authorization: Bearer ${{ secrets.CI_GH_TOKEN }}' \ -d '{ "ref":"main", "inputs": { "buildImage": "false", "deployImage": "true", "buildFEBenjaminImage": "true", "deployFEBenjaminImage": "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 diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 024fb051c7..5c50a02c68 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -6,12 +6,11 @@ on: - 'contracts/**' - '.github/**' push: - branches: - - benjamin paths: - 'contracts/**' - '.github/**' - workflow_dispatch: + branches: + - benjamin concurrency: group: ${{ github.ref }}-${{ github.workflow }} @@ -41,6 +40,7 @@ jobs: - name: Checkout Source code uses: actions/checkout@v3 + - name: Install Rust Toolchain uses: actions-rs/toolchain@v1 @@ -88,8 +88,9 @@ jobs: # wait some while docker pulls the image and starts the node - name: Wait for finalization shell: bash - run: ./.github/scripts/check_finalization.sh - + run: .github/scripts/check_finalization.sh smartnode 9933 node-network + timeout-minutes: 1 + - name: Run e2e tests shell: bash run: | From a01b1fdba68a66a17892e27ed15dd11d556ad00c Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 12:24:00 +0200 Subject: [PATCH 05/33] wtf --- .github/workflows/e2e-tests-contracts.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 5c50a02c68..8625be225b 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true +env: + CHECKOUT_BRANCH: benjamin + jobs: run-tests: name: Run smart contracts test suite @@ -39,8 +42,9 @@ jobs: - name: Checkout Source code uses: actions/checkout@v3 + with: + ref: ${{ env.CHECKOUT_BRANCH }} - - name: Install Rust Toolchain uses: actions-rs/toolchain@v1 @@ -90,7 +94,7 @@ jobs: shell: bash run: .github/scripts/check_finalization.sh smartnode 9933 node-network timeout-minutes: 1 - + - name: Run e2e tests shell: bash run: | From d8cd778cf8782e1196eacd574e9c8f8556218035 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 12:33:19 +0200 Subject: [PATCH 06/33] show networks --- .github/workflows/e2e-tests-contracts.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 8625be225b..3eb7cc94bc 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -42,8 +42,6 @@ jobs: - name: Checkout Source code uses: actions/checkout@v3 - with: - ref: ${{ env.CHECKOUT_BRANCH }} - name: Install Rust Toolchain uses: actions-rs/toolchain@v1 @@ -92,7 +90,9 @@ jobs: # wait some while docker pulls the image and starts the node - name: Wait for finalization shell: bash - run: .github/scripts/check_finalization.sh smartnode 9933 node-network + run: | + docker network inspect node-network + .github/scripts/check_finalization.sh smartnode 9933 node-network timeout-minutes: 1 - name: Run e2e tests From 8841ccc2fc362554201f616f83f216b9172d4ae2 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 12:39:57 +0200 Subject: [PATCH 07/33] rerun --- .github/workflows/e2e-tests-contracts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 3eb7cc94bc..7e28892aab 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -91,8 +91,8 @@ jobs: - name: Wait for finalization shell: bash run: | - docker network inspect node-network - .github/scripts/check_finalization.sh smartnode 9933 node-network + docker network inspect node-networkx + .github/scripts/check_finalization.sh smartnode 9933 node-network timeout-minutes: 1 - name: Run e2e tests From 9e6f1ab70de36bb251522ae3eb9d3f5ded5d83cd Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 12:48:22 +0200 Subject: [PATCH 08/33] short lived wf --- .github/workflows/e2e-tests-contracts.yml | 129 +++++++++++----------- 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 7e28892aab..41adbd4d12 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -27,44 +27,44 @@ jobs: 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: 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 @@ -87,34 +87,39 @@ jobs: shell: bash run: ./.github/scripts/run_smartnet.sh & + - name: Debug + shell: bash + run: | + sleep 2 + docker network inspect node-network + # wait some while docker pulls the image and starts the node - name: Wait for finalization shell: bash run: | - docker network inspect node-networkx .github/scripts/check_finalization.sh smartnode 9933 node-network 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 }} + # - 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 }} From 6a39be20d9d1d2d76f890c93a93a7f9a686cb27a Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 12:53:18 +0200 Subject: [PATCH 09/33] run it --- .github/workflows/e2e-tests-contracts.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 41adbd4d12..dc5683a6e0 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -85,7 +85,8 @@ jobs: - name: Run one-node smartnet shell: bash - run: ./.github/scripts/run_smartnet.sh & + run: | + .github/scripts/run_smartnet.sh & - name: Debug shell: bash From 86b52a4d652b947696ce5ce58a3dae3eba40f393 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 12:54:09 +0200 Subject: [PATCH 10/33] need code --- .github/workflows/e2e-tests-contracts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index dc5683a6e0..b94375064e 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -40,8 +40,8 @@ jobs: # shell: bash # run: wasm-opt --version - # - name: Checkout Source code - # uses: actions/checkout@v3 + - name: Checkout Source code + uses: actions/checkout@v3 # - name: Install Rust Toolchain # uses: actions-rs/toolchain@v1 From 2bcced3fe47e49f2bee3966dcc59af0f85652a0f Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:06:06 +0200 Subject: [PATCH 11/33] just use host --- .github/scripts/run_smartnet.sh | 2 +- .github/workflows/e2e-tests-contracts.yml | 2 +- docker/smartnet-compose.yml | 25 ++++++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index 25f81fc103..187ff0e912 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -16,7 +16,7 @@ docker run --rm -v $(pwd)/docker/data:/data --entrypoint "/bin/sh" -e RUST_LOG=d # Get bootnode peer id 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 network create node-network || true docker-compose -f docker/smartnet-compose.yml up --remove-orphans exit $? diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index b94375064e..fc6acd1eb6 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -98,7 +98,7 @@ jobs: - name: Wait for finalization shell: bash run: | - .github/scripts/check_finalization.sh smartnode 9933 node-network + .github/scripts/check_finalization.sh timeout-minutes: 1 # - name: Run e2e tests diff --git a/docker/smartnet-compose.yml b/docker/smartnet-compose.yml index 2bd1f0394d..8d930d5838 100644 --- a/docker/smartnet-compose.yml +++ b/docker/smartnet-compose.yml @@ -22,16 +22,17 @@ services: - PUBLIC_ADDR=/ip4/127.0.0.1/tcp/30333 volumes: - ./data/:/data/ - expose: - - 30333 - - 9933 - - 9943 - ports: - - 0.0.0.0:30333:30333 - - 0.0.0.0:9933:9933 - - 0.0.0.0:9943:9943 + network_mode: "host" + # expose: + # - 30333 + # - 9933 + # - 9943 + # ports: + # - 0.0.0.0:30333:30333 + # - 0.0.0.0:9933:9933 + # - 0.0.0.0:9943:9943 -networks: - default: - external: - name: node-network +# networks: +# default: +# external: +# name: node-network From 55aaaef7eb4432861f940f0b560e6bef5ef931f3 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:07:23 +0200 Subject: [PATCH 12/33] mhm --- .github/workflows/e2e-tests-contracts.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index fc6acd1eb6..6dbff01448 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -88,11 +88,11 @@ jobs: run: | .github/scripts/run_smartnet.sh & - - name: Debug - shell: bash - run: | - sleep 2 - docker network inspect node-network + # - name: Debug + # shell: bash + # run: | + # sleep 2 + # docker network inspect node-network # wait some while docker pulls the image and starts the node - name: Wait for finalization From c4f86a055073dbbbe899576bc0fa42c6bc47ed76 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:11:27 +0200 Subject: [PATCH 13/33] co tu sie --- .github/scripts/run_smartnet.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index 187ff0e912..119172b2a3 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -17,6 +17,7 @@ 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 -d +docker logs smartnode --follow exit $? From b16e4fe90b5e42737c5885fb5d615a3881b5393d Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:42:34 +0200 Subject: [PATCH 14/33] debug --- .github/workflows/e2e-tests-contracts.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 6dbff01448..ea0ff6adb8 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -88,11 +88,11 @@ jobs: run: | .github/scripts/run_smartnet.sh & - # - name: Debug - # shell: bash - # run: | - # sleep 2 - # docker network inspect node-network + - name: Debug + shell: bash + run: | + sleep 2 + docker ps #network inspect node-network # wait some while docker pulls the image and starts the node - name: Wait for finalization From 24cd7ed7ce8acbb7a8cfe729811a2aa04206a3bb Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:44:10 +0200 Subject: [PATCH 15/33] get a shell --- .github/workflows/e2e-tests-contracts.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index ea0ff6adb8..2aaf3ccfa2 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -94,12 +94,15 @@ jobs: sleep 2 docker ps #network inspect node-network + - name: Setup upterm session + uses: lhotari/action-upterm@v1 + # 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 + timeout-minutes: 10 # - name: Run e2e tests # shell: bash From 2607a3de0ab5d054690f0b3eb63c0e37d67817d1 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:50:12 +0200 Subject: [PATCH 16/33] add missing flag --- .github/scripts/run_smartnet.sh | 5 ++--- docker/smartnet-compose.yml | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index 119172b2a3..1082706192 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -16,8 +16,7 @@ docker run --rm -v $(pwd)/docker/data:/data --entrypoint "/bin/sh" -e RUST_LOG=d # Get bootnode peer id 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 -d -docker logs smartnode --follow +docker network create node-network || true +docker-compose -f docker/smartnet-compose.yml up --remove-orphans exit $? diff --git a/docker/smartnet-compose.yml b/docker/smartnet-compose.yml index 8d930d5838..dfb0edca2e 100644 --- a/docker/smartnet-compose.yml +++ b/docker/smartnet-compose.yml @@ -20,19 +20,20 @@ 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 + - PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30333 volumes: - ./data/:/data/ network_mode: "host" - # expose: - # - 30333 - # - 9933 - # - 9943 - # ports: - # - 0.0.0.0:30333:30333 - # - 0.0.0.0:9933:9933 - # - 0.0.0.0:9943:9943 + expose: + - 30333 + - 9933 + - 9943 + ports: + - 0.0.0.0:30333:30333 + - 0.0.0.0:9933:9933 + - 0.0.0.0:9943:9943 -# networks: -# default: -# external: -# name: node-network +networks: + default: + external: + name: node-network From fe78a4f77d4ca3af7ea5f5495703f575fd997b78 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:51:15 +0200 Subject: [PATCH 17/33] aaaaaa --- .github/workflows/e2e-tests-contracts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 2aaf3ccfa2..0b002ffba8 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -94,8 +94,8 @@ jobs: sleep 2 docker ps #network inspect node-network - - name: Setup upterm session - uses: lhotari/action-upterm@v1 + # - name: Setup upterm session + # uses: lhotari/action-upterm@v1 # wait some while docker pulls the image and starts the node - name: Wait for finalization From b827a299ac5febf2c8f46e4de81bfef7f153316e Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:54:42 +0200 Subject: [PATCH 18/33] get shell --- .github/workflows/e2e-tests-contracts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 0b002ffba8..2aaf3ccfa2 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -94,8 +94,8 @@ jobs: sleep 2 docker ps #network inspect node-network - # - name: Setup upterm session - # uses: lhotari/action-upterm@v1 + - name: Setup upterm session + uses: lhotari/action-upterm@v1 # wait some while docker pulls the image and starts the node - name: Wait for finalization From 44a72db7ca906568c3fdcea9552fc66e0bc67360 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:56:49 +0200 Subject: [PATCH 19/33] show me the logs --- .github/scripts/run_smartnet.sh | 2 +- .github/workflows/e2e-tests-contracts.yml | 10 ++++++++-- contracts/scripts/deploy.sh | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index 1082706192..c91d459f45 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -17,6 +17,6 @@ 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 -d exit $? diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 2aaf3ccfa2..7c6cd6cbf8 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -86,13 +86,19 @@ jobs: - name: Run one-node smartnet shell: bash run: | - .github/scripts/run_smartnet.sh & + .github/scripts/run_smartnet.sh + + - name: Display logs + shell: bash + run: | + docker logs smartnode --follow & - name: Debug shell: bash run: | sleep 2 - docker ps #network inspect node-network + docker ps + network inspect node-network - name: Setup upterm session uses: lhotari/action-upterm@v1 diff --git a/contracts/scripts/deploy.sh b/contracts/scripts/deploy.sh index 8fdc148c02..7f6e25e5b1 100755 --- a/contracts/scripts/deploy.sh +++ b/contracts/scripts/deploy.sh @@ -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 From 3c4a3c74575e439785536e4e2635749811c4801d Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:57:09 +0200 Subject: [PATCH 20/33] docke rnet --- docker/smartnet-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/smartnet-compose.yml b/docker/smartnet-compose.yml index dfb0edca2e..7f96f48b1c 100644 --- a/docker/smartnet-compose.yml +++ b/docker/smartnet-compose.yml @@ -23,7 +23,6 @@ services: - PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30333 volumes: - ./data/:/data/ - network_mode: "host" expose: - 30333 - 9933 From 52d6a89270608ed3a65eb5dfadfc1b02301e4e0a Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 13:58:40 +0200 Subject: [PATCH 21/33] fixit --- .github/workflows/e2e-tests-contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 7c6cd6cbf8..9a043c6645 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -98,7 +98,7 @@ jobs: run: | sleep 2 docker ps - network inspect node-network + docker network inspect node-network - name: Setup upterm session uses: lhotari/action-upterm@v1 From ed450be211357b0771b3e99102abdc6a364e1896 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 14:00:32 +0200 Subject: [PATCH 22/33] off you go --- .github/workflows/e2e-tests-contracts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 9a043c6645..668174b225 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -100,8 +100,8 @@ jobs: docker ps docker network inspect node-network - - name: Setup upterm session - uses: lhotari/action-upterm@v1 + # - name: Setup upterm session + # uses: lhotari/action-upterm@v1 # wait some while docker pulls the image and starts the node - name: Wait for finalization From 0d767f6c955cb7f1632331cfaaec5e224889435d Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 14:03:21 +0200 Subject: [PATCH 23/33] yesh --- .github/workflows/e2e-tests-contracts.yml | 118 +++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 668174b225..a1280741ad 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -27,44 +27,44 @@ jobs: 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: 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 Rust Toolchain + uses: actions-rs/toolchain@v1 - # - name: Install WASM target - # run: rustup target add wasm32-unknown-unknown + - name: Install WASM target + run: rustup target add wasm32-unknown-unknown - # - name: Install rust-src - # run: rustup component add rust-src + - 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: 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: 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 @@ -93,12 +93,12 @@ jobs: run: | docker logs smartnode --follow & - - name: Debug - shell: bash - run: | - sleep 2 - docker ps - docker network inspect node-network + # - name: Debug + # shell: bash + # run: | + # sleep 2 + # docker ps + # docker network inspect node-network # - name: Setup upterm session # uses: lhotari/action-upterm@v1 @@ -110,26 +110,26 @@ jobs: .github/scripts/check_finalization.sh timeout-minutes: 10 - # - 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 }} + - 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 }} From e3637697cea07a8334180fb6ee8b12af3654ff4e Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 14:49:05 +0200 Subject: [PATCH 24/33] test workflow dispatch --- .github/scripts/run_smartnet.sh | 3 +-- .github/workflows/deploy-the-button.yaml | 7 ++++--- .github/workflows/e2e-tests-contracts.yml | 16 +++------------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index c91d459f45..d2b1b23a71 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -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 -d - +docker-compose -f docker/smartnet-compose.yml up --remove-orphans exit $? diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index a533047eeb..3635b9d2c6 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -6,10 +6,11 @@ on: workflows: [e2e-tests-contracts] types: - completed - branches: - - benjamin +# TODO : temporary, uncomment before merging + # branches: + # - benjamin -# allow only once run instance of this workflow ever +# allow only once run instance of this workflow EVER concurrency: group: ${{ github.workflow }} cancel-in-progress: false diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index a1280741ad..48bde6d956 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -86,29 +86,19 @@ jobs: - name: Run one-node smartnet shell: bash run: | - .github/scripts/run_smartnet.sh + .github/scripts/run_smartnet.sh & - - name: Display logs + - name: Display node logs shell: bash run: | docker logs smartnode --follow & - # - name: Debug - # shell: bash - # run: | - # sleep 2 - # docker ps - # docker network inspect node-network - - # - name: Setup upterm session - # uses: lhotari/action-upterm@v1 - # 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: 10 + timeout-minutes: 1 - name: Run e2e tests shell: bash From 47c790a985b8d65853249a4ff557b8b9d55c9749 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 15:27:34 +0200 Subject: [PATCH 25/33] deployment triggered by tests --- .github/workflows/deploy-the-button.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index 3635b9d2c6..a13b91c655 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -1,14 +1,8 @@ name: Deploy The Button game -# triggered by the e2e-tests-contracts +# should be triggered by the e2e-tests-contracts on: - workflow_run: - workflows: [e2e-tests-contracts] - types: - - completed -# TODO : temporary, uncomment before merging - # branches: - # - benjamin + workflow_dispatch: # allow only once run instance of this workflow EVER concurrency: From b83f7afe25f3f4fd5e2adfc2925f90fde2ca7b7e Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 26 Oct 2022 15:29:58 +0200 Subject: [PATCH 26/33] cleanup --- .github/workflows/deploy-the-button.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button.yaml index a13b91c655..820c7048a2 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button.yaml @@ -1,6 +1,6 @@ name: Deploy The Button game -# should be triggered by the e2e-tests-contracts +# triggered by the e2e-tests-contracts on: workflow_dispatch: From 698428f7b8ec5b463b51788aa4935436997111de Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 27 Oct 2022 09:50:46 +0200 Subject: [PATCH 27/33] TODOs --- ...deploy-the-button.yaml => deploy-the-button-contracts.yml} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename .github/workflows/{deploy-the-button.yaml => deploy-the-button-contracts.yml} (98%) diff --git a/.github/workflows/deploy-the-button.yaml b/.github/workflows/deploy-the-button-contracts.yml similarity index 98% rename from .github/workflows/deploy-the-button.yaml rename to .github/workflows/deploy-the-button-contracts.yml index 820c7048a2..ab10f4fed3 100644 --- a/.github/workflows/deploy-the-button.yaml +++ b/.github/workflows/deploy-the-button-contracts.yml @@ -1,6 +1,6 @@ name: Deploy The Button game -# triggered by the e2e-tests-contracts +# TODO triggered by the e2e-tests-contracts workflow completed on branch benjamin on: workflow_dispatch: @@ -174,6 +174,8 @@ jobs: -H 'Authorization: Bearer ${{ secrets.CI_GH_TOKEN }}' \ -d '{ "ref":"main", "inputs": { "buildImage": "false", "deployImage": "true" }}' + # TODO: trigger indexer deployment + - name: Create empty target directory so that restore-cache does not fail run: | mkdir -p target From 5aff6c13fb26ef78bc85ee8aa4e0b9d60140fa35 Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 27 Oct 2022 10:02:09 +0200 Subject: [PATCH 28/33] try the trigger --- .github/workflows/deploy-the-button-contracts.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-the-button-contracts.yml b/.github/workflows/deploy-the-button-contracts.yml index ab10f4fed3..66a4ee2f8c 100644 --- a/.github/workflows/deploy-the-button-contracts.yml +++ b/.github/workflows/deploy-the-button-contracts.yml @@ -2,7 +2,11 @@ name: Deploy The Button game # TODO triggered by the e2e-tests-contracts workflow completed on branch benjamin on: - workflow_dispatch: + workflow_run: + workflows: + - e2e-tests-contracts + types: + - completed # allow only once run instance of this workflow EVER concurrency: From 8d41a202e5e9bf475769ed7889e1866d22d42144 Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 27 Oct 2022 10:06:55 +0200 Subject: [PATCH 29/33] add dispatch trigger --- .github/workflows/deploy-the-button-contracts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-the-button-contracts.yml b/.github/workflows/deploy-the-button-contracts.yml index 66a4ee2f8c..eac1b72df9 100644 --- a/.github/workflows/deploy-the-button-contracts.yml +++ b/.github/workflows/deploy-the-button-contracts.yml @@ -2,6 +2,7 @@ name: Deploy The Button game # TODO triggered by the e2e-tests-contracts workflow completed on branch benjamin on: + workflow_dispatch: workflow_run: workflows: - e2e-tests-contracts From 7fbae16ebcefa4f5b8a24036466bd7a2ca554511 Mon Sep 17 00:00:00 2001 From: Mikolaj Gasior Date: Thu, 27 Oct 2022 12:22:37 +0200 Subject: [PATCH 30/33] Blend contracts e2e tests and deployment workflows into one workflow --- ...ml => contracts-e2e-tests-and-deploy.yaml} | 133 ++++++++++++-- .github/workflows/e2e-tests-contracts.yml | 172 +++++++++++++++++- 2 files changed, 285 insertions(+), 20 deletions(-) rename .github/workflows/{deploy-the-button-contracts.yml => contracts-e2e-tests-and-deploy.yaml} (67%) diff --git a/.github/workflows/deploy-the-button-contracts.yml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml similarity index 67% rename from .github/workflows/deploy-the-button-contracts.yml rename to .github/workflows/contracts-e2e-tests-and-deploy.yaml index eac1b72df9..4e552dc595 100644 --- a/.github/workflows/deploy-the-button-contracts.yml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -1,18 +1,20 @@ -name: Deploy The Button game +name: e2e-tests-contracts -# TODO triggered by the e2e-tests-contracts workflow completed on branch benjamin on: - workflow_dispatch: - workflow_run: - workflows: - - e2e-tests-contracts - types: - - completed - -# allow only once run instance of this workflow EVER + pull_request: + paths: + - 'contracts/**' + - '.github/**' + push: + paths: + - 'contracts/**' + - '.github/**' + branches: + - benjamin + concurrency: group: ${{ github.workflow }} - cancel-in-progress: false + cancel-in-progress: true env: CHECKOUT_BRANCH: benjamin @@ -23,7 +25,111 @@ env: S3BUCKET_PATH: contracts/fe-benjamin-button jobs: + 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: + needs: [run-tests] runs-on: ubuntu-20.04 steps: - name: Checkout repo @@ -180,8 +286,3 @@ jobs: -d '{ "ref":"main", "inputs": { "buildImage": "false", "deployImage": "true" }}' # TODO: trigger indexer deployment - - - name: Create empty target directory so that restore-cache does not fail - run: | - mkdir -p target - touch target/emptyfile diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml index 48bde6d956..a6e2092e8f 100644 --- a/.github/workflows/e2e-tests-contracts.yml +++ b/.github/workflows/e2e-tests-contracts.yml @@ -1,4 +1,4 @@ -name: e2e-tests-contracts +name: contracts-e2e-tests-and-deploy on: pull_request: @@ -13,20 +13,24 @@ on: - benjamin concurrency: - group: ${{ github.ref }}-${{ github.workflow }} + group: ${{ github.workflow }} cancel-in-progress: true env: CHECKOUT_BRANCH: benjamin + CACHE_KEY: fe-benjamin-button + CONTRACTS_ENVFILE: fe-benjamin + CARGOCONTRACT_REV: 2b1758756de59bd81e7bed5f8429d364f281cb9a + NODE_VERSION: 16 + S3BUCKET_PATH: contracts/fe-benjamin-button jobs: run-tests: name: Run smart contracts test suite - runs-on: ubuntu-latest + 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 @@ -123,3 +127,163 @@ jobs: 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 + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + with: + ref: ${{ env.CHECKOUT_BRANCH }} + + - name: Check if environment is reachable + shell: bash + run: | + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && HOSTPORT=${NODE/wss:\/\//} && nc -zvw5 ${HOSTPORT/:*/} ${HOSTPORT/*:/} + + - name: Get branch name and commit SHA + id: get_branch + uses: ./.github/actions/get-branch + + # Use of 'actions-rs/toolchain@v1' has been removed as it was causing some unknown problems + # Also, there is a ticket to replace it with custom solution anyway + + - name: Setup rust toolchain + run: | + . "$HOME/.cargo/env" + rustup target add wasm32-unknown-unknown + rustup toolchain install nightly-2022-08-12-x86_64-unknown-linux-gnu + rustup component add rust-src --toolchain nightly-2022-08-12-x86_64-unknown-linux-gnu + rustup default nightly-2022-08-12-x86_64-unknown-linux-gnu + + - name: Install jq + shell: bash + run: | + sudo apt-get install -y jq + + - name: Install binaryen + shell: bash + run: | + wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz -O /tmp/binaryen-version_110-x86_64-linux.tar.gz + tar -zxvf /tmp/binaryen-version_110-x86_64-linux.tar.gz -C /tmp + sudo chmod +x /tmp/binaryen-version_110/bin/* + sudo cp -rf /tmp/binaryen-version_110/* /usr/ + + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Restore cache + uses: ./.github/actions/restore-cache + with: + target-key: ${{ env.CACHE_KEY }} + cargo-key: ${{ env.CACHE_KEY }} + cache-version: v1 + + - name: Install cargo additional libs + run: | + . "$HOME/.cargo/env" + cargo install dylint-link cargo-dylint + + - name: Install cargo-contract with bug fixes around URL parsing + run: | + . "$HOME/.cargo/env" + cargo install --git https://github.com/paritytech/cargo-contract.git --rev ${{ env.CARGOCONTRACT_REV }} --force + + # TODO: Cache some files from contracts directory to fasten up builds, is that possible? + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + env: + AWS_REGION: us-east-1 + with: + aws-access-key-id: ${{ secrets.AWS_DEVNET_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVNET_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Get contracts' target directories cache from S3 bucket + 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 + shell: bash + run: | + aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json contracts/addresses.json + for i in ticket_token marketplace button game_token access_control; do \ + mkdir -p contracts/"$i"/target/ink + aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json contracts/"$i"/target/ink/metadata.json; \ + done + + - name: Run clean.sh script + continue-on-error: true + shell: bash + run: | + . "$HOME/.cargo/env" + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && ./contracts/scripts/clean.sh + + - name: Run deploy.sh script + shell: bash + run: | + . "$HOME/.cargo/env" + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && ./contracts/scripts/deploy.sh + + - name: Copy metadata.json and addresses.json files onto S3 bucket + shell: bash + run: | + aws s3 cp contracts/addresses.json s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json + for i in ticket_token marketplace button game_token access_control; do \ + aws s3 cp contracts/"$i"/target/ink/metadata.json s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json; \ + done + echo -n "${{ steps.get_branch.outputs.sha_short }}" > commit_sha.txt + aws s3 cp commit_sha.txt s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/commit_sha.txt + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && echo -n "$NODE" > env_NODE.txt + aws s3 cp env_NODE.txt s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/env_NODE.txt + + - name: Rename metadata and addresses JSON files to artifact upload + shell: bash + run: | + cp contracts/addresses.json addresses.${{ env.CONTRACTS_ENVFILE }}.json + for i in ticket_token marketplace button game_token access_control; do \ + cp contracts/"$i"/target/ink/metadata.json metadata_"$i".${{ env.CONTRACTS_ENVFILE }}.json; \ + done + + - name: Upload artifact with contract addresses + uses: actions/upload-artifact@v3 + with: + name: contracts-addresses + path: addresses.${{ env.CONTRACTS_ENVFILE }}.json + if-no-files-found: error + retention-days: 90 + + - name: Upload artifact with contract metadata + uses: actions/upload-artifact@v3 + with: + name: contracts-metadata + path: metadata_*.${{ env.CONTRACTS_ENVFILE }}.json + if-no-files-found: error + retention-days: 90 + + - name: Cache contracts' target directories in S3 bucket + shell: bash + run: | + tar -czf targets.tgz contracts/ticket_token/target \ + contracts/marketplace/target \ + contracts/button/target \ + contracts/game_token/target \ + contracts/access_control/target + aws s3 cp targets.tgz s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/targets.tgz + + - 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" }}' + + # TODO: trigger indexer deployment From b1a7d6ff28054428db6a29936e49b172e6ba2fd9 Mon Sep 17 00:00:00 2001 From: Mikolaj Gasior Date: Thu, 27 Oct 2022 12:25:46 +0200 Subject: [PATCH 31/33] Oops! Remove duplicated workflow --- .../contracts-e2e-tests-and-deploy.yaml | 3 +- .github/workflows/e2e-tests-contracts.yml | 289 ------------------ 2 files changed, 2 insertions(+), 290 deletions(-) delete mode 100644 .github/workflows/e2e-tests-contracts.yml diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index 4e552dc595..a6e2092e8f 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -1,4 +1,4 @@ -name: e2e-tests-contracts +name: contracts-e2e-tests-and-deploy on: pull_request: @@ -129,6 +129,7 @@ jobs: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} build_and_deploy_contracts: + name: Deploy contracts on feature environment needs: [run-tests] runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/e2e-tests-contracts.yml b/.github/workflows/e2e-tests-contracts.yml deleted file mode 100644 index a6e2092e8f..0000000000 --- a/.github/workflows/e2e-tests-contracts.yml +++ /dev/null @@ -1,289 +0,0 @@ -name: contracts-e2e-tests-and-deploy - -on: - pull_request: - paths: - - 'contracts/**' - - '.github/**' - push: - paths: - - 'contracts/**' - - '.github/**' - branches: - - benjamin - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -env: - CHECKOUT_BRANCH: benjamin - CACHE_KEY: fe-benjamin-button - CONTRACTS_ENVFILE: fe-benjamin - CARGOCONTRACT_REV: 2b1758756de59bd81e7bed5f8429d364f281cb9a - NODE_VERSION: 16 - S3BUCKET_PATH: contracts/fe-benjamin-button - -jobs: - 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 - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - with: - ref: ${{ env.CHECKOUT_BRANCH }} - - - name: Check if environment is reachable - shell: bash - run: | - source contracts/env/${{ env.CONTRACTS_ENVFILE }} && HOSTPORT=${NODE/wss:\/\//} && nc -zvw5 ${HOSTPORT/:*/} ${HOSTPORT/*:/} - - - name: Get branch name and commit SHA - id: get_branch - uses: ./.github/actions/get-branch - - # Use of 'actions-rs/toolchain@v1' has been removed as it was causing some unknown problems - # Also, there is a ticket to replace it with custom solution anyway - - - name: Setup rust toolchain - run: | - . "$HOME/.cargo/env" - rustup target add wasm32-unknown-unknown - rustup toolchain install nightly-2022-08-12-x86_64-unknown-linux-gnu - rustup component add rust-src --toolchain nightly-2022-08-12-x86_64-unknown-linux-gnu - rustup default nightly-2022-08-12-x86_64-unknown-linux-gnu - - - name: Install jq - shell: bash - run: | - sudo apt-get install -y jq - - - name: Install binaryen - shell: bash - run: | - wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz -O /tmp/binaryen-version_110-x86_64-linux.tar.gz - tar -zxvf /tmp/binaryen-version_110-x86_64-linux.tar.gz -C /tmp - sudo chmod +x /tmp/binaryen-version_110/bin/* - sudo cp -rf /tmp/binaryen-version_110/* /usr/ - - - name: Install node - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Restore cache - uses: ./.github/actions/restore-cache - with: - target-key: ${{ env.CACHE_KEY }} - cargo-key: ${{ env.CACHE_KEY }} - cache-version: v1 - - - name: Install cargo additional libs - run: | - . "$HOME/.cargo/env" - cargo install dylint-link cargo-dylint - - - name: Install cargo-contract with bug fixes around URL parsing - run: | - . "$HOME/.cargo/env" - cargo install --git https://github.com/paritytech/cargo-contract.git --rev ${{ env.CARGOCONTRACT_REV }} --force - - # TODO: Cache some files from contracts directory to fasten up builds, is that possible? - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - env: - AWS_REGION: us-east-1 - with: - aws-access-key-id: ${{ secrets.AWS_DEVNET_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEVNET_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: Get contracts' target directories cache from S3 bucket - 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 - shell: bash - run: | - aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json contracts/addresses.json - for i in ticket_token marketplace button game_token access_control; do \ - mkdir -p contracts/"$i"/target/ink - aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json contracts/"$i"/target/ink/metadata.json; \ - done - - - name: Run clean.sh script - continue-on-error: true - shell: bash - run: | - . "$HOME/.cargo/env" - source contracts/env/${{ env.CONTRACTS_ENVFILE }} && ./contracts/scripts/clean.sh - - - name: Run deploy.sh script - shell: bash - run: | - . "$HOME/.cargo/env" - source contracts/env/${{ env.CONTRACTS_ENVFILE }} && ./contracts/scripts/deploy.sh - - - name: Copy metadata.json and addresses.json files onto S3 bucket - shell: bash - run: | - aws s3 cp contracts/addresses.json s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json - for i in ticket_token marketplace button game_token access_control; do \ - aws s3 cp contracts/"$i"/target/ink/metadata.json s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json; \ - done - echo -n "${{ steps.get_branch.outputs.sha_short }}" > commit_sha.txt - aws s3 cp commit_sha.txt s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/commit_sha.txt - source contracts/env/${{ env.CONTRACTS_ENVFILE }} && echo -n "$NODE" > env_NODE.txt - aws s3 cp env_NODE.txt s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/env_NODE.txt - - - name: Rename metadata and addresses JSON files to artifact upload - shell: bash - run: | - cp contracts/addresses.json addresses.${{ env.CONTRACTS_ENVFILE }}.json - for i in ticket_token marketplace button game_token access_control; do \ - cp contracts/"$i"/target/ink/metadata.json metadata_"$i".${{ env.CONTRACTS_ENVFILE }}.json; \ - done - - - name: Upload artifact with contract addresses - uses: actions/upload-artifact@v3 - with: - name: contracts-addresses - path: addresses.${{ env.CONTRACTS_ENVFILE }}.json - if-no-files-found: error - retention-days: 90 - - - name: Upload artifact with contract metadata - uses: actions/upload-artifact@v3 - with: - name: contracts-metadata - path: metadata_*.${{ env.CONTRACTS_ENVFILE }}.json - if-no-files-found: error - retention-days: 90 - - - name: Cache contracts' target directories in S3 bucket - shell: bash - run: | - tar -czf targets.tgz contracts/ticket_token/target \ - contracts/marketplace/target \ - contracts/button/target \ - contracts/game_token/target \ - contracts/access_control/target - aws s3 cp targets.tgz s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/targets.tgz - - - 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" }}' - - # TODO: trigger indexer deployment From 6277e759a0124beaedf1d943d6812927242e14fd Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 27 Oct 2022 15:58:02 +0200 Subject: [PATCH 32/33] addressing comments --- docker/smartnet-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/smartnet-compose.yml b/docker/smartnet-compose.yml index 7f96f48b1c..4733ebb9c2 100644 --- a/docker/smartnet-compose.yml +++ b/docker/smartnet-compose.yml @@ -20,7 +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 - - PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30333 + - VALIDATOR_PORT=30343 + - PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30343 volumes: - ./data/:/data/ expose: From 6a282a6ba7e4342266cbb697183a743e7bbe1270 Mon Sep 17 00:00:00 2001 From: Mikolaj Gasior Date: Thu, 27 Oct 2022 22:03:44 +0200 Subject: [PATCH 33/33] Add triggering indexer deployment workflow --- .github/workflows/contracts-e2e-tests-and-deploy.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index a6e2092e8f..8c14550c1f 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -279,6 +279,13 @@ 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' \ @@ -286,4 +293,3 @@ jobs: -H 'Authorization: Bearer ${{ secrets.CI_GH_TOKEN }}' \ -d '{ "ref":"main", "inputs": { "buildImage": "false", "deployImage": "true" }}' - # TODO: trigger indexer deployment