From 5ba3c52dcf0a83ec4d30a1303e239dc83d1bc3b0 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 16:03:35 +0000 Subject: [PATCH 1/7] remove piping wasm-strip to true --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 74415277..c9141869 100644 --- a/Makefile +++ b/Makefile @@ -9,13 +9,13 @@ build-contract: cd client/get_approved_session && cargo build --release --target wasm32-unknown-unknown cd client/minting_contract && cargo build --release --target wasm32-unknown-unknown cd client/transfer_session && cargo build --release --target wasm32-unknown-unknown - wasm-strip contract/target/wasm32-unknown-unknown/release/contract.wasm 2>/dev/null | true - wasm-strip client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm 2>/dev/null | true - wasm-strip client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm 2>/dev/null | true - wasm-strip client/owner_of_session/target/wasm32-unknown-unknown/release/owner_of_call.wasm 2>/dev/null | true - wasm-strip client/get_approved_session/target/wasm32-unknown-unknown/release/get_approved_call.wasm 2>/dev/null | true - wasm-strip client/minting_contract/target/wasm32-unknown-unknown/release/minting_contract.wasm 2>/dev/null | true - wasm-strip client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm 2>/dev/null | true + wasm-strip contract/target/wasm32-unknown-unknown/release/contract.wasm + wasm-strip client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm + wasm-strip client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm + wasm-strip client/owner_of_session/target/wasm32-unknown-unknown/release/owner_of_call.wasm + wasm-strip client/get_approved_session/target/wasm32-unknown-unknown/release/get_approved_call.wasm + wasm-strip client/minting_contract/target/wasm32-unknown-unknown/release/minting_contract.wasm + wasm-strip client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm test: build-contract mkdir -p tests/wasm @@ -43,4 +43,4 @@ lint: clippy clean: cd contract && cargo clean cd tests && cargo clean - rm -rf tests/wasm \ No newline at end of file + rm -rf tests/wasm From 37d52970fccbb759db7e8c718a2a28e3031a4b6e Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 16:04:46 +0000 Subject: [PATCH 2/7] cleanup ci to be more verbose; install wabt for wasm-strip --- .github/workflows/ci-cep-78-enhanced-nft.yml | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-cep-78-enhanced-nft.yml b/.github/workflows/ci-cep-78-enhanced-nft.yml index f93980ec..bb55c010 100644 --- a/.github/workflows/ci-cep-78-enhanced-nft.yml +++ b/.github/workflows/ci-cep-78-enhanced-nft.yml @@ -22,16 +22,19 @@ env: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2 - - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 #latest commit - with: - profile: minimal - components: rustfmt, clippy - - - run: sudo apt update && sudo apt install -y build-essential - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c #v1.4.0 - - run: make prepare - - run: make check-lint - - run: make test + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2 + - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c #v1.4.0 + + - name: Install dependencies + run: sudo apt update && sudo apt install -y build-essential wabt + + - name: Setup wasm32-unknown-unknown + run: make prepare + + - name: Run clippy and fmt + run: make check-lint + + - name: Run tests + run: make test From 14fa419c46dba9884181c83bcc56cbcadb6af455 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 16:08:58 +0000 Subject: [PATCH 3/7] cleanup nightly ci workflow; install wabt for wasm-strip; bump ubuntu to 22.04 --- .github/workflows/nightly-scheduled-test.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nightly-scheduled-test.yml b/.github/workflows/nightly-scheduled-test.yml index 3bd38700..95e2a72c 100644 --- a/.github/workflows/nightly-scheduled-test.yml +++ b/.github/workflows/nightly-scheduled-test.yml @@ -9,18 +9,19 @@ on: jobs: nightly-make-test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2 - - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 #latest commit - with: - profile: minimal - components: rustfmt, clippy - - - run: sudo apt update && sudo apt install -y build-essential - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c #v1.4.0 - - run: make prepare - - run: make test + + - name: Install dependencies + run: sudo apt update && sudo apt install -y build-essential wabt + + - name: Setup wasm32-unknown-unknown + run: make prepare + + - name: Run tests + run: make test - name: Slack Notification uses: ravsamhq/notify-slack-action@4ed28566c2bdcdaee6dca2b46b9666d01b4ed8a4 #v1.10.0 From c3d065b9a52c4e668a245b4a2c59ee077d59cb38 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 21:40:25 +0000 Subject: [PATCH 4/7] initial commit of publishing tarball --- .../workflows/publish-cep-78-contracts.yml | 32 ++++++++++++++ ci/package_wasm.sh | 44 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/publish-cep-78-contracts.yml create mode 100755 ci/package_wasm.sh diff --git a/.github/workflows/publish-cep-78-contracts.yml b/.github/workflows/publish-cep-78-contracts.yml new file mode 100644 index 00000000..4b821fd0 --- /dev/null +++ b/.github/workflows/publish-cep-78-contracts.yml @@ -0,0 +1,32 @@ +--- +name: publish-cep-78-contracts + +on: + push: + tags: + - "v*" + +jobs: + publish-contract-tarball: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2 + - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c #v1.4.0 + + - name: Install dependencies + run: sudo apt update && sudo apt install -y build-essential wabt + + - name: Setup wasm32-unknown-unknown + run: make prepare + + - name: Build wasm contracts + run: make build-contract + + - name: Create tarball + run: ./ci/package_wasm.sh + + - name: Upload tarball to release + uses: svenstaro/upload-release-action@133984371c30d34e38222a64855679a414cb7575 #v2.3.0 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: /tmp/ci_package_wasm_${{ github.ref_name }}/cep-78-wasm.tar.gz diff --git a/ci/package_wasm.sh b/ci/package_wasm.sh new file mode 100755 index 00000000..a98957e6 --- /dev/null +++ b/ci/package_wasm.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e + +BUILD_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd)" +IGNORE='minting_contract' +WASM_FILE_PATH_ARRAY=($(cat "$BUILD_ROOT_DIR/Makefile" | grep 'wasm-strip' | awk -F' ' '{print $2}')) +TAG=${GITHUB_REF_NAME:-local} +TEMP_DIR="/tmp/ci_package_wasm_$TAG" +TARBALL="cep-78-wasm.tar.gz" + +# Hygiene for local debugging. Won't apply to CI. +if [ -d "$TEMP_DIR" ]; then + rm -rf "$TEMP_DIR" +fi + +# Create temporary directory for staging tarball +mkdir -p "$TEMP_DIR" + +if [ -d "$TEMP_DIR" ]; then + # Loop over the contracts + for wasm_path in "${WASM_FILE_PATH_ARRAY[@]}"; do + # Ignore minting_contract, used only in testing + if [[ "$wasm_path" != *"$IGNORE"* ]]; then + # Copy the other wasm files if they exist + if [ -f "$wasm_path" ]; then + echo "copying $wasm_path to $TEMP_DIR" + cp "$wasm_path" "$TEMP_DIR/" + fi + fi + done + + # Move to the staging directory + pushd "$TEMP_DIR" > /dev/null + echo "" + echo "creating $TEMP_DIR/$TARBALL" + echo "" + # create the tarball + tar -czf "$TARBALL" "*.wasm" --remove-files + # Move back + popd > /dev/null +fi + +echo "success!" From a190dbbfc2120ef04a6e0428eadc5885e8392249 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 22:29:18 +0000 Subject: [PATCH 5/7] ditch qoutes --- ci/package_wasm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/package_wasm.sh b/ci/package_wasm.sh index a98957e6..a0d9e51a 100755 --- a/ci/package_wasm.sh +++ b/ci/package_wasm.sh @@ -36,7 +36,7 @@ if [ -d "$TEMP_DIR" ]; then echo "creating $TEMP_DIR/$TARBALL" echo "" # create the tarball - tar -czf "$TARBALL" "*.wasm" --remove-files + tar -czf "$TARBALL" *.wasm --remove-files # Move back popd > /dev/null fi From f312f153c9a3f863a7d88c6f7776d1bc6d5ed600 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 23:01:43 +0000 Subject: [PATCH 6/7] add clippy for pinned nightly to makefile --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index c9141869..8abc4885 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ +PINNED_TOOLCHAIN := $(shell cat rust-toolchain) + prepare: rustup target add wasm32-unknown-unknown + rustup component add clippy --toolchain ${PINNED_TOOLCHAIN} build-contract: cd contract && cargo build --release --target wasm32-unknown-unknown From c3a6dc46bf31443795aeb920e15c276ff1c68526 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 17 Aug 2022 23:07:01 +0000 Subject: [PATCH 7/7] add fmt for pinned nightly to makefile --- .github/workflows/ci-cep-78-enhanced-nft.yml | 2 +- .github/workflows/nightly-scheduled-test.yml | 2 +- .github/workflows/publish-cep-78-contracts.yml | 2 +- Makefile | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cep-78-enhanced-nft.yml b/.github/workflows/ci-cep-78-enhanced-nft.yml index bb55c010..92aaf323 100644 --- a/.github/workflows/ci-cep-78-enhanced-nft.yml +++ b/.github/workflows/ci-cep-78-enhanced-nft.yml @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: sudo apt update && sudo apt install -y build-essential wabt - - name: Setup wasm32-unknown-unknown + - name: Setup run: make prepare - name: Run clippy and fmt diff --git a/.github/workflows/nightly-scheduled-test.yml b/.github/workflows/nightly-scheduled-test.yml index 95e2a72c..6fd0aef8 100644 --- a/.github/workflows/nightly-scheduled-test.yml +++ b/.github/workflows/nightly-scheduled-test.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: sudo apt update && sudo apt install -y build-essential wabt - - name: Setup wasm32-unknown-unknown + - name: Setup run: make prepare - name: Run tests diff --git a/.github/workflows/publish-cep-78-contracts.yml b/.github/workflows/publish-cep-78-contracts.yml index 4b821fd0..3d4a972b 100644 --- a/.github/workflows/publish-cep-78-contracts.yml +++ b/.github/workflows/publish-cep-78-contracts.yml @@ -16,7 +16,7 @@ jobs: - name: Install dependencies run: sudo apt update && sudo apt install -y build-essential wabt - - name: Setup wasm32-unknown-unknown + - name: Setup run: make prepare - name: Build wasm contracts diff --git a/Makefile b/Makefile index 8abc4885..165be6b0 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ PINNED_TOOLCHAIN := $(shell cat rust-toolchain) prepare: rustup target add wasm32-unknown-unknown rustup component add clippy --toolchain ${PINNED_TOOLCHAIN} + rustup component add rustfmt --toolchain ${PINNED_TOOLCHAIN} build-contract: cd contract && cargo build --release --target wasm32-unknown-unknown