Skip to content

Commit 1fd1631

Browse files
authored
Merge pull request #8 from Bovi-analytics/feat/pre-commit
Feat/pre commit
2 parents 21384a2 + 2ff1ae9 commit 1fd1631

72 files changed

Lines changed: 2029 additions & 691 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
#for secret/key management
1+
#for secret/key management
22
milkbot_key = YOUR_MILKBOT_KEY
3-
uv_publish_token = YOUR_UNV_TOKEN
3+
uv_publish_token = YOUR_UNV_TOKEN
4+
pulumi_passphrase = YOUR_PASSPHRASE

.github/workflows/api-tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: API Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
- master
8+
9+
jobs:
10+
api-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v3
19+
20+
- name: Set up Python 3.12
21+
run: uv python install 3.12
22+
23+
- name: Install app dependencies
24+
working-directory: apps/lactation_curves
25+
run: uv sync
26+
27+
- name: Start API server and run tests
28+
working-directory: apps/lactation_curves
29+
run: |
30+
nohup uv run python -m uvicorn main:app --host 0.0.0.0 --port 8000 > /tmp/uvicorn.log 2>&1 &
31+
for i in $(seq 1 30); do
32+
if curl -sf http://localhost:8000/ > /dev/null 2>&1; then
33+
echo "API is ready"
34+
break
35+
fi
36+
echo "Waiting for API... ($i/30)"
37+
sleep 1
38+
done
39+
if ! curl -sf http://localhost:8000/ > /dev/null 2>&1; then
40+
echo "API failed to start. Server logs:"
41+
cat /tmp/uvicorn.log
42+
exit 1
43+
fi
44+
uv run pytest tests/ -v

.github/workflows/cffconvert.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ name: cffconvert
22

33
on:
44
push:
5-
paths:
6-
- CITATION.cff
7-
5+
branches:
6+
- master
87
pull_request:
9-
paths:
10-
- CITATION.cff
8+
branches:
9+
- master
1110

1211
jobs:
1312
validate:

.github/workflows/docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- master
7+
pull_request:
8+
branches:
9+
- master
710

811
permissions:
912
contents: read
@@ -49,6 +52,7 @@ jobs:
4952
path: packages/python/lactation/site
5053

5154
deploy:
55+
if: github.event_name == 'push'
5256
needs: build-docs
5357
runs-on: ubuntu-latest
5458
environment:

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish (lactationcurve)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
environment: master
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v3
22+
23+
- name: Set up Python 3.12
24+
run: uv python install 3.12
25+
26+
- name: Build package
27+
working-directory: packages/python/lactation
28+
run: uv build
29+
30+
- name: Publish to PyPI
31+
working-directory: packages/python/lactation
32+
run: uv publish

.github/workflows/pytest.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Unit Tests (lactationcurve)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
- master
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v3
19+
20+
- name: Set up Python 3.12
21+
run: uv python install 3.12
22+
23+
- name: Install dependencies
24+
run: uv sync
25+
26+
- name: Run tests
27+
env:
28+
milkbot_key: ${{ secrets.MILKBOT_KEY }}
29+
run: uv run pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ wheels/
2020
.env.local
2121
node_modules
2222
.next
23+
*.tsbuildinfo
2324
tests/lactationcurve/test_dotenv.py

.pre-commit-config.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Pre-commit hooks for lactation_curve_core
2+
# Install: uv run pre-commit install
3+
# Run all: uv run pre-commit run --all-files
4+
5+
repos:
6+
# ── General checks ──────────────────────────────────────────
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: check-added-large-files
11+
args: ['--maxkb=500']
12+
- id: check-merge-conflict
13+
- id: trailing-whitespace
14+
- id: end-of-file-fixer
15+
- id: check-yaml
16+
- id: check-toml
17+
- id: check-json
18+
19+
# ── Secrets detection ───────────────────────────────────────
20+
- repo: https://github.com/Yelp/detect-secrets
21+
rev: v1.5.0
22+
hooks:
23+
- id: detect-secrets
24+
args: ['--baseline', '.secrets.baseline']
25+
exclude: (bun\.lock|uv\.lock|\.tsbuildinfo)$
26+
27+
# ── Python formatting + linting ─────────────────────────────
28+
- repo: https://github.com/astral-sh/ruff-pre-commit
29+
rev: v0.11.0
30+
hooks:
31+
- id: ruff-format
32+
- id: ruff
33+
args: [--fix]
34+
35+
# ── Python type checking ────────────────────────────────────
36+
- repo: local
37+
hooks:
38+
- id: basedpyright
39+
name: basedpyright
40+
entry: uv run basedpyright
41+
language: system
42+
types: [python]
43+
pass_filenames: false
44+
45+
# ── TypeScript formatting (prettier) ────────────────────────
46+
- id: prettier
47+
name: prettier
48+
entry: bash -c 'cd apps/dashboard && bun run format:check'
49+
language: system
50+
types_or: [ts, tsx, javascript, jsx, json, css]
51+
files: ^apps/dashboard/
52+
pass_filenames: false
53+
54+
# ── TypeScript linting (eslint) ─────────────────────────────
55+
- id: eslint
56+
name: eslint
57+
entry: bash -c 'cd apps/dashboard && bun run lint'
58+
language: system
59+
types_or: [ts, tsx, javascript, jsx]
60+
files: ^apps/dashboard/src/
61+
pass_filenames: false
62+
63+
# ── TypeScript type checking (tsc) ──────────────────────────
64+
- id: tsc
65+
name: tsc
66+
entry: bash -c 'cd apps/dashboard && bun run typecheck'
67+
language: system
68+
types_or: [ts, tsx]
69+
files: ^apps/dashboard/
70+
pass_filenames: false

0 commit comments

Comments
 (0)