Skip to content

Commit 9e4780d

Browse files
committed
chore: standardize eco-wide infra (versioning, CI, hooks, templates)
- VERSION file as single source of truth - CODEOWNERS for auto-review routing - Canonical Makefile with standard targets - release-please config + workflow - lefthook/pre-commit hooks (conventional commits, fmt, lint, secrets) - Canonical CI + release GitHub Actions workflows - Standardized .editorconfig, .gitattributes, CODE_OF_CONDUCT, SECURITY, CONTRIBUTING - goreleaser config (where applicable) Part of hawk-eco standardization sweep.
1 parent 1dc0be4 commit 9e4780d

16 files changed

Lines changed: 646 additions & 205 deletions

.editorconfig

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,67 @@
1+
# EditorConfig — https://editorconfig.org
2+
# Canonical eco-wide template (.shared-templates/editorconfig.tmpl).
3+
14
root = true
25

6+
# Default for everything.
37
[*]
48
charset = utf-8
59
end_of_line = lf
610
insert_final_newline = true
711
trim_trailing_whitespace = true
812
indent_style = space
9-
indent_size = 2
10-
11-
# Python: 4 spaces (PEP 8).
12-
[*.py]
13-
indent_style = space
1413
indent_size = 4
15-
max_line_length = 100
1614

17-
# Makefile-likes use tabs by language convention.
18-
[{Makefile,*.mk,**.mk}]
15+
# Go uses tabs by convention.
16+
[*.go]
1917
indent_style = tab
2018
indent_size = 4
2119

22-
# YAML / JSON / TOML: 2 spaces.
23-
[*.{yml,yaml,json,toml}]
24-
indent_style = space
20+
# Python — PEP 8.
21+
[*.py]
22+
indent_size = 4
23+
24+
# TypeScript / JavaScript — 2 spaces, ecosystem default.
25+
[*.{ts,tsx,js,jsx,mjs,cjs}]
26+
indent_size = 2
27+
28+
# Web assets.
29+
[*.{html,css,scss}]
30+
indent_size = 2
31+
32+
# YAML — 2 spaces (ecosystem standard, GitHub Actions, k8s, etc.).
33+
[*.{yml,yaml}]
34+
indent_size = 2
35+
36+
# JSON / JSONC.
37+
[*.{json,jsonc}]
38+
indent_size = 2
39+
40+
# TOML.
41+
[*.toml]
2542
indent_size = 2
2643

27-
# Markdown: trailing whitespace can be significant (line break with two spaces).
44+
# Markdown — 2 spaces, preserve trailing whitespace (used for line breaks).
2845
[*.md]
2946
trim_trailing_whitespace = false
47+
indent_size = 2
48+
49+
# Shell scripts.
50+
[*.{sh,bash,zsh,fish}]
51+
indent_size = 4
52+
53+
# Makefiles must use tabs.
54+
[{Makefile,*.mk}]
55+
indent_style = tab
56+
57+
# Dockerfiles.
58+
[Dockerfile*]
59+
indent_size = 4
60+
61+
# GitHub Actions workflows — 2 spaces.
62+
[.github/**/*.{yml,yaml}]
63+
indent_size = 2
64+
65+
# Config files.
66+
[*.{cfg,ini,conf}]
67+
indent_size = 4

.gitattributes

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,86 @@
1-
# Default: normalize line endings to LF on commit, leave the working copy alone.
1+
# Canonical eco-wide .gitattributes template (.shared-templates/gitattributes.tmpl).
2+
# Auto-detect text files and normalise line endings to LF.
3+
24
* text=auto eol=lf
35

4-
# Explicitly LF for source, scripts, and config — never CRLF.
5-
*.py text eol=lf
6-
*.md text eol=lf
7-
*.yml text eol=lf
8-
*.yaml text eol=lf
9-
*.json text eol=lf
10-
*.toml text eol=lf
11-
*.cfg text eol=lf
12-
*.ini text eol=lf
6+
# --- Source code -----------------------------------------------------------
7+
*.go text eol=lf diff=golang
8+
*.py text eol=lf diff=python
9+
*.ts text eol=lf
10+
*.tsx text eol=lf
11+
*.js text eol=lf
12+
*.jsx text eol=lf
13+
*.mjs text eol=lf
14+
*.cjs text eol=lf
15+
*.rs text eol=lf diff=rust
16+
17+
# --- Shell + config --------------------------------------------------------
1318
*.sh text eol=lf
14-
Makefile text eol=lf
19+
*.bash text eol=lf
20+
*.toml text eol=lf
21+
*.yaml text eol=lf
22+
*.yml text eol=lf
23+
*.json text eol=lf linguist-language=JSON
24+
*.jsonc text eol=lf linguist-language=JSON
25+
*.cff text eol=lf
26+
27+
# --- Documentation ---------------------------------------------------------
28+
*.md text eol=lf diff=markdown
29+
*.txt text eol=lf
30+
31+
# --- Build / packaging ----------------------------------------------------
32+
Makefile text eol=lf
33+
*.mk text eol=lf
34+
Dockerfile* text eol=lf
35+
docker-compose*.yml text eol=lf
36+
.github/**/*.yml text eol=lf
37+
.github/**/*.yaml text eol=lf
1538

16-
# Windows-only files keep CRLF.
17-
*.bat text eol=crlf
18-
*.cmd text eol=crlf
19-
*.ps1 text eol=crlf
39+
# --- Generated artefacts (mark as such for diffs and language stats) ------
40+
go.mod text eol=lf linguist-generated
41+
go.sum text eol=lf linguist-generated
42+
*.pb.go linguist-generated
43+
*_generated.go linguist-generated
44+
package-lock.json linguist-generated
45+
pnpm-lock.yaml linguist-generated
46+
yarn.lock linguist-generated
2047

21-
# Binary files — never diffed, never EOL-normalized.
48+
# --- Vendored / external sources ------------------------------------------
49+
vendor/** linguist-vendored
50+
node_modules/** linguist-vendored
51+
testdata/** linguist-vendored
52+
benchmarks/data/** linguist-vendored
53+
54+
# --- Binary files (do not text-normalise) ---------------------------------
55+
*.exe binary
56+
*.dll binary
57+
*.so binary
58+
*.dylib binary
59+
*.a binary
60+
*.o binary
61+
*.db binary
62+
*.sqlite binary
2263
*.png binary
2364
*.jpg binary
2465
*.jpeg binary
2566
*.gif binary
2667
*.ico binary
68+
*.svg text eol=lf
69+
*.pdf binary
2770
*.zip binary
28-
*.tar binary
2971
*.tar.gz binary
30-
*.gz binary
31-
*.pdf binary
72+
*.tgz binary
3273
*.whl binary
3374

34-
# Generated / lock files — collapse in PR diffs (GitHub linguist hint).
35-
poetry.lock linguist-generated=true
36-
Pipfile.lock linguist-generated=true
37-
uv.lock linguist-generated=true
38-
requirements*.txt linguist-generated=true
75+
# --- Source archive hygiene (excluded from `git archive`) -----------------
76+
.github export-ignore
77+
.shared-templates export-ignore
78+
.gitattributes export-ignore
79+
.gitignore export-ignore
80+
.editorconfig export-ignore
81+
.golangci.yml export-ignore
82+
.goreleaser.yml export-ignore
83+
.goreleaser.yaml export-ignore
84+
testdata/ export-ignore
85+
benchmarks/ export-ignore
86+
e2e/ export-ignore

.github/workflows/ci.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Canonical CI workflow for hawk-eco Python repos.
2+
# Source of truth: .shared-templates/workflows/python-ci.yml.tmpl
3+
14
name: CI
25

36
on:
@@ -9,9 +12,13 @@ on:
912
permissions:
1013
contents: read
1114

15+
concurrency:
16+
group: ci-${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1219
jobs:
1320
test:
14-
name: Test (Python ${{ matrix.python-version }})
21+
name: test (Python ${{ matrix.python-version }})
1522
runs-on: ubuntu-latest
1623
strategy:
1724
fail-fast: false
@@ -31,7 +38,7 @@ jobs:
3138
run: pytest --strict-markers --tb=short
3239

3340
lint:
34-
name: Lint (ruff)
41+
name: lint (ruff)
3542
runs-on: ubuntu-latest
3643
steps:
3744
- uses: actions/checkout@v4
@@ -49,7 +56,7 @@ jobs:
4956
run: ruff format --check .
5057

5158
typecheck:
52-
name: Type check (mypy --strict)
59+
name: typecheck (mypy --strict)
5360
runs-on: ubuntu-latest
5461
steps:
5562
- uses: actions/checkout@v4
@@ -64,8 +71,24 @@ jobs:
6471
- name: mypy
6572
run: mypy src/
6673

74+
security:
75+
name: security (pip-audit)
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
- uses: actions/setup-python@v5
80+
with:
81+
python-version: "3.12"
82+
cache: pip
83+
- name: Install
84+
run: |
85+
python -m pip install --upgrade pip pip-audit
86+
pip install -e ".[dev]"
87+
- name: pip-audit
88+
run: pip-audit
89+
6790
build:
68-
name: Build sdist + wheel
91+
name: build (sdist + wheel)
6992
runs-on: ubuntu-latest
7093
needs: [test, lint, typecheck]
7194
steps:
@@ -74,10 +97,9 @@ jobs:
7497
with:
7598
python-version: "3.12"
7699
cache: pip
77-
- name: Install build
100+
- name: Install build tools
78101
run: |
79-
python -m pip install --upgrade pip
80-
pip install build twine
102+
python -m pip install --upgrade pip build twine
81103
- name: Build
82104
run: python -m build
83105
- name: Twine check
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Canonical release-please workflow for hawk-eco repos.
2+
# Opens / updates a release PR on every push to main; on merge of that PR,
3+
# tags the new release. The tag triggers goreleaser (separate workflow).
4+
#
5+
# Source of truth: .shared-templates/release-please.yml.tmpl at the eco root.
6+
7+
name: release-please
8+
9+
on:
10+
push:
11+
branches: [main]
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
issues: write
17+
18+
concurrency:
19+
group: release-please-${{ github.ref }}
20+
cancel-in-progress: false
21+
22+
jobs:
23+
release-please:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Run release-please
27+
id: release
28+
uses: googleapis/release-please-action@v4
29+
with:
30+
config-file: release-please-config.json
31+
manifest-file: .release-please-manifest.json
32+
token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
33+
34+
- name: Summary
35+
if: always()
36+
run: |
37+
if [[ "${{ steps.release.outputs.release_created }}" == "true" ]]; then
38+
echo "Released ${{ steps.release.outputs.tag_name }}." >> $GITHUB_STEP_SUMMARY
39+
elif [[ "${{ steps.release.outputs.pr }}" != "" ]]; then
40+
echo "Updated release PR: ${{ steps.release.outputs.pr }}" >> $GITHUB_STEP_SUMMARY
41+
else
42+
echo "No release-relevant changes detected." >> $GITHUB_STEP_SUMMARY
43+
fi

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Canonical PyPI publish workflow for hawk-eco Python repos.
2+
# Triggered by release-please when it pushes a v* tag.
3+
# Source of truth: .shared-templates/workflows/python-release.yml.tmpl
4+
#
5+
# Uses PyPI Trusted Publishing (OIDC) — no API tokens stored in GitHub.
6+
# Configure once at https://pypi.org/manage/account/publishing/
7+
8+
name: release
9+
10+
on:
11+
push:
12+
tags: ["v*"]
13+
14+
permissions:
15+
contents: read
16+
id-token: write # required for PyPI Trusted Publishing
17+
18+
jobs:
19+
build-and-publish:
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: pypi
23+
url: https://pypi.org/p/hawk-sdk
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.12"
30+
31+
- name: Install build tooling
32+
run: |
33+
python -m pip install --upgrade pip build
34+
35+
- name: Build sdist + wheel
36+
run: python -m build
37+
38+
- name: Publish to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
packages-dir: dist/

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Canonical pre-commit config for hawk-eco Python repos.
2+
# Source of truth: .shared-templates/pre-commit-config.yaml.tmpl
3+
#
4+
# Install: pip install pre-commit
5+
# Activate: pre-commit install --install-hooks
6+
# Run all: pre-commit run --all-files
7+
8+
repos:
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v4.6.0
11+
hooks:
12+
- id: trailing-whitespace
13+
exclude: '\.md$' # markdown uses trailing whitespace for line breaks
14+
- id: end-of-file-fixer
15+
- id: check-yaml
16+
- id: check-toml
17+
- id: check-json
18+
- id: check-merge-conflict
19+
- id: check-added-large-files
20+
args: [--maxkb=512]
21+
- id: detect-private-key
22+
- id: mixed-line-ending
23+
args: [--fix=lf]
24+
25+
- repo: https://github.com/astral-sh/ruff-pre-commit
26+
rev: v0.8.0
27+
hooks:
28+
- id: ruff
29+
args: [--fix, --exit-non-zero-on-fix]
30+
- id: ruff-format
31+
32+
- repo: https://github.com/pre-commit/mirrors-mypy
33+
rev: v1.13.0
34+
hooks:
35+
- id: mypy
36+
additional_dependencies: [pydantic>=2.0, httpx>=0.25]
37+
args: [--strict, --ignore-missing-imports]
38+
39+
- repo: https://github.com/commitizen-tools/commitizen
40+
rev: v3.30.1
41+
hooks:
42+
- id: commitizen
43+
stages: [commit-msg]

0 commit comments

Comments
 (0)