Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Merge branch 'benjamin' into obrok/button-e2e
  • Loading branch information
obrok committed Oct 28, 2022
commit c04aa417b78c5b5bcf70142388fccdac647c07bd
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 $?
6 changes: 3 additions & 3 deletions .github/workflows/build-node-and-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ jobs:
cache-version: v1

- name: Build binary and runtime
run: cargo build --release -p aleph-node
run: cargo build --profile production -p aleph-node

- name: Upload release binary
uses: actions/upload-artifact@v2
with:
name: ${{ inputs.artifact-prefix }}aleph-release-node
path: target/release/aleph-node
path: target/production/aleph-node
if-no-files-found: error
retention-days: 7

- name: Upload release runtime
uses: actions/upload-artifact@v2
with:
name: ${{ inputs.artifact-prefix }}aleph-release-runtime
path: target/release/wbuild/aleph-runtime/aleph_runtime.compact.wasm
path: target/production/wbuild/aleph-runtime/aleph_runtime.compact.wasm
if-no-files-found: error
retention-days: 7

Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,142 @@
name: Deploy The Button game
name: contracts-e2e-tests-and-deploy

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

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/[email protected]
with:
ref: ${{ env.CHECKOUT_REF }}
ref: ${{ env.CHECKOUT_BRANCH }}

- name: Check if environment is reachable
shell: bash
Expand Down Expand Up @@ -101,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 @@ -143,6 +245,30 @@ jobs:
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: |
Expand All @@ -153,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 The Button deployment workflow
- name: Trigger Indexer deployment workflow
run: |
curl -X POST 'https://api.github.com/repos/Cardinal-Cryptography/the-button/actions/workflows/main.yaml/dispatches' \
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":"main", "inputs": { "buildImage": "false", "deployImage": "true", "buildFEBenjaminImage": "true", "deployFEBenjaminImage": "true" }}'
-d '{ "ref":"master" }'

- name: Add label to mark that contracts have been deployed
uses: actions-ecosystem/[email protected]
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/[email protected]
with:
labels: ${{ env.LABEL_DEPLOY_CONTRACTS }}
github_token: ${{ secrets.CI_GH_TOKEN }}

- name: Create empty target directory so that restore-cache does not fail
- name: Trigger The Button deployment workflow
run: |
mkdir -p target
touch target/emptyfile
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" }}'

Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.