Add comprehensive coding guidelines for GitHub Copilot to improve quality and consistency of AI-generated code. Instructions cover C++ and Python development with language-specific best practices, build system usage, and testing workflows. Following GitHub Copilot's standard layout with general instructions in .github/copilot-instructions.md and language-specific files in .github/instructions/ directory using *.instructions.md naming. No backport: This change is only for developers in master, so it doesn't need to be backported. Closes scylladb/scylladb#25374
3.3 KiB
3.3 KiB
ScyllaDB Development Instructions
Project Context
High-performance distributed NoSQL database. Core values: performance, correctness, readability.
Build System
Modern Build (configure.py + ninja)
# Configure (run once per mode, or when switching modes)
./configure.py --mode=<mode> # mode: dev, debug, release, sanitize
# Build everything
ninja <mode>-build # e.g., ninja dev-build
# Build Scylla binary only (sufficient for Python integration tests)
ninja build/<mode>/scylla
# Build specific test
ninja build/<mode>/test/boost/<test_name>
Running Tests
C++ Unit Tests
# Run all tests in a file
./test.py --mode=<mode> test/<suite>/<test_name>.cc
# Run a single test case from a file
./test.py --mode=<mode> test/<suite>/<test_name>.cc::<test_case_name>
# Examples
./test.py --mode=dev test/boost/memtable_test.cc
./test.py --mode=dev test/raft/raft_server_test.cc::test_check_abort_on_client_api
Important:
- Use full path with
.ccextension (e.g.,test/boost/test_name.cc, notboost/test_name) - To run a single test case, append
::<test_case_name>to the file path - If you encounter permission issues with cgroup metric gathering, add
--no-gather-metricsflag
Rebuilding Tests:
- test.py does NOT automatically rebuild when test source files are modified
- Many tests are part of composite binaries (e.g.,
combined_testsin test/boost contains multiple test files) - To find which binary contains a test, check
configure.pyin the repository root (primary source) ortest/<suite>/CMakeLists.txt - To rebuild a specific test binary:
ninja build/<mode>/test/<suite>/<binary_name> - Examples:
ninja build/dev/test/boost/combined_tests(contains group0_voter_calculator_test.cc and others)ninja build/dev/test/raft/replication_test(standalone Raft test)
Python Integration Tests
# Only requires Scylla binary (full build usually not needed)
ninja build/<mode>/scylla
# Run all tests in a file
./test.py --mode=<mode> <test_path>
# Run a single test case from a file
./test.py --mode=<mode> <test_path>::<test_function_name>
# Examples
./test.py --mode=dev alternator/
./test.py --mode=dev cluster/test_raft_voters::test_raft_limited_voters_retain_coordinator
# Optional flags
./test.py --mode=dev cluster/test_raft_no_quorum -v # Verbose output
./test.py --mode=dev cluster/test_raft_no_quorum --repeat 5 # Repeat test 5 times
Important:
- Use path without
.pyextension (e.g.,cluster/test_raft_no_quorum, notcluster/test_raft_no_quorum.py) - To run a single test case, append
::<test_function_name>to the file path - Add
-vfor verbose output - Add
--repeat <num>to repeat a test multiple times - After modifying C++ source files, only rebuild the Scylla binary for Python tests - building the entire repository is unnecessary
Code Philosophy
- Performance matters in hot paths (data read/write, inner loops)
- Self-documenting code through clear naming
- Comments explain "why", not "what"
- Prefer standard library over custom implementations
- Strive for simplicity and clarity, add complexity only when clearly justified
- Question requests: don't blindly implement requests - evaluate trade-offs, identify issues, and suggest better alternatives when appropriate
- Consider different approaches, weigh pros and cons, and recommend the best fit for the specific context