Skip to content

Commit 23ab190

Browse files
feat: Resolver WASM distribution via GitHub Releases (#12)
* refactor: Rename rust_guest wasm * feat: GitHub Releases for WASM * refactor: Move deployer distribution to release-please yml * fix: Deployer iamge workflow fixes * refactor: Better strucutre the workflows * refactor: Small wf renaming * refactor: Change naming slightly
1 parent b25f10f commit 23ab190

File tree

9 files changed

+99
-17
lines changed

9 files changed

+99
-17
lines changed

.github/workflows/deployer-image.yml renamed to .github/workflows/ci-cloudflare-deployer.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Build and Push Deployer Image
1+
name: CloudFlare Deployer Image CI
22

33
on:
44
push:
5+
branches: [ main ]
56
paths-ignore:
67
- 'wasm/**'
78
- 'wasm-msg/**'
@@ -18,7 +19,7 @@ permissions:
1819

1920
jobs:
2021
docker:
21-
name: Build and (conditionally) push image
22+
name: Build image
2223
runs-on: ubuntu-latest
2324
timeout-minutes: 30
2425
steps:
@@ -51,12 +52,12 @@ jobs:
5152
type=semver,pattern={{version}}
5253
type=raw,value=latest,enable={{is_default_branch}}
5354
54-
- name: Build (and push on main/tags)
55+
- name: Build (no push)
5556
uses: docker/build-push-action@v6
5657
with:
5758
context: .
5859
file: ./confidence-cloudflare-resolver/deployer/Dockerfile
59-
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
60+
push: false
6061
build-args: |
6162
COMMIT_SHA=${{ github.sha }}
6263
platforms: linux/amd64

.github/workflows/ci.yml renamed to .github/workflows/ci-wasm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: CI
1+
name: WASM CI
22

33
on:
44
pull_request:
55
push:
66
branches: [ main ]
77

88
jobs:
9-
build_and_test:
9+
Build and test:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout

.github/workflows/release-please.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,96 @@ permissions:
1313
jobs:
1414
release:
1515
runs-on: ubuntu-latest
16+
outputs:
17+
release_created: ${{ steps.release.outputs.release_created }}
18+
tag_name: ${{ steps.release.outputs.tag_name }}
1619
steps:
1720
- name: Checkout
1821
uses: actions/checkout@v4
1922
with:
2023
fetch-depth: 0
2124

2225
- name: Release Please (manifest)
26+
id: release
2327
uses: googleapis/release-please-action@v4
2428
with:
2529
token: ${{ secrets.GITHUB_TOKEN }}
2630
config-file: release-please-config.json
2731
manifest-file: .release-please-manifest.json
2832

33+
publish-wasm:
34+
needs: release
35+
if: ${{ needs.release.outputs.release_created == 'true' }}
36+
runs-on: ubuntu-latest
37+
permissions:
38+
contents: write
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Setup Rust (stable)
44+
uses: dtolnay/rust-toolchain@stable
45+
with:
46+
targets: wasm32-unknown-unknown
47+
48+
- name: Install protoc
49+
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
50+
51+
- name: Build WASM artifact
52+
run: make wasm/confidence_resolver.wasm
53+
54+
- name: Upload WASM to GitHub Release
55+
uses: softprops/action-gh-release@v2
56+
with:
57+
tag_name: ${{ needs.release.outputs.tag_name }}
58+
files: |
59+
wasm/confidence_resolver.wasm
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
publish-cloudflare-deployer-image:
64+
needs: release
65+
if: ${{ needs.release.outputs.release_created == 'true' }}
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: read
69+
packages: write
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
74+
- name: Set up QEMU
75+
uses: docker/setup-qemu-action@v3
76+
77+
- name: Set up Docker Buildx
78+
uses: docker/setup-buildx-action@v3
79+
80+
- name: Log in to GHCR
81+
uses: docker/login-action@v3
82+
with:
83+
registry: ghcr.io
84+
username: ${{ github.actor }}
85+
password: ${{ secrets.GITHUB_TOKEN }}
86+
87+
- name: Docker meta
88+
id: meta
89+
uses: docker/metadata-action@v5
90+
with:
91+
images: ghcr.io/${{ github.repository_owner }}/confidence-cloudflare-deployer
92+
tags: |
93+
type=raw,value=${{ needs.release.outputs.tag_name }}
94+
type=raw,value=latest
95+
96+
- name: Build and push deployer image
97+
uses: docker/build-push-action@v6
98+
with:
99+
context: .
100+
file: ./confidence-cloudflare-resolver/deployer/Dockerfile
101+
push: true
102+
build-args: |
103+
COMMIT_SHA=${{ github.sha }}
104+
platforms: linux/amd64
105+
tags: ${{ steps.meta.outputs.tags }}
106+
labels: ${{ steps.meta.outputs.labels }}
107+
29108

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,27 @@ cloudflare-lint:
3838
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo clippy -p confidence-cloudflare-resolver --lib --target wasm32-unknown-unknown --release
3939

4040
# Produce a stable artifact location for CI hosts
41-
wasm/rust_guest.wasm: | rust-guest
42-
@echo "Copying rust_guest.wasm to wasm/rust_guest.wasm..."
43-
cp target/wasm32-unknown-unknown/wasm/rust_guest.wasm wasm/rust_guest.wasm
41+
wasm/confidence_resolver.wasm: | rust-guest
42+
@echo "Copying rust_guest.wasm to wasm/confidence_resolver.wasm..."
43+
cp target/wasm32-unknown-unknown/wasm/rust_guest.wasm wasm/confidence_resolver.wasm
44+
4445

4546
# Run examples (depend on stable wasm artifact)
46-
run-go-host: wasm/rust_guest.wasm
47+
run-go-host: wasm/confidence_resolver.wasm
4748
cd wasm/go-host && bash generate_proto.sh && go run .
4849

49-
run-node-host: wasm/rust_guest.wasm
50+
run-node-host: wasm/confidence_resolver.wasm
5051
cd wasm/node-host && yarn install --frozen-lockfile && yarn proto:gen && yarn start
5152

52-
run-python-host: wasm/rust_guest.wasm
53+
run-python-host: wasm/confidence_resolver.wasm
5354
cd wasm/python-host \
5455
&& python3 -m venv .venv \
5556
&& .venv/bin/python -m pip install --upgrade pip \
5657
&& .venv/bin/python -m pip install --require-virtualenv wasmtime protobuf \
5758
&& .venv/bin/python generate_proto.py --out .venv/proto \
5859
&& PYTHONPATH=$$(pwd)/.venv:$$(pwd)/.venv/proto:$$PYTHONPATH .venv/bin/python main.py
5960

60-
run-java-host: wasm/rust_guest.wasm
61+
run-java-host: wasm/confidence_resolver.wasm
6162
cd wasm/java-host && mvn -q package exec:java
6263

6364
# Aggregate test runs (only resolver has tests today)

wasm/go-host/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func main() {
1717
// Load the WASM module
18-
wasmPath := filepath.Join("..", "rust_guest.wasm")
18+
wasmPath := filepath.Join("..", "confidence_resolver.wasm")
1919
wasmBytes, err := os.ReadFile(wasmPath)
2020
if err != nil {
2121
log.Fatalf("Failed to read WASM file: %v", err)

wasm/java-host/src/main/java/com/spotify/confidence/wasmresolvepoc/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Main {
1818
private final ResolverApi resolverApi;
1919

2020
public Main() {
21-
Path wasmModulePath = Path.of("../rust_guest.wasm");
21+
Path wasmModulePath = Path.of("../confidence_resolver.wasm");
2222
WasmModule module = Parser.parse(wasmModulePath);
2323
resolverApi = new ResolverApi(module);
2424

wasm/node-host/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ApiBuilder } from './wasm-msg.ts';
88
const dirname = path.dirname(new URL(import.meta.url).pathname);
99

1010
// Load the WASM module from shared artifact
11-
const wasmPath = path.join(dirname, '../../rust_guest.wasm');
11+
const wasmPath = path.join(dirname, '../../confidence_resolver.wasm');
1212
const wasmBuffer = fs.readFileSync(wasmPath);
1313
const resolverState = fs.readFileSync(path.join(dirname, '../../resolver_state.pb'));
1414

wasm/python-host/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def main():
1313
# Load the WASM module
14-
wasm_path = Path(__file__).parent / ".." / "rust_guest.wasm"
14+
wasm_path = Path(__file__).parent / ".." / "confidence_resolver.wasm"
1515
if not wasm_path.exists():
1616
print(f"WASM file not found: {wasm_path}")
1717
sys.exit(1)

wasm/rust-guest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[lib]
7+
name = "rust_guest"
78
crate-type = ["cdylib"] # This is required for WASM
89

910
[dependencies]

0 commit comments

Comments
 (0)