check / check (push) Canceled after 0s
Rewrite the agent rules from scratch, as a newcomer would read them, with one idea per sentence and every file name and command in backticks. Drop the rule that models embed `models.Base`, which no package in the repository has, and the statement that tests share their package: nearly every test is in an external test package with an `export_test.go` beside it. State the branch workflow in use: pull requests target `next` and only the owner merges `next` into `main`. Record the three snake_case JSON tags the HTTP API keeps. Part of #190. Model: fable-5-1
2.6 KiB
2.6 KiB
Rules for coding agents
Rules for coding agents working in this repository. CONVENTIONS.md defines the
architecture and REPO_POLICIES.md the repository standards. Both are copies of
shared documents and are not edited here.
Before every commit
- Run
make fmt. - Run
make check. It runs the tests and the linter in Docker, then the format check. All three must pass with no findings.
Never run go test, golangci-lint or gofmt directly. The make targets
hold the flags and the Docker setup.
Branches and pull requests
- Never commit to
mainornextdirectly. Every change is a pull request from a feature branch intonext. - Only the owner merges
nextintomain. - A pull request that closes an issue has the title
Description (closes #N). - One logical change per commit.
- Commit messages are in the imperative mood and short.
Code style
- Follow
CONVENTIONS.md. - Every package has a package doc comment. Every exported type, function, method and variable has a doc comment.
- JSON tags are camelCase. The HTTP API's
last_id,pow_tokenandhashcash_bitsstay as they are, each with a//nolint:tagliatellecomment. - No magic numbers. Use named constants.
- No inline error handling such as
if err := f(); err != nil. Assign the error on its own line, then test it. - A blank line before every
return. - A blank line between the embedded fields of a struct and its other fields.
- Every blank import has a comment saying why it is there.
Architecture
- Dependency injection uses Uber
fx. Every component is anfxprovider, wired together incmd/neoircd/main.go. - Application packages live under
internal/, one package per concern.pkg/ircholds the IRC command names and numeric reply codes. - A handler method returns an
http.HandlerFunc. - A request struct is defined inside the handler that decodes it.
- Database access goes through the methods of
db.Database. - The database schema lives in
internal/db/schema/and is embedded withgo:embed. - The database is SQLite, through the pure Go driver
modernc.org/sqlite.
Testing
- Prefer table-driven tests.
- Use
testing.Thelpers, not assertion libraries. - A test file lives next to the code it tests and ends in
_test.go. - Tests are in the package's external test package, such as
handlers_test. Anexport_test.gofile in the package itself exposes what the tests need.
Dependencies
- The required libraries are listed in
CONVENTIONS.md§1. - No new dependency without a reason given in the pull request.
- Prefer pure Go. No cgo.