Skip to content

Commit

Permalink
Set up the initial CI pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed Sep 4, 2023
1 parent 80e614e commit 8321540
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 25 deletions.
51 changes: 43 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,48 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:

build-and-test-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install LLD
run: sudo apt-get install -y lld
- name: Install target -- i686-unknown-linux-musl
run: rustup target add i686-unknown-linux-musl
- name: Build and test (generic)
run: ./ci/jobs/build-and-test.sh
- name: Build and test (Linux-only)
run: ./ci/jobs/build-and-test-linux.sh
build-and-test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build and test
run: ./ci/jobs/build-and-test.sh
build-and-test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Build and test
shell: bash
run: ./ci/jobs/build-and-test.sh
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clippy (base toolchain)
run: rustup component add clippy
- name: Install clippy (zygote toolchain)
run: cd crates/polkavm-zygote && rustup component add clippy
- name: Run clippy
run: ./ci/jobs/clippy.sh
rustfmt:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- uses: actions/checkout@v4
- name: Install rustfmt (base toolchain)
run: rustup component add rustfmt
- name: Install rustfmt (zygote toolchain)
run: cd crates/polkavm-zygote && rustup component add rustfmt
- name: Run rustfmt
run: ./ci/jobs/rustfmt.sh
13 changes: 13 additions & 0 deletions ci/jobs/build-and-test-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ../..

echo ">> cargo build (zygote)"
cd crates/polkavm-zygote
cargo build --release
cd ../..

echo ">> cargo run (examples, musl)"
POLKAVM_TRACE_EXECUTION=1 POLKAVM_ALLOW_INSECURE=1 cargo run --target=i686-unknown-linux-musl -p hello-world-host
14 changes: 14 additions & 0 deletions ci/jobs/build-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ../..

echo ">> cargo test (debug)"
cargo test --all

echo ">> cargo test (release)"
cargo test --all --release

echo ">> cargo run (examples)"
POLKAVM_TRACE_EXECUTION=1 POLKAVM_ALLOW_INSECURE=1 cargo run -p hello-world-host
12 changes: 12 additions & 0 deletions ci/jobs/build-guests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ../..

if [ "${CI_RV32E_TOOLCHAIN_AVAILABLE:-}" == 1 ]; then
echo ">> cargo build (example guests)"
cd examples/guests
cargo build --all
cd ../..
fi
20 changes: 20 additions & 0 deletions ci/jobs/clippy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ../..

echo ">> cargo clippy"
RUSTFLAGS="-D warnings" cargo clippy --all

echo ">> cargo clippy (zygote)"
cd crates/polkavm-zygote
RUSTFLAGS="-D warnings" cargo clippy --all
cd ../..

if [ "${CI_RV32E_TOOLCHAIN_AVAILABLE:-}" == 1 ]; then
echo ">> cargo clippy (example guests)"
cd examples/guests
RUSTFLAGS="-D warnings" cargo clippy --all
cd ../..
fi
20 changes: 20 additions & 0 deletions ci/jobs/rustfmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ../..

echo ">> cargo fmt"
cargo fmt --check --all

echo ">> cargo fmt (zygote)"
cd crates/polkavm-zygote
cargo fmt --check --all
cd ../..

if [ "${CI_RV32E_TOOLCHAIN_AVAILABLE:-}" == 1 ]; then
echo ">> cargo fmt (example guests)"
cd examples/guests
cargo fmt --check --all
cd ../..
fi
26 changes: 9 additions & 17 deletions ci/run-all-tests.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
#!/bin/bash

set -euo pipefail

cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
cd ..

cargo test --all
POLKAVM_TRACE_EXECUTION=1 POLKAVM_ALLOW_INSECURE=1 cargo run -p hello-world-host
POLKAVM_TRACE_EXECUTION=1 POLKAVM_ALLOW_INSECURE=1 cargo run --target=i686-unknown-linux-musl -p hello-world-host

cd crates/polkavm-zygote
cargo build --release
RUSTFLAGS='-D warnings' cargo clippy --all
cargo fmt --check --all
cd ../..
./ci/jobs/build-and-test.sh

cd examples/guests
cargo build
RUSTFLAGS='-D warnings' cargo clippy --all
cargo fmt --check --all
cd ../..
case "$OSTYPE" in
linux*)
./ci/jobs/build-and-test-linux.sh
esac

RUSTFLAGS='-D warnings' cargo clippy --all
cargo fmt --check --all
./ci/jobs/build-guests.sh
./ci/jobs/clippy.sh
./ci/jobs/rustfmt.sh

echo "----------------------------------------"
echo "All tests finished!"

0 comments on commit 8321540

Please sign in to comment.