Skip to content

Commit

Permalink
✨ fpvm tests in CI (#19)
Browse files Browse the repository at this point in the history
don't install go for `cannon-rs` tests

caching

prefix key

use actions/cache for go
  • Loading branch information
clabby authored Feb 13, 2024
1 parent 6831d10 commit b4b3ba7
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 26 deletions.
33 changes: 27 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,56 @@ jobs:
cargo-lint:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
target: ["native", "cannon", "asterisc"]
name: lint-${{ matrix.target }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: cargo fmt
run: cargo fmt --all -- --check
- name: cargo clippy
run: cargo clippy --workspace --all --locked -- -D warnings
prefix-key: ${{ matrix.target }}
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: fmt + lint
run: just lint-${{ matrix.target }}
cargo-build:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
target: ["native", "cannon", "asterisc"]
name: build-${{ matrix.target }}
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
prefix-key: ${{ matrix.target }}
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build
id: build
run: cargo build --workspace --all --locked
run: just build-${{ matrix.target }}
cargo-doc:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/fpvm-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: FPVM
on: [push]
env:
CARGO_TERM_COLOR: always
jobs:
build-example-programs:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
fpvm: ["cannon", "asterisc"]
name: build-${{ matrix.fpvm }}-examples
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
prefix-key: ${{ matrix.fpvm }}
cache-directories: |
examples/minimal/target
examples/simple-revm/target
- uses: taiki-e/install-action@just
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.fpvm }} examples
working-directory: ./fpvm-tests
run: just build-${{ matrix.fpvm }}-examples
- uses: actions/upload-artifact@v4
with:
name: images-${{ matrix.fpvm }}
path: |
examples/minimal/target/${{ matrix.fpvm == 'cannon' && 'mips-unknown-none' || 'riscv64gc-unknown-none-elf' }}/release/minimal
examples/simple-revm/target/${{ matrix.fpvm == 'cannon' && 'mips-unknown-none' || 'riscv64gc-unknown-none-elf' }}/release/simple-revm
fpvm-example-tests:
needs: build-example-programs
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
fpvm: ["cannon-go", "cannon-rs", "asterisc"]
name: ${{ matrix.fpvm }}-tests
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- name: Install Rust nightly toolchain
if: contains(matrix.fpvm, 'cannon-rs')
uses: dtolnay/rust-toolchain@nightly
- name: Install xsltproc
if: contains(matrix.fpvm, 'cannon-rs')
run: sudo apt-get install xsltproc
- uses: Swatinem/rust-cache@v2
if: contains(matrix.fpvm, 'cannon-rs')
with:
cache-on-failure: true
prefix-key: ${{ matrix.fpvm }}
cache-directories: |
fpvm-tests/cannon-rs-tests/target
- name: Setup Go toolchain
if: "!contains(matrix.fpvm, 'cannon-rs')"
uses: actions/setup-go@v4
with:
go-version: "1.21.6"
# Doesn't support key prefixes, L.
cache: false
- id: go-cache-paths
if: "!contains(matrix.fpvm, 'cannon-rs')"
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Cache Golang Builds
if: "!contains(matrix.fpvm, 'cannon-rs')"
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ matrix.fpvm }}-fpvm-test-go-build-cache-${{ hashFiles(format('fpvm-tests/{0}-tests/go.sum', matrix.fpvm)) }}
- name: Cache Golang Modules
if: "!contains(matrix.fpvm, 'cannon-rs')"
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ matrix.fpvm }}-fpvm-test-go-mod-cache-${{ hashFiles(format('fpvm-tests/{0}-tests/go.sum', matrix.fpvm)) }}
- name: Download Binaries
uses: actions/download-artifact@v4
with:
name: images-${{ contains(matrix.fpvm, 'cannon') && 'cannon' || 'asterisc' }}
- name: Restore Targets
run: |
mv minimal/target examples/minimal
mv simple-revm/target examples/simple-revm
- name: Run FPVM tests
working-directory: ./fpvm-tests
run: just test-${{ matrix.fpvm }}
5 changes: 3 additions & 2 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ docker run \
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
cannon-pipeline:latest cargo build --release -Zbuild-std
ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo build --release -Zbuild-std
```

**asterisc**

```
docker run \
--rm \
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
asterisc-pipeline:latest cargo build --release -Zbuild-std
ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build --release -Zbuild-std
```
4 changes: 2 additions & 2 deletions examples/minimal/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-cannon *args='':
--platform linux/amd64 \
-v `pwd`/../../:/workdir \
-w="/workdir/examples/minimal" \
cannon-pipeline:latest cargo build -Zbuild-std $@
ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo build -Zbuild-std $@

# Build for the `asterisc` target
build-asterisc *args='':
Expand All @@ -16,4 +16,4 @@ build-asterisc *args='':
--platform linux/amd64 \
-v `pwd`/../../:/workdir \
-w="/workdir/examples/minimal" \
asterisc-pipeline:latest cargo build -Zbuild-std $@
ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build -Zbuild-std $@
4 changes: 2 additions & 2 deletions examples/simple-revm/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-cannon *args='':
--platform linux/amd64 \
-v `pwd`/../../:/workdir \
-w="/workdir/examples/simple-revm" \
cannon-pipeline:latest cargo build -Zbuild-std $@
ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo build -Zbuild-std $@

# Build for the `asterisc` target
build-asterisc *args='':
Expand All @@ -16,4 +16,4 @@ build-asterisc *args='':
--platform linux/amd64 \
-v `pwd`/../../:/workdir \
-w="/workdir/examples/simple-revm" \
asterisc-pipeline:latest cargo build -Zbuild-std $@
ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build -Zbuild-std $@
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 19 additions & 8 deletions fpvm-tests/justfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
# Test all FPVM targets
test: test-cannon test-asterisc
test: build-cannon-examples build-asterisc-examples test-cannon test-asterisc

# Test programs on `cannon`
test-cannon:
# Build the programs
# Build cannon programs
build-cannon-examples:
@cd ../examples/minimal && just build-cannon --release
@cd ../examples/simple-revm && just build-cannon --release

# Build asterisc programs
build-asterisc-examples:
@cd ../examples/minimal && just build-asterisc --release
@cd ../examples/simple-revm && just build-asterisc --release

# Test programs on `cannon`
test-cannon: test-cannon-go test-cannon-rs

# Test programs on `cannon`
test-cannon-go:
# Run Cannon tests
@cd cannon-go-tests && go test -count=1 -v ./...

# Test programs on `cannon-rs`
test-cannon-rs:
# Run Cannon tests
@cd cannon-tests && go test -count=1 -v ./...
@cd cannon-rs-tests && cargo +nightly test --release

# Test programs on `asterisc`
test-asterisc:
# Build the programs
@cd ../examples/minimal && just build-asterisc --release
@cd ../examples/simple-revm && just build-asterisc --release
# Run Asterisc tests
@cd asterisc-tests && go test -count=1 -v ./...
19 changes: 13 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ test *args='':
# Lint the workspace for all available targets
lint: lint-native lint-cannon lint-asterisc

# Lint the workspace
lint-native:
# Fixes the formatting of the workspace
fmt-native-fix:
cargo +nightly fmt --all

# Check the formatting of the workspace
fmt-native-check:
cargo +nightly fmt --all -- --check

# Lint the workspace
lint-native: fmt-native-check
cargo +nightly clippy --workspace --all --all-features --all-targets -- -D warnings

# Lint the workspace (mips arch)
Expand All @@ -23,7 +30,7 @@ lint-cannon:
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
cannon-pipeline:latest cargo +nightly clippy --workspace --all --all-features --target /mips-unknown-none.json -Zbuild-std -- -D warnings
ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo +nightly clippy --workspace --all --all-features --target /mips-unknown-none.json -Zbuild-std -- -D warnings

# Lint the workspace (risc-v arch)
lint-asterisc:
Expand All @@ -32,7 +39,7 @@ lint-asterisc:
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
asterisc-pipeline:latest cargo +nightly clippy --workspace --all --all-features --target riscv64gc-unknown-linux-gnu -Zbuild-std -- -D warnings
ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo +nightly clippy --workspace --all --all-features --target riscv64gc-unknown-linux-gnu -Zbuild-std -- -D warnings

# Build the workspace for all available targets
build: build-native build-cannon build-asterisc
Expand All @@ -48,7 +55,7 @@ build-cannon *args='':
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
cannon-pipeline:latest cargo build --workspace --all -Zbuild-std $@
ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo build --workspace --all -Zbuild-std $@

# Build for the `asterisc` target
build-asterisc *args='':
Expand All @@ -57,4 +64,4 @@ build-asterisc *args='':
--platform linux/amd64 \
-v `pwd`/:/workdir \
-w="/workdir" \
asterisc-pipeline:latest cargo build --workspace --all -Zbuild-std $@
ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build --workspace --all -Zbuild-std $@

0 comments on commit b4b3ba7

Please sign in to comment.