Skip to content

Commit d5576b2

Browse files
committed
docs(contributing): improve contributing guide
1 parent 850a493 commit d5576b2

File tree

1 file changed

+118
-2
lines changed

1 file changed

+118
-2
lines changed

docs/contributing.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,67 @@ Guide for contributing to BalatroBot development.
1919
- **Steamodded** (v1.0.0-beta-1221a+) - [Installation](https://github.com/Steamopollys/Steamodded)
2020
- **DebugPlus** (v1.5.1+) (optional) - Required for test endpoints
2121

22+
## Development Environment Setup
23+
24+
### direnv (Recommended)
25+
26+
We use [direnv](https://direnv.net/) to automatically manage environment variables and virtual environment activation. When you `cd` into the project directory, direnv automatically loads settings from `.envrc`.
27+
28+
!!! warning "Contains Secrets"
29+
30+
The `.envrc` file may contain API keys and tokens. **Never commit this file**.
31+
32+
**Example `.envrc` configuration:**
33+
34+
```bash
35+
# Load the virtual environment
36+
source .venv/bin/activate
37+
38+
# Python-specific variables
39+
export PYTHONUNBUFFERED="1"
40+
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
41+
export PYTHONPATH="${PWD}/tests:${PYTHONPATH}"
42+
43+
# BALATROBOT env vars
44+
export BALATROBOT_FAST=1
45+
export BALATROBOT_DEBUG=1
46+
export BALATROBOT_LOVE_PATH='/path/to/Balatro/love'
47+
export BALATROBOT_LOVELY_PATH='/path/to/liblovely.dylib'
48+
export BALATROBOT_PARALLEL=1
49+
export BALATROBOT_RENDER_ON_API=0
50+
export BALATROBOT_HEADLESS=1
51+
export BALATROBOT_AUDIO=0
52+
```
53+
54+
**Setup:** Install [direnv](https://direnv.net/), then create `.envrc` in the project root with the above configuration, updating paths for your system.
55+
56+
### Lua LSP Configuration
57+
58+
The `.luarc.json` file should be placed at the root of the balatrobot repository. It configures the Lua Language Server for IDE support (autocomplete, diagnostics, type checking).
59+
60+
!!! info "Update Library Paths"
61+
62+
You **must** update the `workspace.library` paths in `.luarc.json` to match your system:
63+
64+
- Steamodded LSP definitions: `path/to/Mods/smods/lsp_def`
65+
- Love2D library: `path/to/love2d/library` (clone locally: [LuaCATS/love2d](https://github.com/LuaCATS/love2d))
66+
- LuaSocket library: `path/to/luasocket/library` (clone locally: [LuaCATS/luasocket](https://github.com/LuaCATS/luasocket))
67+
68+
**Example `.luarc.json`:**
69+
70+
```json
71+
{
72+
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
73+
"workspace.library": [
74+
"/path/to/Balatro/Mods/smods/lsp_def",
75+
"/path/to/love2d/library",
76+
"/path/to/luasocket/library"
77+
],
78+
"diagnostics.disable": ["lowercase-global"],
79+
"diagnostics.globals": ["G"]
80+
}
81+
```
82+
2283
## Development Setup
2384

2485
### 1. Clone the Repository
@@ -78,7 +139,7 @@ For detailed CLI options, see the [CLI Reference](cli.md).
78139

79140
### 5. Running Tests
80141

81-
Tests use Python + pytest to communicate with the Lua API.
142+
Tests use Python + pytest to communicate with the Lua API. You don't need to have balatrobot running—the tests automatically start the required Balatro instances.
82143

83144
!!! info "Separate Lua and CLI test suites"
84145

@@ -111,6 +172,26 @@ pytest tests/lua -m integration
111172
pytest tests/lua -m "not integration"
112173
```
113174

175+
## Available Make Commands
176+
177+
The project includes a Makefile with convenient targets for common development tasks. Run `make help` to see all available commands.
178+
179+
```bash
180+
make help # Show all available commands with descriptions
181+
make install # Install all dependencies (dev + test groups)
182+
make lint # Run ruff linter with auto-fix
183+
make format # Format code (Python, Markdown, Lua)
184+
make typecheck # Run type checker (ty)
185+
make quality # Run all code quality checks
186+
make fixtures # Generate test fixtures (starts Balatro)
187+
make test # Run all tests (CLI + Lua suites)
188+
make all # Run quality checks + tests
189+
```
190+
191+
!!! note "Test Fixtures"
192+
193+
The `make fixtures` command is only required if you need to explicitly generate fixtures. When running tests, missing fixtures are automatically generated if required.
194+
114195
## Code Structure
115196

116197
```
@@ -120,6 +201,7 @@ src/lua/
120201
│ ├── dispatcher.lua # Request routing
121202
│ └── validator.lua # Schema validation
122203
├── endpoints/ # API endpoints
204+
│ ├── tests/ # Test-only endpoints
123205
│ ├── health.lua
124206
│ ├── gamestate.lua
125207
│ ├── play.lua
@@ -163,10 +245,44 @@ return {
163245

164246
- Update `docs/api.md` with the new method
165247

248+
## Code Quality
249+
250+
Before committing, always run:
251+
252+
```bash
253+
make quality # Runs lint, typecheck, and format
254+
```
255+
256+
**Test markers:**
257+
258+
- `@pytest.mark.dev`: Run only tests under development with `-m dev`
259+
- `@pytest.mark.integration`: Tests that start Balatro (skip with `-m "not integration"`)
260+
166261
## Pull Request Guidelines
167262

168263
1. **One feature per PR** - Keep changes focused
169264
2. **Add tests** - New endpoints need test coverage
170265
3. **Update docs** - Update api.md and openrpc.json for API changes
171-
4. **Follow conventions** - Match existing code style
266+
4. **Run code quality checks** - Execute `make quality` before committing (see [Code Quality Tools](#code-quality-tools))
172267
5. **Test locally** - Ensure both `pytest -n 6 tests/lua` and `pytest tests/cli` pass
268+
269+
## CI/CD Pipeline
270+
271+
The project uses GitHub Actions for continuous integration and deployment.
272+
273+
### Workflows
274+
275+
- **code_quality.yml**: Runs linting, type checking, and formatting on every PR (equivalent to `make quality`)
276+
- **deploy_docs.yml**: Deploys documentation to GitHub Pages when a release is published
277+
- **release_please.yml**: Automated version management and changelog generation
278+
- **release_pypi.yml**: Publishes the package to PyPI on release
279+
280+
### For Contributors
281+
282+
You don't need to worry about most CI/CD workflows—just ensure your PR passes the **code quality checks**:
283+
284+
```bash
285+
make quality # Run this before pushing
286+
```
287+
288+
If CI fails on your PR, check the workflow logs on GitHub for details. Most issues can be fixed by running `make quality` locally.

0 commit comments

Comments
 (0)