Skip to content

Commit

Permalink
Merge pull request #49 from TomVasile/zh-sre-556
Browse files Browse the repository at this point in the history
CI: Add wasm tar.gz on release
  • Loading branch information
darthsiroftardis authored Aug 18, 2022
2 parents f01d13c + e7d6863 commit 9fd5175
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 29 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/ci-cep-78-enhanced-nft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
run: make prepare

- name: Run clippy and fmt
run: make check-lint

- name: Run tests
run: make test
19 changes: 10 additions & 9 deletions .github/workflows/nightly-scheduled-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
run: make prepare

- name: Run tests
run: make test

- name: Slack Notification
uses: ravsamhq/notify-slack-action@4ed28566c2bdcdaee6dca2b46b9666d01b4ed8a4 #v1.10.0
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/publish-cep-78-contracts.yml
Original file line number Diff line number Diff line change
@@ -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
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
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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
Expand All @@ -9,13 +13,13 @@ build-contract:
cd client/get_approved_session && cargo build --release --target wasm32-unknown-unknown
cd client/transfer_session && cargo build --release --target wasm32-unknown-unknown
cd test-contracts/minting_contract && 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/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm 2>/dev/null | true
wasm-strip test-contracts/minting_contract/target/wasm32-unknown-unknown/release/minting_contract.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/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm
wasm-strip test-contracts/minting_contract/target/wasm32-unknown-unknown/release/minting_contract.wasm

test: build-contract
mkdir -p tests/wasm
Expand Down Expand Up @@ -43,4 +47,4 @@ lint: clippy
clean:
cd contract && cargo clean
cd tests && cargo clean
rm -rf tests/wasm
rm -rf tests/wasm
44 changes: 44 additions & 0 deletions ci/package_wasm.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 9fd5175

Please sign in to comment.