Skip to content

Commit f06fee3

Browse files
Add contributing guide (#179)
1 parent 87a8d20 commit f06fee3

File tree

5 files changed

+218
-4
lines changed

5 files changed

+218
-4
lines changed

.github/workflows/claude-code-review.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Claude Code Review
22

33
on:
44
pull_request:
5-
types: [opened, synchronize]
5+
types: [opened, synchronize, labeled]
66
# Optional: Only run on specific file changes
77
# paths:
88
# - "src/**/*.ts"
@@ -13,7 +13,12 @@ on:
1313
jobs:
1414
claude-review:
1515
# Skip review for automated "Version Packages" PRs created by changesets
16-
if: github.event.pull_request.title != 'Version Packages'
16+
# For external PRs: requires 'ci' label
17+
# For internal PRs: runs automatically
18+
if: |
19+
github.event.pull_request.title != 'Version Packages' &&
20+
(github.event.pull_request.head.repo.full_name == github.repository ||
21+
contains(github.event.pull_request.labels.*.name, 'ci'))
1722
1823
runs-on: ubuntu-latest
1924
permissions:

.github/workflows/pkg-pr-new.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ permissions:
66

77
on:
88
pull_request:
9-
types: [opened, synchronize, reopened]
9+
types: [opened, synchronize, reopened, labeled]
1010
paths:
1111
- '**'
1212
- '!**/*.md'
1313
- '!.changeset/**'
1414

1515
jobs:
1616
publish-preview:
17+
# For external PRs: requires 'ci' label
18+
# For internal PRs: runs automatically
19+
if: |
20+
github.event.pull_request.head.repo.full_name == github.repository ||
21+
contains(github.event.pull_request.labels.*.name, 'ci')
1722
runs-on: ubuntu-latest
1823
timeout-minutes: 15
1924

.github/workflows/pullrequest.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ permissions:
55

66
on:
77
pull_request:
8+
types: [opened, synchronize, reopened, labeled]
89

910
concurrency:
1011
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -71,8 +72,13 @@ jobs:
7172
run: npm run test -w @repo/sandbox-container
7273

7374
# E2E tests against deployed worker
75+
# For external PRs: requires 'ci' label
76+
# For internal PRs: runs automatically
7477
e2e-tests:
7578
needs: unit-tests
79+
if: |
80+
github.event.pull_request.head.repo.full_name == github.repository ||
81+
contains(github.event.pull_request.labels.*.name, 'ci')
7682
timeout-minutes: 30
7783
runs-on: ubuntu-latest
7884
steps:

CONTRIBUTING.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# Contributing to Cloudflare Sandbox SDK
2+
3+
Thank you for your interest in contributing to the Cloudflare Sandbox SDK! This guide will help you get started.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
- Node.js 24+
10+
- Bun (latest)
11+
- Docker (for E2E tests)
12+
- Git
13+
14+
### Setup
15+
16+
1. Fork the repository to your GitHub account
17+
2. Clone your fork:
18+
```bash
19+
git clone https://github.com/YOUR-USERNAME/sandbox-sdk.git
20+
cd sandbox-sdk
21+
```
22+
23+
3. Install dependencies:
24+
```bash
25+
npm install
26+
```
27+
28+
4. Build the packages:
29+
```bash
30+
npm run build
31+
```
32+
33+
5. Run tests:
34+
```bash
35+
npm test
36+
```
37+
38+
## Development Workflow
39+
40+
### Making Changes
41+
42+
1. Create a new branch for your changes:
43+
```bash
44+
git checkout -b feat/your-feature-name
45+
# or
46+
git checkout -b fix/your-bug-fix
47+
```
48+
49+
2. Make your changes following our coding standards (see CLAUDE.md)
50+
51+
3. Run code quality checks:
52+
```bash
53+
npm run check # Linting + type checking
54+
npm run fix # Auto-fix linting issues
55+
```
56+
57+
4. Run tests:
58+
```bash
59+
npm test # Unit tests
60+
npm run test:e2e # E2E tests (requires Docker)
61+
```
62+
63+
### Commit Message Guidelines
64+
65+
Follow the [7 rules for great commit messages](https://cbea.ms/git-commit/):
66+
67+
1. Separate subject from body with a blank line
68+
2. Limit the subject line to 50 characters
69+
3. Capitalize the subject line
70+
4. Do not end the subject line with a period
71+
5. Use the imperative mood ("Add feature" not "Added feature")
72+
6. Wrap the body at 72 characters
73+
7. Use the body to explain what and why vs. how
74+
75+
Example:
76+
```
77+
Add session isolation for concurrent executions
78+
79+
Previously, multiple concurrent exec() calls would interfere with each
80+
other's working directories and environment variables. This adds proper
81+
session management to isolate execution contexts.
82+
```
83+
84+
### Creating a Changeset
85+
86+
Before submitting a PR, create a changeset if your change modifies any published packages:
87+
88+
```bash
89+
npx changeset
90+
```
91+
92+
This will interactively guide you through:
93+
1. Selecting which packages to include
94+
2. Choosing the semantic version bump (`patch`, `minor`, or `major`)
95+
3. Writing a description of your changes
96+
97+
Use semantic versioning:
98+
- `patch`: Bug fixes, minor improvements
99+
- `minor`: New features, non-breaking changes
100+
- `major`: Breaking changes
101+
102+
The changeset bot will comment on your PR if a changeset is needed.
103+
104+
## Submitting a Pull Request
105+
106+
1. Push your branch to your fork:
107+
```bash
108+
git push origin feat/your-feature-name
109+
```
110+
111+
2. Open a pull request from your fork to `cloudflare/sandbox-sdk:main`
112+
113+
3. Fill out the PR template with:
114+
- Description of your changes
115+
- Motivation and context
116+
- How you tested the changes
117+
- Screenshots (if applicable)
118+
119+
### Review Process
120+
121+
A maintainer will review your PR and may:
122+
- Request changes
123+
- Ask questions
124+
- Suggest improvements
125+
- Approve and merge
126+
127+
Please be patient and responsive to feedback. We aim to review PRs within a few days.
128+
129+
## Code Style
130+
131+
We use Biome for linting and formatting. Key guidelines:
132+
133+
- Use TypeScript for all code
134+
- Avoid `any` type - define proper types
135+
- Write concise, readable code
136+
- Add comments for complex logic
137+
- Follow patterns in existing code
138+
139+
## Testing
140+
141+
### Unit Tests
142+
143+
Located in `packages/*/tests/`:
144+
- Test individual components in isolation
145+
- Mock external dependencies
146+
- Fast feedback loop
147+
148+
Run with: `npm test`
149+
150+
### E2E Tests
151+
152+
Located in `tests/e2e/`:
153+
- Test full workflows against real Workers and containers
154+
- Require Docker
155+
- Slower but comprehensive
156+
157+
Run with: `npm run test:e2e`
158+
159+
You can also run specific test files or individual tests:
160+
161+
```bash
162+
# Run a single E2E test file
163+
npm run test:e2e -- -- tests/e2e/process-lifecycle-workflow.test.ts
164+
165+
# Run a specific test within a file
166+
npm run test:e2e -- -- tests/e2e/git-clone-workflow.test.ts -t 'should handle cloning to default directory'
167+
```
168+
169+
### Writing Tests
170+
171+
- Write tests for new features
172+
- Add regression tests for bug fixes
173+
- Ensure tests are deterministic (no flaky tests)
174+
- Use descriptive test names
175+
176+
## Documentation
177+
178+
- Update README.md if you change public APIs
179+
- Add JSDoc comments to public functions
180+
- Update CLAUDE.md if you change architecture or conventions
181+
182+
## Questions?
183+
184+
- Open an issue for bug reports or feature requests
185+
- Start a discussion for questions or ideas
186+
- Check existing issues and discussions first
187+
188+
## License
189+
190+
By contributing, you agree that your contributions will be licensed under the MIT License.

packages/sandbox/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,17 @@ export default {
116116
- **Preview URLs** - Expose services with public URLs
117117
- **Git Integration** - Clone repositories directly
118118

119+
## Contributing
120+
121+
We welcome contributions from the community! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on:
122+
123+
- Setting up your development environment
124+
- Creating pull requests
125+
- Code style and testing requirements
126+
119127
## Development
120128

121-
This repository contains the SDK source code. To contribute:
129+
This repository contains the SDK source code. Quick start:
122130

123131
```bash
124132
# Clone the repo

0 commit comments

Comments
 (0)