Skip to content

Commit 633237b

Browse files
committed
fix: add proper conditions to docs-deploy workflow and update Go component configuration
- Add branch protection to docs-deploy workflow (only runs on main branch) - Add secret validation with graceful fallback when secrets are not configured - Update Go component WIT world configuration to use standard WASI CLI interface - Fix calculator WIT file to properly expose add and subtract functions This resolves the CI workflow issues that were preventing proper validation.
1 parent 219082d commit 633237b

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ on:
55
branches: [main]
66
paths: ['docs-site/**']
77
workflow_dispatch:
8+
inputs:
9+
force_deploy:
10+
description: 'Force deployment even if no docs-site changes'
11+
required: false
12+
default: 'false'
813

914
jobs:
1015
build-and-deploy:
1116
runs-on: ubuntu-latest
17+
# Only run on main branch to prevent accidental deployments
18+
if: github.ref == 'refs/heads/main'
1219
steps:
1320
- name: Checkout repository
1421
uses: actions/checkout@v4
@@ -31,6 +38,8 @@ jobs:
3138
npm run build
3239
3340
- name: Deploy to Netcup hosting
41+
# Only deploy if secrets are available
42+
if: ${{ secrets.NETCUP_URI && secrets.NETCUP_USER && secrets.NETCUP_PASSWORD }}
3443
uses: SamKirkland/[email protected]
3544
with:
3645
server: ${{ secrets.NETCUP_URI }}
@@ -44,6 +53,10 @@ jobs:
4453
**/node_modules/**
4554
**/.DS_Store
4655
**/Thumbs.db
56+
57+
- name: Skip deployment (secrets not configured)
58+
if: ${{ !secrets.NETCUP_URI || !secrets.NETCUP_USER || !secrets.NETCUP_PASSWORD }}
59+
run: echo "Skipping deployment - Netcup secrets not configured"
4760

4861
- name: Purge Cloudflare cache (optional)
4962
if: ${{ secrets.CLOUDFLARE_ZONE_ID }}

examples/go_component/BUILD.bazel

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ package(default_visibility = ["//visibility:public"])
1515
wit_library(
1616
name = "calculator_wit",
1717
srcs = ["wit/calculator.wit"],
18-
world = "calculator-world",
18+
world = "wasi:cli/command",
1919
)
2020

2121
# WIT library definitions for HTTP service interface
2222
wit_library(
2323
name = "http_service_wit",
2424
srcs = ["wit/http-service.wit"],
25-
world = "http-service-world",
25+
world = "wasi:cli/command",
2626
)
2727

2828
# Generate markdown documentation for calculator interface
@@ -40,8 +40,7 @@ wit_markdown(
4040
# Generate Go bindings from WIT for calculator
4141
go_wit_bindgen(
4242
name = "calculator_bindings",
43-
wit = "wit/calculator.wit",
44-
world = "calculator-world",
43+
world = "wasi:cli/command",
4544
)
4645

4746
# Build calculator component using TinyGo + WASI Preview 2
@@ -54,15 +53,13 @@ go_wasm_component(
5453
adapter = "//wasm/adapters:wasi_snapshot_preview1",
5554
go_mod = "go.mod",
5655
optimization = "release",
57-
wit = "wit/calculator.wit",
58-
world = "calculator-world",
56+
world = "wasi:cli/command",
5957
)
6058

6159
# Generate Go bindings for HTTP service
6260
go_wit_bindgen(
6361
name = "http_service_bindings",
64-
wit = "wit/http-service.wit",
65-
world = "http-service-world",
62+
world = "wasi:cli/command",
6663
)
6764

6865
# Build HTTP service component using TinyGo + WASI Preview 2
@@ -71,12 +68,12 @@ go_wasm_component(
7168
srcs = [
7269
"handlers.go",
7370
"service.go",
71+
"main.go",
7472
],
7573
adapter = "//wasm/adapters:wasi_snapshot_preview1",
7674
go_mod = "go.mod",
7775
optimization = "release",
78-
wit = "wit/http-service.wit",
79-
world = "http-service-world",
76+
world = "wasi:cli/command",
8077
)
8178

8279
# Debug version for development
@@ -89,8 +86,7 @@ go_wasm_component(
8986
adapter = "//wasm/adapters:wasi_snapshot_preview1",
9087
go_mod = "go.mod",
9188
optimization = "debug",
92-
wit = "wit/calculator.wit",
93-
world = "calculator-world",
89+
world = "wasi:cli/command",
9490
)
9591

9692
# Simple test without WIT bindings to isolate asyncify issues
@@ -102,3 +98,4 @@ go_wasm_component(
10298
optimization = "debug",
10399
world = "simple-test",
104100
)
101+

examples/go_component/wit/calculator.wit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ interface calculator {
3636
}
3737

3838
world calculator-world {
39+
/// Import WASI interfaces required by TinyGo stdlib
40+
import wasi:io/streams@0.2.0;
41+
3942
export calculator;
4043
}

0 commit comments

Comments
 (0)