Skip to content

Commit

Permalink
Run CI on multiple platforms
Browse files Browse the repository at this point in the history
We use multiple different GitHub runners to cover the most common
developer targets.

- ubuntu-latest
- macos-latest-large
- macos-latest-xlarge
  • Loading branch information
Eduardo Leegwater Simões committed Dec 5, 2023
1 parent eea8f91 commit b2c32ed
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,32 @@ jobs:

test:
name: Make test
runs-on: core
strategy:
matrix:
target: [
x86_64-unknown-linux-gnu,
x86_64-apple-darwin,
aarch64-apple-darwin,
]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest-large
- target: aarch64-apple-darwin
os: macos-latest-xlarge
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- run: rustup target add wasm32-unknown-unknown
- run: rustup component add rust-src

- run: sudo apt update && sudo apt install -y clang lld
if: ${{ contains(matrix.target, 'linux') }}

- run: brew install llvm lld
if: ${{ contains(matrix.target, 'apple') }}

- name: Run `make test`
run: make test
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ contracts: setup-compiler ## Build example contracts
@contracts/c-example/build.sh
@find target/wasm64-unknown-unknown/release -maxdepth 1 -name "*.wasm" \
| xargs -I % basename % \
| xargs -I % wasm-tools strip -a \
| xargs -I % ./scripts/strip.sh \
target/wasm64-unknown-unknown/release/% \
-o target/stripped/%
target/stripped/%

test: contracts cold-reboot assert-counter-contract-small ## Run all tests
@cargo test \
Expand Down
54 changes: 54 additions & 0 deletions scripts/strip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

# The script should check whether the inputs are set, or print usage
# information otherwise.
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <input-wasm> <output-wasm>"
exit 1
fi

TRIPLE=$(rustc -vV | sed -n 's|host: ||p')
ARCH=$(echo "$TRIPLE" | cut -f 1 -d'-')

# This is a bit of a mess because target triples are pretty inconsistent
OS=$(echo "$TRIPLE" | cut -f 2 -d'-')
# If OS is not currently linux, or apple, then we get it again
if [ "$OS" != "linux" ] && [ "$OS" != "apple" ]; then
OS=$(echo "$TRIPLE" | cut -f 3 -d'-')
fi
if [ "$OS" != "linux" ] && [ "$OS" != "apple" ]; then
echo "OS not supported: $OS"
exit 1
fi
# If OS is apple, change it to macos
if [ "$OS" = "apple" ]; then
OS="macos"
fi

RELEASES_URL=https://github.com/bytecodealliance/wasm-tools/releases/download

PROGRAM_VERSION=1.0.54

ARTIFACT_NAME=wasm-tools-$PROGRAM_VERSION-$ARCH-$OS.tar.gz
ARTIFACT_URL=$RELEASES_URL/wasm-tools-$PROGRAM_VERSION/$ARTIFACT_NAME

ARTIFACT_DIR=$PWD/target/wasm-tools/$PROGRAM_VERSION
ARTIFACT_PATH=$ARTIFACT_DIR/$ARTIFACT_NAME

# If the artifact doesn't already exist in the target directory, download it,
# otherwise skip.
if [ ! -f "$ARTIFACT_PATH" ]; then
echo "Downloading wasm-tools version $PROGRAM_VERSION"
mkdir -p "$ARTIFACT_DIR"
curl -L "$ARTIFACT_URL" -o "$ARTIFACT_PATH"
fi

# Extract the tarball, if they aren't already extracted
EXTRACTED_DIR=$ARTIFACT_DIR/extracted

if [ ! -d "$EXTRACTED_DIR" ]; then
mkdir -p "$EXTRACTED_DIR"
tar -xzf "$ARTIFACT_PATH" -C "$EXTRACTED_DIR" --strip-components=1
fi

"$EXTRACTED_DIR"/wasm-tools strip -a "$1" -o "$2"

0 comments on commit b2c32ed

Please sign in to comment.