Skip to content

Commit 3d71177

Browse files
authored
Merge pull request #3272 from hathach/add-claude-github-actions-1759342361886
Add Claude Code GitHub Workflow
2 parents 43e6c9d + 3c108b2 commit 3d71177

File tree

4 files changed

+176
-4
lines changed

4 files changed

+176
-4
lines changed
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+
# - "src/**/*.ts"
9+
# - "src/**/*.tsx"
10+
# - "src/**/*.js"
11+
# - "src/**/*.jsx"
12+
13+
jobs:
14+
claude-review:
15+
# Optional: Filter by PR author
16+
# if: |
17+
# github.event.pull_request.user.login == 'external-contributor' ||
18+
# github.event.pull_request.user.login == 'new-developer' ||
19+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20+
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
pull-requests: read
25+
issues: read
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 1
33+
34+
- name: Run Claude Code Review
35+
id: claude-review
36+
uses: anthropics/claude-code-action@v1
37+
with:
38+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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@v1
36+
with:
37+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
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: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44+
# prompt: 'Update the pull request description to include a summary of changes.'
45+
46+
# Optional: Add claude_args to customize behavior and configuration
47+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
49+
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'

CLAUDE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# TinyUSB Development Guide
2+
3+
## Build Commands
4+
5+
### CMake Build System (Preferred)
6+
CMake with Ninja is the preferred build method for TinyUSB development.
7+
8+
- Build example with Ninja:
9+
```bash
10+
cd examples/device/cdc_msc
11+
mkdir build && cd build
12+
cmake -G Ninja -DBOARD=raspberry_pi_pico ..
13+
ninja
14+
```
15+
- Debug build: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DCMAKE_BUILD_TYPE=Debug ..`
16+
- With logging: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 ..`
17+
- With RTT logger: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 -DLOGGER=rtt ..`
18+
- Flash with JLink: `ninja cdc_msc-jlink`
19+
- Flash with OpenOCD: `ninja cdc_msc-openocd`
20+
- Generate UF2: `ninja cdc_msc-uf2`
21+
- List all targets: `ninja -t targets`
22+
23+
### Make Build System (Alternative)
24+
- Build example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico all`
25+
- For specific example: `cd examples/{device|host|dual}/{example_name} && make BOARD=raspberry_pi_pico all`
26+
- Flash with JLink: `make BOARD=raspberry_pi_pico flash-jlink`
27+
- Flash with OpenOCD: `make BOARD=raspberry_pi_pico flash-openocd`
28+
- Debug build: `make BOARD=raspberry_pi_pico DEBUG=1 all`
29+
- With logging: `make BOARD=raspberry_pi_pico LOG=2 all`
30+
- With RTT logger: `make BOARD=raspberry_pi_pico LOG=2 LOGGER=rtt all`
31+
- Generate UF2: `make BOARD=raspberry_pi_pico all uf2`
32+
33+
### Additional Options
34+
- Select RootHub port: `RHPORT_DEVICE=1` (make) or `-DRHPORT_DEVICE=1` (cmake)
35+
- Set port speed: `RHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (make) or `-DRHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (cmake)
36+
37+
### Dependencies
38+
- Get dependencies: `python tools/get_deps.py rp2040`
39+
- Or from example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico get-deps`
40+
41+
### Testing
42+
- Run unit tests: `cd test/unit-test && ceedling test:all`
43+
- Run specific test: `cd test/unit-test && ceedling test:test_fifo`
44+
45+
### Pre-commit Hooks
46+
Before building, it's recommended to run pre-commit to ensure code quality:
47+
- Run pre-commit on all files: `pre-commit run --all-files`
48+
- Run pre-commit on staged files: `pre-commit run`
49+
- Install pre-commit hook: `pre-commit install`
50+
51+
## Code Style Guidelines
52+
- Use C99 standard
53+
- Memory-safe: no dynamic allocation
54+
- Thread-safe: defer all interrupt events to non-ISR task functions
55+
- 2-space indentation, no tabs
56+
- Use snake_case for variables/functions
57+
- Use UPPER_CASE for macros and constants
58+
- Follow existing variable naming patterns in files you're modifying
59+
- Include proper header comments with MIT license
60+
- Add descriptive comments for non-obvious functions
61+
- When including headers, group in order: C stdlib, tusb common, drivers, classes
62+
- Always check return values from functions that can fail
63+
- Use TU_ASSERT() for error checking with return statements
64+
65+
## Project Structure
66+
- src/: Core TinyUSB stack code
67+
- hw/: Board support packages and MCU drivers
68+
- examples/: Reference examples for device/host/dual
69+
- test/: Unit tests and hardware integration tests

README.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Supported CPUs
115115
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
116116
| | F402_F405 |||| dwc2 | F405 is HS |
117117
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
118-
| Brigetek | FT90x || || ft9xx | 1-dir ep |
118+
| Bridgetek | FT90x || || ft9xx | 1-dir ep |
119119
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
120120
| Broadcom | BCM2711, BCM2837 || || dwc2 | |
121121
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
@@ -147,7 +147,7 @@ Supported CPUs
147147
| | +-----------------------+--------+------+-----------+------------------------+-------------------+
148148
| | | 32mz || | | pic32mz | musb variant |
149149
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
150-
| Mind Montion | mm32 || || mm32f327x_otg | ci_fs variant |
150+
| MindMotion | mm32 || || mm32f327x_otg | ci_fs variant |
151151
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
152152
| NordicSemi | nRF 52833, 52840, 5340 |||| nrf5x | only ep8 is ISO |
153153
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
@@ -202,8 +202,6 @@ Supported CPUs
202202
| | C0, G0, H5 || || stm32_fsdev | |
203203
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
204204
| | G4 |||| stm32_fsdev | |
205-
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
206-
| | L0, L1 |||| stm32_fsdev | |
207205
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
208206
| | L4 | 4x2, 4x3 |||| stm32_fsdev | |
209207
| | +------------------------+--------+------+-----------+------------------------+-------------------+

0 commit comments

Comments
 (0)