Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup docker builds for contracts and add WASM check to CI #509

Merged
merged 6 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
toolchain: [stable-2020-10-08]
toolchain: [stable]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, why did we even have the other version. didn't notice 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk it was the version used across the board before, I assume for consistency, but is counter-intuitive for a lib like the SDK

example: [cross-contract-high-level, cross-contract-low-level, fungible-token]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_examples_small.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
toolchain: [stable-2020-10-08]
toolchain: [stable]
steps:
- uses: actions/checkout@v2
- name: "${{ matrix.toolchain }} with rustfmt, clippy, and wasm32"
Expand Down
8 changes: 5 additions & 3 deletions ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ else
# Only testing it for one configuration to avoid running the same tests twice
echo "Build wasm32 for all examples"

./examples/build_all.sh
./examples/build_all_docker.sh --check
echo "Testing all examples"
./examples/test_all.sh
echo "Checking size of all example contracts"
./examples/size_all.sh
# TODO re-enable when parsing unknown sections is fixed in twiggy
# https://github.com/rustwasm/twiggy/pull/576
# echo "Checking size of all example contracts"
# ./examples/size_all.sh
fi
26 changes: 26 additions & 0 deletions examples/build_all_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -ex

CHECK=0

pushd $(dirname ${BASH_SOURCE[0]})

# Loop through arguments and process them
for arg in "$@"
do
case $arg in
-c|--check)
CHECK=1
shift
;;
esac
done

for d in "status-message" $(ls -d */ | grep -v -e "status-message\/$"); do
(./build_docker.sh ${d%%/})
done

if [ $CHECK == 1 ] && [ ! -z "$(git diff --exit-code)" ] ; then
echo "Repository is dirty, please make sure you have committed all contract wasm files"
exit 1
fi
26 changes: 26 additions & 0 deletions examples/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Exit script as soon as a command fails.
set -ex

NAME="$1"

# Switch to current directory (./examples) then out to root for specific examples
pushd $(dirname ${BASH_SOURCE[0]})
cd ../

if docker ps -a --format '{{.Names}}' | grep -Eq "^build_${NAME}\$"; then
echo "Container exists"
else
docker create \
--mount type=bind,source=$(pwd),target=/host \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--name=build_$NAME \
-w /host/examples/$NAME \
-e RUSTFLAGS='-C link-arg=-s' \
-it nearprotocol/contract-builder \
/bin/bash
fi

docker start build_$NAME
docker exec build_$NAME /bin/bash -c "./build.sh"
Binary file not shown.
Binary file not shown.
Binary file modified examples/fungible-token/res/defi.wasm
Binary file not shown.
Binary file modified examples/fungible-token/res/fungible_token.wasm
Binary file not shown.
Binary file modified examples/gas-fee-tester/res/gas_fee_tester.wasm
Binary file not shown.
Binary file not shown.
Binary file modified examples/mission-control/res/mission_control.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/approval_receiver.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/non_fungible_token.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/token_receiver.wasm
Binary file not shown.
Binary file not shown.
Binary file modified examples/status-message/res/status_message.wasm
Binary file not shown.
Binary file modified examples/test-contract/res/test_contract.wasm
Binary file not shown.