diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7baef7b..3e06f9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,3 +113,45 @@ jobs: - name: Check code formatting run: cargo fmt -- --check + + claude-ci-analysis: + name: Claude CI Analysis + + runs-on: ubuntu-latest + needs: [test_all, build_targets, clippy_check, fmt_check] + if: failure() && contains(github.event.pull_request.labels.*.name, 'claude-debug') + + permissions: + contents: read + pull-requests: write + issues: read + id-token: write + actions: read + + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude CI Analysis + uses: anthropics/claude-code-action@v1 + with: + prompt: | + REPO: ${{ github.repository }} + PR NUMBER: ${{ github.event.pull_request.number }} + + The CI workflow has failed. Please analyze the failure and provide: + 1. Root cause of the failure + 2. Specific steps to fix the issue + 3. Whether this appears to be a flaky test or genuine bug + 4. Any relevant context from the codebase + + Use the repository's CLAUDE.md for guidance on testing and debugging. + + After your analysis, use `gh pr comment` with your Bash tool to post your findings as a comment on the PR. + + 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:*)"' diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 0000000..feeb3f0 --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,56 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize] + # Optional: Only run on specific file changes + # paths: + # - "rust/**/*.rs" + # - "**/Cargo.toml" + +jobs: + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + prompt: | + REPO: ${{ github.repository }} + PR NUMBER: ${{ github.event.pull_request.number }} + + Please review this pull request and provide feedback on: + - Code quality and best practices + - Potential bugs or issues + - Performance considerations + - Security concerns + - Test coverage + + Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback. + + Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR. + + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options + 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:*)"' \ No newline at end of file diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 0000000..ba3a63a --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,52 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + with: + + # This is an optional setting that allows Claude to read CI results on PRs + additional_permissions: | + actions: read + + # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. + # prompt: 'Update the pull request description to include a summary of changes.' + + # Optional: Add claude_args to customize behavior and configuration + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options + # claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)' \ No newline at end of file diff --git a/rust/src/log.rs b/rust/src/log.rs index 8fc87d4..a92c2a2 100644 --- a/rust/src/log.rs +++ b/rust/src/log.rs @@ -5,8 +5,16 @@ pub fn info(msg: &str) { } } +#[cfg(target_family = "wasm")] #[link(wasm_import_module = "freenet_log")] extern "C" { #[doc(hidden)] fn __frnt__logger__info(id: i64, ptr: i64, len: i32); } + +#[cfg(not(target_family = "wasm"))] +#[allow(non_snake_case)] +unsafe fn __frnt__logger__info(_id: i64, _ptr: i64, _len: i32) { + // Stub implementation for non-WASM targets (e.g., Windows native compilation) + // These contracts are meant to run only in WASM runtime +} diff --git a/rust/src/rand.rs b/rust/src/rand.rs index 81bef47..bf19269 100644 --- a/rust/src/rand.rs +++ b/rust/src/rand.rs @@ -33,8 +33,16 @@ pub fn rand_bytes(number: u32) -> Vec { } } +#[cfg(target_family = "wasm")] #[link(wasm_import_module = "freenet_rand")] extern "C" { #[doc(hidden)] fn __frnt__rand__rand_bytes(id: i64, ptr: i64, len: u32); } + +#[cfg(not(target_family = "wasm"))] +#[allow(non_snake_case)] +unsafe fn __frnt__rand__rand_bytes(_id: i64, _ptr: i64, _len: u32) { + // Stub implementation for non-WASM targets (e.g., Windows native compilation) + // These contracts are meant to run only in WASM runtime +} diff --git a/rust/src/time.rs b/rust/src/time.rs index c844533..84ffed1 100644 --- a/rust/src/time.rs +++ b/rust/src/time.rs @@ -14,8 +14,16 @@ pub fn now() -> DateTime { } } +#[cfg(target_family = "wasm")] #[link(wasm_import_module = "freenet_time")] extern "C" { #[doc(hidden)] fn __frnt__time__utc_now(id: i64, ptr: i64); } + +#[cfg(not(target_family = "wasm"))] +#[allow(non_snake_case)] +unsafe fn __frnt__time__utc_now(_id: i64, _ptr: i64) { + // Stub implementation for non-WASM targets (e.g., Windows native compilation) + // These contracts are meant to run only in WASM runtime +}