Skip to content

Commit 3bc0013

Browse files
committed
cloeset thing to hatch scripts using project scripts
Signed-off-by: leohoare <[email protected]>
1 parent 368bb40 commit 3bc0013

File tree

4 files changed

+244
-9
lines changed

4 files changed

+244
-9
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,10 @@ jobs:
3737
run: uv sync --extra dev
3838

3939
- name: Test with pytest
40-
run: uv run pytest tests
41-
42-
- name: Run coverage
43-
run: uv run coverage run -m pytest tests && uv run coverage xml
40+
run: uv run cov
4441

4542
- name: Run E2E tests with behave
46-
run: |
47-
git submodule update --init --recursive
48-
cp spec/specification/assets/gherkin/* tests/features/
49-
uv run behave tests/features/
50-
rm tests/features/*.feature
43+
run: uv run e2e
5144

5245
- if: matrix.python-version == '3.13'
5346
name: Upload coverage to Codecov

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,11 @@ max-statements = 30
117117
[tool.ruff.lint.pyupgrade]
118118
# Preserve types, even if a file imports `from __future__ import annotations`.
119119
keep-runtime-typing = true
120+
121+
[project.scripts]
122+
# workaround while UV doesn't support scripts directly in the pyproject.toml
123+
test = "scripts.scripts:test"
124+
test-cov = "scripts.scripts:test_cov"
125+
cov-report = "scripts.scripts:cov_report"
126+
cov = "scripts.scripts:cov"
127+
e2e = "scripts.scripts:e2e"

scripts/scripts.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import subprocess
2+
3+
4+
def test():
5+
"""Run pytest tests."""
6+
subprocess.run("pytest tests", shell=True, check=True)
7+
8+
9+
def test_cov():
10+
"""Run tests with coverage."""
11+
subprocess.run("coverage run -m pytest tests", shell=True, check=True)
12+
13+
14+
def cov_report():
15+
"""Generate coverage report."""
16+
subprocess.run("coverage xml", shell=True, check=True)
17+
18+
19+
def cov():
20+
"""Run tests with coverage and generate report."""
21+
test_cov()
22+
cov_report()
23+
24+
25+
def e2e():
26+
"""Run end-to-end tests."""
27+
subprocess.run("git submodule update --init --recursive", shell=True, check=True)
28+
subprocess.run("cp spec/specification/assets/gherkin/* tests/features/", shell=True, check=True)
29+
subprocess.run("behave tests/features/", shell=True, check=True)
30+
subprocess.run("rm tests/features/*.feature", shell=True, check=True)

0 commit comments

Comments
 (0)