Skip to content

Commit c94f5e1

Browse files
committed
update ci and clean guest-examples
1 parent b4dc957 commit c94f5e1

File tree

14 files changed

+72
-293
lines changed

14 files changed

+72
-293
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,37 @@ jobs:
120120
- name: Run tests
121121
run: make test
122122

123-
# Build guest programs in parallel using matrix
124-
build-guest:
123+
# Generate guest program list dynamically
124+
generate-guest-matrix:
125125
runs-on: ubuntu-latest
126126
# Run on main branches, release branches, or when explicitly requested
127127
if: |
128128
github.ref == 'refs/heads/master' ||
129129
startsWith(github.ref, 'refs/heads/release/') ||
130130
startsWith(github.ref, 'refs/tags/v') ||
131131
contains(github.event.pull_request.labels.*.name, 'full-build')
132+
outputs:
133+
guest-matrix: ${{ steps.generate-matrix.outputs.guest-matrix }}
134+
steps:
135+
- uses: actions/checkout@v4
136+
with:
137+
submodules: recursive
138+
139+
- name: Generate guest matrix
140+
id: generate-matrix
141+
run: |
142+
# Extract package names from Cargo.toml files
143+
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]')
144+
echo "guest-matrix=$guests" >> $GITHUB_OUTPUT
145+
echo "Found guest programs: $guests"
146+
147+
# Build guest programs in parallel using dynamic matrix
148+
build-guest:
149+
runs-on: ubuntu-latest
150+
needs: generate-guest-matrix
132151
strategy:
133152
matrix:
134-
guest: [
135-
sum-balance,
136-
sum-balance-hand-written,
137-
sum-balance-percent,
138-
swap-info,
139-
total-supply,
140-
total-supply-hand-written,
141-
transparent-call-hand-written
142-
]
153+
guest: ${{ fromJson(needs.generate-guest-matrix.outputs.guest-matrix) }}
143154
steps:
144155
- uses: actions/checkout@v4
145156
with:
@@ -153,7 +164,7 @@ jobs:
153164
- uses: Swatinem/rust-cache@v2
154165
with:
155166
cache-bin: "false"
156-
prefix-key: "guest-${{ matrix.guest }}"
167+
prefix-key: "${{ matrix.guest }}"
157168

158169
- name: Install polkatool and pvq-program-metadata-gen
159170
run: |
@@ -177,7 +188,7 @@ jobs:
177188
# Collect all guest artifacts (optional - for when you need all guests together)
178189
collect-guests:
179190
runs-on: ubuntu-latest
180-
needs: build-guest
191+
needs: [generate-guest-matrix, build-guest]
181192
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'full-build')
182193
steps:
183194
- name: Download all guest artifacts

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
run: chainspec
33
bunx @acala-network/chopsticks@1.0.6 --config poc/runtime/chopsticks.yml --genesis output/chainspec.json
44

5-
GUEST_EXAMPLES = $(shell find guest-examples -name "Cargo.toml" -not -path "guest-examples/Cargo.toml" | xargs -n1 dirname | xargs -n1 basename)
5+
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 " \""')
66
GUEST_TARGETS = $(patsubst %,guest-%,$(GUEST_EXAMPLES))
77
DUMMY_GUEST_TARGETS = $(patsubst %,dummy-guest-%,$(GUEST_EXAMPLES))
88

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

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

2020
dummy-guest-%:
2121
mkdir -p output
22-
touch output/guest-$*.polkavm
22+
touch output/$*.polkavm
2323

2424
.PHONY: tools
2525
tools: polkatool chain-spec-builder pvq-program-metadata-gen

guest-examples/Cargo.lock

Lines changed: 39 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

guest-examples/Cargo.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
[workspace]
2-
members = [
3-
"sum-balance",
4-
"sum-balance-percent",
5-
"sum-balance-hand-written",
6-
"total-supply",
7-
"total-supply-hand-written",
8-
"transparent-call-hand-written",
9-
"swap-info",
10-
]
2+
members = ["sum-balance", "sum-balance-percent", "total-supply", "swap-info"]
113
resolver = "2"
124

135
[workspace.dependencies]

guest-examples/sum-balance-hand-written/Cargo.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

guest-examples/sum-balance-hand-written/src/main.rs

Lines changed: 0 additions & 83 deletions
This file was deleted.

guest-examples/sum-balance-percent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "guest-sum-balance-percent"
2+
name = "sum-balance-percent"
33
version = "0.1.0"
44
edition = "2021"
55
publish = false

guest-examples/sum-balance/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "guest-sum-balance"
2+
name = "sum-balance"
33
version = "0.1.0"
44
edition = "2021"
55
publish = false

guest-examples/swap-info/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "guest-swap-info"
2+
name = "swap-info"
33
version = "0.1.0"
44
edition = "2021"
55
publish = false

guest-examples/total-supply-hand-written/Cargo.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)