-
Notifications
You must be signed in to change notification settings - Fork 48
179 lines (156 loc) · 5.76 KB
/
test-agent.yml
File metadata and controls
179 lines (156 loc) · 5.76 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Test Agent
on:
pull_request:
branches: [main]
paths:
- "agent/**"
- ".github/workflows/test-agent.yml"
push:
branches: [main]
paths:
- "agent/**"
workflow_dispatch:
permissions:
contents: read
checks: write # post test results as PR check
pull-requests: write # comment with coverage summary
concurrency:
group: test-agent-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
# ── Lint & type-check (fast, runs once) ─────────────────────────────────────
lint:
name: Lint & type-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install lint tools
run: pip install ruff mypy pydantic
- name: Ruff — lint
working-directory: agent
run: |
ruff check src/ tests/ --output-format=github || true
- name: Ruff — format check
working-directory: agent
run: |
ruff format src/ tests/ --check || true
- name: Mypy — type check (non-blocking)
working-directory: agent
run: |
pip install -e "." --quiet
mypy src/regraph_agent/ \
--ignore-missing-imports \
--no-strict-optional \
--follow-imports=silent \
|| true
# ── Pytest matrix ────────────────────────────────────────────────────────────
test:
name: pytest / Python ${{ matrix.python-version }} / ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest]
include:
# Also run 3.11 on macOS to catch Darwin-specific code paths
- python-version: "3.11"
os: macos-latest
# And 3.11 on Windows to test Windows-specific paths
- python-version: "3.11"
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: agent/pyproject.toml
- name: Install agent (core deps only — no heavy ML libs)
working-directory: agent
run: |
pip install --upgrade pip
pip install -e "." pytest pytest-cov pytest-mock
- name: Run tests
working-directory: agent
run: |
pytest tests/ \
--cov=src/regraph_agent \
--cov-report=xml:coverage.xml \
--cov-report=term-missing \
--junitxml=junit.xml \
-v
- name: Upload JUnit results
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-${{ matrix.os }}-py${{ matrix.python-version }}
path: agent/junit.xml
retention-days: 7
- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: agent/coverage.xml
retention-days: 7
# ── Coverage comment on PR ────────────────────────────────────────────────────
coverage:
name: Coverage report
needs: test
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-report
path: ./
- name: Coverage summary comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: ./coverage.xml
title: "Agent Test Coverage"
badge-title: "Coverage"
hide-comment: false
create-new-comment: false
default-branch: main
# ── Test summary ──────────────────────────────────────────────────────────────
summary:
name: Test Summary
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- name: Download all JUnit reports
uses: actions/download-artifact@v4
with:
pattern: junit-*
merge-multiple: true
path: ./junit-reports/
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: runner.os == 'Linux'
with:
files: "junit-reports/**/*.xml"
comment_title: "Agent Unit Test Results"
check_name: "Agent Tests"
- name: Write step summary
if: always()
run: |
echo "## 🧪 Agent Test Matrix Results" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| OS | Python | Result |" >> "$GITHUB_STEP_SUMMARY"
echo "|-----|--------|--------|" >> "$GITHUB_STEP_SUMMARY"
echo "| ubuntu | 3.10 | ${{ needs.test.result }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| ubuntu | 3.11 | ${{ needs.test.result }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| ubuntu | 3.12 | ${{ needs.test.result }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| macOS | 3.11 | ${{ needs.test.result }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Windows| 3.11 | ${{ needs.test.result }} |" >> "$GITHUB_STEP_SUMMARY"