Skip to content

Commit 750e1fb

Browse files
committed
feat(tooling): add pre-commit, commitizen, golangci-lint; enforce OM branch naming\n\nCloses #29
1 parent b349280 commit 750e1fb

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

.cz.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[tool.commitizen]
2+
name = "cz_conventional_commits"
3+
version = "0.1.0"
4+
tag_format = "v$version"
5+

.golangci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
run:
2+
timeout: 3m
3+
issues-exit-code: 1
4+
tests: true
5+
6+
linters:
7+
enable:
8+
- govet
9+
- staticcheck
10+
- gosimple
11+
- ineffassign
12+
- errcheck
13+
- gofmt
14+
15+
issues:
16+
exclude-use-default: false
17+
max-issues-per-linter: 0
18+
max-same-issues: 0
19+

.pre-commit-config.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
default_install_hook_types: [commit-msg, pre-commit]
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.6.0
6+
hooks:
7+
# Git style
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: check-vcs-permalinks
11+
- id: forbid-new-submodules
12+
- id: no-commit-to-branch
13+
args:
14+
- '--pattern'
15+
- '^((?!(feat|feature|fix|bugfix|chore|docs|refactor|test|ci|build|perf|wip|break|revert|hotfix|security)/(OM|om)-[0-9]{1,5}_[A-Za-z0-9._\-]+).)*$'
16+
17+
# Common errors
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace
20+
args: [--markdown-linebreak-ext=md]
21+
- id: check-yaml
22+
- id: check-executables-have-shebangs
23+
24+
# Cross platform
25+
- id: check-case-conflict
26+
- id: mixed-line-ending
27+
args: [--fix=lf]
28+
29+
- repo: https://github.com/Yelp/detect-secrets.git
30+
rev: v1.4.0
31+
hooks:
32+
- id: detect-secrets
33+
name: Detect secrets
34+
always_run: true
35+
description: Detects high entropy strings that are likely to be passwords.
36+
entry: detect-secrets-hook
37+
files: .*(\.(json|yml|yaml|tf|toml|ini))$
38+
39+
- repo: https://github.com/commitizen-tools/commitizen
40+
rev: v2.42.1
41+
hooks:
42+
- id: commitizen
43+
stages: [commit-msg]
44+
45+
# Go formatting and vet (local hooks)
46+
- repo: local
47+
hooks:
48+
- id: go-fmt
49+
name: go fmt
50+
entry: bash -lc 'go fmt ./...'
51+
language: system
52+
pass_filenames: false
53+
- id: go-vet
54+
name: go vet
55+
entry: bash -lc 'go vet ./...'
56+
language: system
57+
pass_filenames: false
58+
59+
# GolangCI-Lint (static analysis)
60+
- repo: https://github.com/golangci/golangci-lint
61+
rev: v1.59.1
62+
hooks:
63+
- id: golangci-lint
64+
args: ["-c", ".golangci.yml"]
65+

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# replicator
22
Controller component of the OpenMigrate platform — receives replicated disk data from agents, processes block-level changes, applies compression, and securely uploads to target cloud storage (e.g., S3). Enables scalable, centralized orchestration of migrations across environments.
3+
4+
### Pre-commit, Commitizen, and Linting
5+
6+
- Install pre-commit hooks:
7+
- pipx: `pipx install pre-commit` (or `pip install pre-commit`)
8+
- Install hooks: `pre-commit install --hook-type pre-commit --hook-type commit-msg`
9+
- Branch naming enforced via pre-commit: `<type>/(OM|om)-<ticket>_<short-desc>`
10+
- Allowed types: `feat, feature, fix, bugfix, chore, docs, refactor, test, ci, build, perf, wip, break, revert, hotfix, security`
11+
- Commit messages validated by Commitizen (Conventional Commits) on `commit-msg`.
12+
- Go formatting and vet run on commit; static analysis via `golangci-lint`.
13+
14+
Configs:
15+
- `.pre-commit-config.yaml` — hooks configuration
16+
- `.golangci.yml` — linter configuration
17+
- `.cz.toml` — commitizen configuration

0 commit comments

Comments
 (0)