Skip to content

Commit b46e761

Browse files
committed
sync: update from source repos
0 parents  commit b46e761

746 files changed

Lines changed: 479782 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
name: contributing
3+
description: >
4+
Guides the developer workflow for contributing to Race Condition. Use when
5+
setting up pre-commit hooks, running tests before a PR, understanding code
6+
style requirements, or preparing a contribution.
7+
---
8+
9+
# Contributing to Race Condition
10+
11+
## First-Time Setup
12+
13+
### Install pre-commit hooks
14+
15+
```bash
16+
pip install pre-commit
17+
pre-commit install
18+
```
19+
20+
This installs hooks that run automatically on `git commit`:
21+
- License header checks (Apache 2.0)
22+
- YAML and JSON syntax validation
23+
- Go vet
24+
- Trailing whitespace and EOF fixes
25+
26+
### Verify your environment
27+
28+
```bash
29+
make check-prereqs # Verify Go, Python, uv, Node.js, Docker
30+
make build # Build Go services (runs proto generation first)
31+
make test # Run all tests
32+
```
33+
34+
If all tests pass, you're ready to contribute.
35+
36+
## Before Every PR
37+
38+
Run these checks. They match what CI runs on GitHub Actions.
39+
40+
### 1. Format code
41+
42+
```bash
43+
make fmt
44+
```
45+
46+
This runs `gofmt -w .` for Go and `uv run ruff format agents/` for Python.
47+
48+
### 2. Lint
49+
50+
```bash
51+
make lint
52+
```
53+
54+
Runs all linters:
55+
- `golangci-lint run ./...` (Go)
56+
- `uv run ruff check agents/` (Python)
57+
- `npx pyright agents/` (Python type checking)
58+
- Pre-commit hooks for YAML, JSON, Dockerfile validation
59+
60+
### 3. Run tests
61+
62+
```bash
63+
make test
64+
```
65+
66+
Runs Go tests, Python tests (excluding slow/eval), and web UI tests. Python
67+
tests run without real GCP credentials -- `conftest.py` mocks them.
68+
69+
### 4. Check coverage
70+
71+
```bash
72+
make coverage
73+
```
74+
75+
Generates Go and Python coverage reports. Python has a 60% minimum threshold.
76+
77+
## Code Style
78+
79+
### Go
80+
81+
- Format with `gofmt` (enforced by `make fmt`)
82+
- Lint with `golangci-lint`
83+
- Tests use `testify` for assertions and `miniredis` for Redis mocking
84+
- Integration tests are tagged with `Integration` or `Relay` in test names
85+
86+
### Python
87+
88+
- Format with `ruff format`
89+
- Lint with `ruff check`
90+
- Type check with `pyright`
91+
- Tests use `pytest` with `pytest-asyncio` for async tests
92+
- Agent entry point must be `root_agent` in `agent.py`
93+
- Use `google-genai` SDK (not the deprecated `google-generativeai`)
94+
95+
### License headers
96+
97+
All source files must have Apache 2.0 license headers (year 2026, Google LLC).
98+
The pre-commit hook checks this. If missing, add:
99+
100+
```python
101+
# Copyright 2026 Google LLC
102+
#
103+
# Licensed under the Apache License, Version 2.0 (the "License");
104+
# ...
105+
```
106+
107+
## PR Process
108+
109+
1. Fork the repo on GitHub.
110+
2. Branch from `main` with a descriptive name.
111+
3. Make your changes following the code style above.
112+
4. Run `make test` and `make lint`. Fix any failures.
113+
5. Commit with clear messages describing what changed and why.
114+
6. Push and open a PR against `main`.
115+
7. Sign the CLA when prompted (first-time contributors only).
116+
117+
PRs are squash-merged. Write a clear PR title and description.
118+
119+
## Test Architecture
120+
121+
| Command | What it runs | Needs infra? |
122+
|---|---|---|
123+
| `make test-go` | `go test ./... -count=1` | No (uses miniredis) |
124+
| `make test-py` | `pytest agents/ -x -q -m "not slow"` | No (mocks GCP) |
125+
| `make test-web` | `npm test` in admin-dash + tester | No |
126+
| `make eval` | Agent evaluations with real Gemini API | Yes (costs money) |
127+
| `make verify` | lint + unit tests + coverage | No |
128+
| `make verify-full` | verify + integration tests | Yes (needs Redis/Docker) |
129+
130+
## Quick Reference
131+
132+
| Task | Command |
133+
|---|---|
134+
| Format all code | `make fmt` |
135+
| Lint all code | `make lint` |
136+
| Run all tests | `make test` |
137+
| Run only Go tests | `make test-go` |
138+
| Run only Python tests | `make test-py` |
139+
| Generate coverage | `make coverage` |
140+
| Build everything | `make build` |
141+
| Regenerate protobuf | `make proto` |
142+
143+
See [CONTRIBUTING.md](../../../CONTRIBUTING.md) for the full contributing
144+
guide including the CLA process.

0 commit comments

Comments
 (0)