Skip to content

Commit 2a4a3d9

Browse files
Leeon-Tangclaude
andcommitted
Refactor: Align Go SDK with Python SDK structure
Major changes: - Restructure codebase to match Python SDK architecture - Add api/ subpackage with client.go and api.go - Add config.go for global API configuration - Update all tests with 100% functional parity (27 tests, 80.6% coverage) - Add GitHub Actions workflows (claude.yml, claude-code-review.yml, pre-commit.yml) - Update go-packages.yml to align with python-packages.yml - Update README.md and CLAUDE.md documentation - Remove VERSIONING.md (not in Python SDK) Features: - Sync mode status validation - Enhanced error handling and retry logic - Improved test coverage with 8 additional tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 0e21252 commit 2a4a3d9

18 files changed

Lines changed: 2311 additions & 912 deletions
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
# - "**/*.go"
9+
# - "go.mod"
10+
# - "go.sum"
11+
12+
jobs:
13+
claude-review:
14+
# Optional: Filter by PR author
15+
# if: |
16+
# github.event.pull_request.user.login == 'external-contributor' ||
17+
# github.event.pull_request.user.login == 'new-developer' ||
18+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
19+
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code Review
34+
id: claude-review
35+
uses: anthropics/claude-code-action@beta
36+
with:
37+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38+
39+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
40+
# model: "claude-opus-4-1-20250805"
41+
42+
# Direct prompt for automated review (no @claude mention needed)
43+
direct_prompt: |
44+
Please review this pull request and provide feedback on:
45+
- Code quality and best practices
46+
- Potential bugs or issues
47+
- Performance considerations
48+
- Security concerns
49+
- Test coverage
50+
51+
Be constructive and helpful in your feedback.
52+
53+
# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
54+
# use_sticky_comment: true
55+
56+
# Optional: Customize review based on file types
57+
# direct_prompt: |
58+
# Review this PR focusing on:
59+
# - For Go files: Idiomatic Go, error handling, and concurrency safety
60+
# - For API endpoints: Security, input validation, and error handling
61+
# - For tests: Coverage, edge cases, and test quality
62+
# - Check for goroutine leaks and proper context usage
63+
64+
# Optional: Different prompts for different authors
65+
# direct_prompt: |
66+
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
67+
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
68+
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
69+
70+
# Optional: Add specific tools for running tests or linting
71+
# allowed_tools: "Bash(go test),Bash(go vet),Bash(go fmt),Bash(golangci-lint run)"
72+
73+
# Optional: Skip review for certain conditions
74+
# if: |
75+
# !contains(github.event.pull_request.title, '[skip-review]') &&
76+
# !contains(github.event.pull_request.title, '[WIP]')

.github/workflows/claude.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@beta
36+
with:
37+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38+
39+
# This is an optional setting that allows Claude to read CI results on PRs
40+
additional_permissions: |
41+
actions: read
42+
43+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1)
44+
# model: "claude-opus-4-1-20250805"
45+
46+
# Optional: Customize the trigger phrase (default: @claude)
47+
# trigger_phrase: "/claude"
48+
49+
# Optional: Trigger when specific user is assigned to an issue
50+
# assignee_trigger: "claude-bot"
51+
52+
# Optional: Allow Claude to run specific commands
53+
# allowed_tools: "Bash(go test),Bash(go build),Bash(go vet),Bash(go fmt)"
54+
55+
# Optional: Add custom instructions for Claude to customize its behavior for your project
56+
# custom_instructions: |
57+
# Follow Go coding standards
58+
# Ensure all new code has tests
59+
# Run go fmt before committing
60+
61+
# Optional: Custom environment variables for Claude
62+
# claude_env: |
63+
# GO_ENV: test

.github/workflows/go-packages.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: go-packages
2+
3+
on:
4+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-when-a-pull-request-is-approved
5+
# pull_request:
6+
# types:
7+
# - review_requested
8+
# branches:
9+
# - main
10+
push:
11+
branches:
12+
- main
13+
tags:
14+
- "v[0-9]+*"
15+
workflow_dispatch:
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # for tags
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v4
29+
with:
30+
go-version: '1.22'
31+
cache: true
32+
33+
- name: Download dependencies
34+
run: go mod download
35+
36+
- name: Verify dependencies
37+
run: go mod verify
38+
39+
- name: Run go vet
40+
run: go vet ./...
41+
42+
- name: Run tests
43+
run: go test -v -race -coverprofile=coverage.out ./...
44+
env:
45+
WAVESPEED_API_KEY: ${{ secrets.WAVESPEED_API_KEY }}
46+
47+
- name: Build
48+
run: go build -v ./...
49+
50+
- name: Check coverage
51+
run: go tool cover -func=coverage.out
52+
53+
# publish to GitHub Release
54+
gh_release:
55+
name: gh_release
56+
needs: build
57+
runs-on: ubuntu-latest
58+
permissions: write-all
59+
60+
timeout-minutes: 60
61+
defaults:
62+
run:
63+
shell: bash
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
# create nightly release if it's a push to main
70+
- if: github.repository == 'WaveSpeedAI/wavespeed-go' && github.event_name == 'push' && github.ref == 'refs/heads/main'
71+
name: Nightly Release
72+
uses: andelf/nightly-release@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
tag_name: nightly
77+
name: 'Nightly Release $$'
78+
prerelease: true
79+
body: |
80+
Nightly build from main branch.
81+
82+
## Installation
83+
```bash
84+
go get github.com/WaveSpeedAI/wavespeed-go@nightly
85+
```
86+
87+
# create release if it's a tag like vx.y.z
88+
- if: github.repository == 'WaveSpeedAI/wavespeed-go' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
89+
name: Release
90+
uses: softprops/action-gh-release@v1
91+
with:
92+
name: Release ${{ github.ref_name }}
93+
body: |
94+
Release ${{ github.ref_name }}
95+
96+
## Installation
97+
98+
```bash
99+
go get github.com/WaveSpeedAI/wavespeed-go@${{ github.ref_name }}
100+
```
101+
102+
## Changes
103+
104+
See commit history for changes in this release.

.github/workflows/pre-commit.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- "v[0-9]+*"
12+
workflow_dispatch:
13+
14+
jobs:
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
path: "."
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v4
24+
with:
25+
go-version: '1.22'
26+
cache: true
27+
28+
- name: Run gofmt
29+
run: |
30+
if [ -n "$(gofmt -l .)" ]; then
31+
echo "Go code is not formatted. Run 'gofmt -w .' to fix."
32+
gofmt -d .
33+
exit 1
34+
fi
35+
36+
- name: Run go vet
37+
run: go vet ./...
38+
39+
- name: Run go mod verify
40+
run: go mod verify
41+
42+
- name: Run go mod tidy check
43+
run: |
44+
go mod tidy
45+
if ! git diff --exit-code go.mod go.sum; then
46+
echo "go.mod or go.sum is not tidy. Run 'go mod tidy' to fix."
47+
exit 1
48+
fi

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)