-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (103 loc) · 4.45 KB
/
Copy pathtests.yml
File metadata and controls
131 lines (103 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Tests
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
# Promote SONAR_TOKEN to job env so the SonarCloud step can gate on
# `env.SONAR_TOKEN != ''` — `secrets.*` isn't allowed in `if:`. This
# makes the step a no-op on fork PRs (where the secret isn't injected)
# and on any repo that hasn't configured the token yet.
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
# Sonar needs full git history for accurate "new code" blame attribution.
fetch-depth: 0
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- run: uv run pytest -n auto --cov=model_gear --cov-report=xml:coverage.xml --cov-report=term -v
- name: SonarCloud Scan
if: env.SONAR_TOKEN != ''
uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6
env:
SONAR_HOST_URL: https://sonarcloud.io
lint:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- name: black --check
run: uv run black --check model_gear tests
- name: isort --check
run: uv run isort --check-only model_gear tests
- name: flake8
run: uv run flake8 model_gear tests
- name: bandit
run: uv run bandit -c pyproject.toml -r model_gear
- name: markdownlint-cli2
run: |
npm install -g markdownlint-cli2@0.21.0
markdownlint-cli2 "**/*.md" "#node_modules" "#.local"
- name: afi rubric gate
run: uv run afi cli doctor . --strict
version-check:
# Only run on PR events. On push to main after a merged PR, the comparison
# would always fail (PR_VERSION == MAIN_VERSION because HEAD and origin/main
# point at the same commit). Restricting the trigger avoids that.
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- run: git fetch origin main
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Check version bump
env:
GH_TOKEN: ${{ github.token }}
run: |
# AgentCulture rule: every PR bumps the version — even docs/config/CI.
# See CLAUDE.md and the version-bump skill for rationale.
PR_VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
MAIN_VERSION=$(git show origin/main:pyproject.toml 2>/dev/null | python3 -c "import sys,tomllib; print(tomllib.loads(sys.stdin.read())['project']['version'])" 2>/dev/null || echo "")
if [ -z "$MAIN_VERSION" ]; then
echo "No pyproject.toml on main yet — skipping version check (initial scaffold)."
exit 0
fi
if [ "$PR_VERSION" = "$MAIN_VERSION" ]; then
MARKER="<!-- version-check -->"
BODY="⚠️ **Version not bumped** — \`pyproject.toml\` still has \`$PR_VERSION\` (same as main). Bump before merging to avoid a failed PyPI publish.
$MARKER"
EXISTING=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
--jq '.[] | select(.body | contains("<!-- version-check -->")) | .id' | head -1)
if [ -n "$EXISTING" ]; then
gh api repos/${{ github.repository }}/issues/comments/$EXISTING \
-X PATCH -f body="$BODY" > /dev/null
else
gh pr comment ${{ github.event.pull_request.number }} --body "$BODY" || true
fi
echo "::error::Version $PR_VERSION matches main. Bump before merging."
exit 1
else
echo "Version bumped: $MAIN_VERSION -> $PR_VERSION"
fi