Skip to content

Commit 94e38d5

Browse files
sanityclaude
andauthored
fix: Add platform guards for WASM import symbols to fix Windows linking (#43)
* Add Claude Code workflows for CI integration Adds three Claude workflows: - claude.yml: Responds to @claude mentions in issues/PRs - claude-code-review.yml: Automated PR code reviews - claude-ci-analysis job in ci.yml: Analyzes CI failures when 'claude-debug' label is present Features: - Opt-in debugging with 'claude-debug' label - Automatic code review on PR creation - Interactive @claude support for questions and debugging - Reads CI logs and provides root cause analysis 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Use ANTHROPIC_API_KEY instead of CLAUDE_CODE_OAUTH_TOKEN Changed all Claude workflows to use ANTHROPIC_API_KEY environment variable instead of claude_code_oauth_token parameter. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Move ANTHROPIC_API_KEY to job-level env Composite actions need environment variables at job level, not step level, to properly access them during validation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Add platform guards for WASM import symbols to fix Windows linking Fixes freenet/river#39 Windows MSVC linker requires all external symbols to be resolved, even for cdylib crates. The WASM import symbols (__frnt__logger__info, __frnt__rand__rand_bytes, __frnt__time__utc_now) are only valid when compiling to wasm32-unknown-unknown target. This change: - Guards WASM imports with #[cfg(target_family = "wasm")] - Provides stub implementations for non-WASM targets - Allows contracts to compile on Windows native target The stub implementations are never used at runtime since contracts only execute in the Freenet WASM runtime. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d8728b3 commit 94e38d5

File tree

6 files changed

+174
-0
lines changed

6 files changed

+174
-0
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,45 @@ jobs:
113113

114114
- name: Check code formatting
115115
run: cargo fmt -- --check
116+
117+
claude-ci-analysis:
118+
name: Claude CI Analysis
119+
120+
runs-on: ubuntu-latest
121+
needs: [test_all, build_targets, clippy_check, fmt_check]
122+
if: failure() && contains(github.event.pull_request.labels.*.name, 'claude-debug')
123+
124+
permissions:
125+
contents: read
126+
pull-requests: write
127+
issues: read
128+
id-token: write
129+
actions: read
130+
131+
env:
132+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
133+
134+
steps:
135+
- name: Checkout repository
136+
uses: actions/checkout@v4
137+
with:
138+
fetch-depth: 1
139+
140+
- name: Run Claude CI Analysis
141+
uses: anthropics/claude-code-action@v1
142+
with:
143+
prompt: |
144+
REPO: ${{ github.repository }}
145+
PR NUMBER: ${{ github.event.pull_request.number }}
146+
147+
The CI workflow has failed. Please analyze the failure and provide:
148+
1. Root cause of the failure
149+
2. Specific steps to fix the issue
150+
3. Whether this appears to be a flaky test or genuine bug
151+
4. Any relevant context from the codebase
152+
153+
Use the repository's CLAUDE.md for guidance on testing and debugging.
154+
155+
After your analysis, use `gh pr comment` with your Bash tool to post your findings as a comment on the PR.
156+
157+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh api:*),Bash(gh run view:*)"'
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
# Optional: Only run on specific file changes
7+
# paths:
8+
# - "rust/**/*.rs"
9+
# - "**/Cargo.toml"
10+
11+
jobs:
12+
claude-review:
13+
# Optional: Filter by PR author
14+
# if: |
15+
# github.event.pull_request.user.login == 'external-contributor' ||
16+
# github.event.pull_request.user.login == 'new-developer' ||
17+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
18+
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
pull-requests: read
23+
issues: read
24+
id-token: write
25+
26+
env:
27+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 1
34+
35+
- name: Run Claude Code Review
36+
id: claude-review
37+
uses: anthropics/claude-code-action@v1
38+
with:
39+
prompt: |
40+
REPO: ${{ github.repository }}
41+
PR NUMBER: ${{ github.event.pull_request.number }}
42+
43+
Please review this pull request and provide feedback on:
44+
- Code quality and best practices
45+
- Potential bugs or issues
46+
- Performance considerations
47+
- Security concerns
48+
- Test coverage
49+
50+
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
51+
52+
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
53+
54+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
55+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
56+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

.github/workflows/claude.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
actions: read # Required for Claude to read CI results on PRs
27+
28+
env:
29+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 1
36+
37+
- name: Run Claude Code
38+
id: claude
39+
uses: anthropics/claude-code-action@v1
40+
with:
41+
42+
# This is an optional setting that allows Claude to read CI results on PRs
43+
additional_permissions: |
44+
actions: read
45+
46+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
47+
# prompt: 'Update the pull request description to include a summary of changes.'
48+
49+
# Optional: Add claude_args to customize behavior and configuration
50+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
51+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
52+
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'

rust/src/log.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@ pub fn info(msg: &str) {
1515
}
1616
}
1717

18+
#[cfg(target_family = "wasm")]
1819
#[link(wasm_import_module = "freenet_log")]
1920
extern "C" {
2021
#[doc(hidden)]
2122
fn __frnt__logger__info(id: i64, ptr: i64, len: i32);
2223
}
24+
25+
#[cfg(not(target_family = "wasm"))]
26+
#[allow(non_snake_case)]
27+
unsafe fn __frnt__logger__info(_id: i64, _ptr: i64, _len: i32) {
28+
// Stub implementation for non-WASM targets (e.g., Windows native compilation)
29+
// These contracts are meant to run only in WASM runtime
30+
}

rust/src/rand.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@ pub fn rand_bytes(number: u32) -> Vec<u8> {
3333
}
3434
}
3535

36+
#[cfg(target_family = "wasm")]
3637
#[link(wasm_import_module = "freenet_rand")]
3738
extern "C" {
3839
#[doc(hidden)]
3940
fn __frnt__rand__rand_bytes(id: i64, ptr: i64, len: u32);
4041
}
42+
43+
#[cfg(not(target_family = "wasm"))]
44+
#[allow(non_snake_case)]
45+
unsafe fn __frnt__rand__rand_bytes(_id: i64, _ptr: i64, _len: u32) {
46+
// Stub implementation for non-WASM targets (e.g., Windows native compilation)
47+
// These contracts are meant to run only in WASM runtime
48+
}

rust/src/time.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ pub fn now() -> DateTime<Utc> {
1414
}
1515
}
1616

17+
#[cfg(target_family = "wasm")]
1718
#[link(wasm_import_module = "freenet_time")]
1819
extern "C" {
1920
#[doc(hidden)]
2021
fn __frnt__time__utc_now(id: i64, ptr: i64);
2122
}
23+
24+
#[cfg(not(target_family = "wasm"))]
25+
#[allow(non_snake_case)]
26+
unsafe fn __frnt__time__utc_now(_id: i64, _ptr: i64) {
27+
// Stub implementation for non-WASM targets (e.g., Windows native compilation)
28+
// These contracts are meant to run only in WASM runtime
29+
}

0 commit comments

Comments
 (0)