Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
37 changes: 24 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,37 @@ jobs:
- name: Run tests
run: make test

# Build guest programs in parallel using matrix
build-guest:
# Generate guest program list dynamically
generate-guest-matrix:
runs-on: ubuntu-latest
# Run on main branches, release branches, or when explicitly requested
if: |
github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/v') ||
contains(github.event.pull_request.labels.*.name, 'full-build')
outputs:
guest-matrix: ${{ steps.generate-matrix.outputs.guest-matrix }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Generate guest matrix
id: generate-matrix
run: |
# Extract package names from Cargo.toml files
guests=$(find guest-examples -name "Cargo.toml" -not -path "guest-examples/Cargo.toml" | xargs -I{} sh -c 'grep "^name" "{}" | cut -d"=" -f2 | tr -d " \""' | jq -R -s -c 'split("\n")[:-1]')
echo "guest-matrix=$guests" >> $GITHUB_OUTPUT
echo "Found guest programs: $guests"

# Build guest programs in parallel using dynamic matrix
build-guest:
runs-on: ubuntu-latest
needs: generate-guest-matrix
strategy:
matrix:
guest: [
sum-balance,
sum-balance-hand-written,
sum-balance-percent,
swap-info,
total-supply,
total-supply-hand-written,
transparent-call-hand-written
]
guest: ${{ fromJson(needs.generate-guest-matrix.outputs.guest-matrix) }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -153,7 +164,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-bin: "false"
prefix-key: "guest-${{ matrix.guest }}"
prefix-key: "${{ matrix.guest }}"

- name: Install polkatool and pvq-program-metadata-gen
run: |
Expand All @@ -177,7 +188,7 @@ jobs:
# Collect all guest artifacts (optional - for when you need all guests together)
collect-guests:
runs-on: ubuntu-latest
needs: build-guest
needs: [generate-guest-matrix, build-guest]
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'full-build')
steps:
- name: Download all guest artifacts
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
run: chainspec
bunx @acala-network/chopsticks@1.0.6 --config poc/runtime/chopsticks.yml --genesis output/chainspec.json

GUEST_EXAMPLES = $(shell find guest-examples -name "Cargo.toml" -not -path "guest-examples/Cargo.toml" | xargs -n1 dirname | xargs -n1 basename)
GUEST_EXAMPLES = $(shell find guest-examples -name "Cargo.toml" -not -path "guest-examples/Cargo.toml" | xargs -I{} sh -c 'grep "^name" "{}" | cut -d"=" -f2 | tr -d " \""')
GUEST_TARGETS = $(patsubst %,guest-%,$(GUEST_EXAMPLES))
DUMMY_GUEST_TARGETS = $(patsubst %,dummy-guest-%,$(GUEST_EXAMPLES))

Expand All @@ -14,12 +14,12 @@ dummy-guests: $(DUMMY_GUEST_TARGETS)

guest-%:
mkdir -p output
cd guest-examples; METADATA_OUTPUT_DIR=$(shell pwd)/output cargo build --release --bin guest-$* -p guest-$*
polkatool link --run-only-if-newer -s guest-examples/target/riscv32emac-unknown-none-polkavm/release/guest-$* -o output/guest-$*.polkavm
cd guest-examples; METADATA_OUTPUT_DIR=$(shell pwd)/output cargo build --release --bin $* -p $*
polkatool link --run-only-if-newer -s guest-examples/target/riscv32emac-unknown-none-polkavm/release/$* -o output/$*.polkavm

dummy-guest-%:
mkdir -p output
touch output/guest-$*.polkavm
touch output/$*.polkavm

.PHONY: tools
tools: polkatool chain-spec-builder pvq-program-metadata-gen
Expand Down
101 changes: 39 additions & 62 deletions guest-examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions guest-examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[workspace]
members = [
"sum-balance",
"sum-balance-percent",
"sum-balance-hand-written",
"total-supply",
"total-supply-hand-written",
"transparent-call-hand-written",
"swap-info",
]
members = ["sum-balance", "sum-balance-percent", "total-supply", "swap-info"]
resolver = "2"

[workspace.dependencies]
Expand Down
9 changes: 0 additions & 9 deletions guest-examples/sum-balance-hand-written/Cargo.toml

This file was deleted.

83 changes: 0 additions & 83 deletions guest-examples/sum-balance-hand-written/src/main.rs

This file was deleted.

2 changes: 1 addition & 1 deletion guest-examples/sum-balance-percent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "guest-sum-balance-percent"
name = "sum-balance-percent"
version = "0.1.0"
edition = "2021"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion guest-examples/sum-balance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "guest-sum-balance"
name = "sum-balance"
version = "0.1.0"
edition = "2021"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion guest-examples/swap-info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "guest-swap-info"
name = "swap-info"
version = "0.1.0"
edition = "2021"
publish = false
Expand Down
10 changes: 0 additions & 10 deletions guest-examples/total-supply-hand-written/Cargo.toml

This file was deleted.

Loading