summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2025-10-02 12:50:51 +0700
committerGitHub <[email protected]>2025-10-02 12:50:51 +0700
commit3d7117723beeeb4230a1e734e9f3713cef4b7cf3 (patch)
treec6ce9d11fce3227d0d14510abd5d907595d69e21
parent43e6c9dda7be1a38236989138e1e5693a50fb5ca (diff)
parent3c108b233f023d51eea237ed2eb5f48c312c47f4 (diff)
Merge pull request #3272 from hathach/add-claude-github-actions-1759342361886
Add Claude Code GitHub Workflow
-rw-r--r--.github/workflows/claude-code-review.yml56
-rw-r--r--.github/workflows/claude.yml49
-rw-r--r--CLAUDE.md69
-rw-r--r--README.rst6
4 files changed, 176 insertions, 4 deletions
diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml
new file mode 100644
index 000000000..d0d58be9c
--- /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:
+ # - "src/**/*.ts"
+ # - "src/**/*.tsx"
+ # - "src/**/*.js"
+ # - "src/**/*.jsx"
+
+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
+
+ 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:
+ anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+ 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:*)"'
diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml
new file mode 100644
index 000000000..a6ea7e396
--- /dev/null
+++ b/.github/workflows/claude.yml
@@ -0,0 +1,49 @@
+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
+ 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:
+ anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+
+ # 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:*)'
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 000000000..9cfe29aae
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,69 @@
+# TinyUSB Development Guide
+
+## Build Commands
+
+### CMake Build System (Preferred)
+CMake with Ninja is the preferred build method for TinyUSB development.
+
+- Build example with Ninja:
+ ```bash
+ cd examples/device/cdc_msc
+ mkdir build && cd build
+ cmake -G Ninja -DBOARD=raspberry_pi_pico ..
+ ninja
+ ```
+- Debug build: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DCMAKE_BUILD_TYPE=Debug ..`
+- With logging: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 ..`
+- With RTT logger: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 -DLOGGER=rtt ..`
+- Flash with JLink: `ninja cdc_msc-jlink`
+- Flash with OpenOCD: `ninja cdc_msc-openocd`
+- Generate UF2: `ninja cdc_msc-uf2`
+- List all targets: `ninja -t targets`
+
+### Make Build System (Alternative)
+- Build example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico all`
+- For specific example: `cd examples/{device|host|dual}/{example_name} && make BOARD=raspberry_pi_pico all`
+- Flash with JLink: `make BOARD=raspberry_pi_pico flash-jlink`
+- Flash with OpenOCD: `make BOARD=raspberry_pi_pico flash-openocd`
+- Debug build: `make BOARD=raspberry_pi_pico DEBUG=1 all`
+- With logging: `make BOARD=raspberry_pi_pico LOG=2 all`
+- With RTT logger: `make BOARD=raspberry_pi_pico LOG=2 LOGGER=rtt all`
+- Generate UF2: `make BOARD=raspberry_pi_pico all uf2`
+
+### Additional Options
+- Select RootHub port: `RHPORT_DEVICE=1` (make) or `-DRHPORT_DEVICE=1` (cmake)
+- Set port speed: `RHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (make) or `-DRHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (cmake)
+
+### Dependencies
+- Get dependencies: `python tools/get_deps.py rp2040`
+- Or from example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico get-deps`
+
+### Testing
+- Run unit tests: `cd test/unit-test && ceedling test:all`
+- Run specific test: `cd test/unit-test && ceedling test:test_fifo`
+
+### Pre-commit Hooks
+Before building, it's recommended to run pre-commit to ensure code quality:
+- Run pre-commit on all files: `pre-commit run --all-files`
+- Run pre-commit on staged files: `pre-commit run`
+- Install pre-commit hook: `pre-commit install`
+
+## Code Style Guidelines
+- Use C99 standard
+- Memory-safe: no dynamic allocation
+- Thread-safe: defer all interrupt events to non-ISR task functions
+- 2-space indentation, no tabs
+- Use snake_case for variables/functions
+- Use UPPER_CASE for macros and constants
+- Follow existing variable naming patterns in files you're modifying
+- Include proper header comments with MIT license
+- Add descriptive comments for non-obvious functions
+- When including headers, group in order: C stdlib, tusb common, drivers, classes
+- Always check return values from functions that can fail
+- Use TU_ASSERT() for error checking with return statements
+
+## Project Structure
+- src/: Core TinyUSB stack code
+- hw/: Board support packages and MCU drivers
+- examples/: Reference examples for device/host/dual
+- test/: Unit tests and hardware integration tests
diff --git a/README.rst b/README.rst
index 081493d4b..66fbcaa10 100644
--- a/README.rst
+++ b/README.rst
@@ -115,7 +115,7 @@ Supported CPUs
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
| | F402_F405 | ✔ | ✔ | ✔ | dwc2 | F405 is HS |
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
-| Brigetek | FT90x | ✔ | | ✔ | ft9xx | 1-dir ep |
+| Bridgetek | FT90x | ✔ | | ✔ | ft9xx | 1-dir ep |
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
| Broadcom | BCM2711, BCM2837 | ✔ | | ✔ | dwc2 | |
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
@@ -147,7 +147,7 @@ Supported CPUs
| | +-----------------------+--------+------+-----------+------------------------+-------------------+
| | | 32mz | ✔ | | | pic32mz | musb variant |
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
-| Mind Montion | mm32 | ✔ | | ✖ | mm32f327x_otg | ci_fs variant |
+| MindMotion | mm32 | ✔ | | ✖ | mm32f327x_otg | ci_fs variant |
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
| NordicSemi | nRF 52833, 52840, 5340 | ✔ | ✖ | ✖ | nrf5x | only ep8 is ISO |
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
@@ -202,8 +202,6 @@ Supported CPUs
| | C0, G0, H5 | ✔ | | ✖ | stm32_fsdev | |
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
| | G4 | ✔ | ✖ | ✖ | stm32_fsdev | |
-| +-----------------------------+--------+------+-----------+------------------------+-------------------+
-| | L0, L1 | ✔ | ✖ | ✖ | stm32_fsdev | |
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
| | L4 | 4x2, 4x3 | ✔ | ✖ | ✖ | stm32_fsdev | |
| | +------------------------+--------+------+-----------+------------------------+-------------------+