Skip to content

Commit 5a78616

Browse files
authored
DM: add AGENTS.md contributor guide (pingcap#12550)
close pingcap#12549
1 parent d16456b commit 5a78616

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

AGENTS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
This guide targets DM contributions in the TiFlow monorepo. Core DM code lives in `dm/`, shared libraries commonly touched by DM live in `pkg/`, and DM binaries are launched from `cmd/dm-master`, `cmd/dm-worker`, `cmd/dm-ctl`, and `cmd/dm-syncer`. Integration and compatibility cases live in `dm/tests/`; reusable helpers are under `dm/tests/_utils/`. The DM web UI is in `dm/ui/`. `sync_diff_inspector/` is also relevant because DM integration tests depend on it.
5+
6+
## Build, Test, and Development Commands
7+
Run `make help` for the full target list. Common DM commands:
8+
9+
- `make dm`: build `dm-master`, `dm-worker`, `dmctl`, and `dm-syncer` into `bin/`.
10+
- `make dm_unit_test`: run all DM Go unit tests with race detection.
11+
- `make dm_unit_test_pkg PKG=github.com/pingcap/tiflow/dm/master`: run one package locally.
12+
- `make dm_integration_test_build`: build the `.test` binaries required by `dm/tests/`.
13+
- `make dm_integration_test CASE=sharding`: run one DM integration case.
14+
- `npm --prefix dm/ui run lint`, `npm --prefix dm/ui run type-check`, `npm --prefix dm/ui run build`: validate the DM web UI.
15+
16+
Before DM integration tests, make sure `bin/tidb-server`, `mysql`, and `bin/minio` are available; Python requirements from `dm/tests/requirements.txt` will be installed automatically.
17+
18+
## Coding Style & Naming Conventions
19+
Go is the primary language. Follow [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments) and keep Go files tab-indented as defined in `.editorconfig`. Run `make fmt` before sending changes; it applies `gci`, `gofumports`, `shfmt`, and repository checks. Keep unit tests in `*_test.go`. Name shell cases by directory, for example `dm/tests/sharding/run.sh`. Do not hand-edit generated outputs; regenerate with `make go-generate`, `make generate-protobuf`, or `make dm_generate_openapi` when relevant.
20+
21+
## Testing Guidelines
22+
Add unit tests for package-level logic and integration cases for end-to-end replication behavior. New DM shell cases should be added under `dm/tests/<case>/run.sh` and registered in `dm/tests/run_group.sh`. Coverage artifacts are written to `/tmp/dm_test`. If a change affects compatibility behavior, use the existing compatibility workflow instead of only adding a unit test.
23+
24+
## Commit & Pull Request Guidelines
25+
Use the established DM commit style: `<subsystem>(dm): <what changed>`, for example `worker(dm): improve retry logging`. Keep the subject within 70 characters and explain the reason in the body. PRs should follow [the pull request template](.github/pull_request_template.md): link the issue with `Issue Number: close #12345`, list the DM tests you ran, note compatibility impact, mention doc updates, and provide a release note or `None`. DM fixes and features are expected to include tests, and PRs normally require two maintainer LGTMs.

0 commit comments

Comments
 (0)