|
| 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. |
0 commit comments