Skip to content

Commit 6bcb874

Browse files
committed
chore(scripts): add check.sh to run ci.yml checks locally
1 parent e3f240d commit 6bcb874

2 files changed

Lines changed: 59 additions & 12 deletions

File tree

CONTRIBUTING.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,14 @@ Thanks for your interest in contributing. This repository contains the PythonNat
77
Development uses Python ≥ 3.10.
88

99
```bash
10-
# create and activate a venv (recommended)
11-
python3 -m venv .venv && source .venv/bin/activate
10+
# one-shot: creates .venv, syncs CI deps, runs every CI check
11+
# (requires uv: https://docs.astral.sh/uv/getting-started/installation/)
12+
./scripts/check.sh
1213

13-
# install dev tools (lint/format/test)
14-
pip install -e ".[dev]"
15-
16-
# install library (editable) and CLI
17-
pip install -e .
18-
19-
# run tests
14+
# Run individual steps if you only want one
2015
pytest -q
21-
22-
# format and lint
23-
black src examples tests || true
2416
ruff check .
17+
black src examples tests
2518
```
2619

2720
Common library and CLI entry points:
@@ -63,6 +56,7 @@ cd examples/hello-world && pn run android
6356
Common commands:
6457

6558
```bash
59+
./scripts/check.sh # run all CI checks (mirrors ci.yml)
6660
pytest -q # run tests
6761
ruff check . # lint
6862
black src examples tests # format
@@ -127,6 +121,7 @@ Recommended scopes (choose the smallest, most accurate unit; prefer module/direc
127121
- `mkdocs` – documentation site (MkDocs/Material) configuration and content under `docs/`
128122
- `pyproject``pyproject.toml` packaging/build metadata
129123
- `repo` – repository metadata and top‑level files (`README.md`, `CONTRIBUTING.md`, `.gitignore`, licenses)
124+
- `scripts` – developer scripts under `scripts/` (e.g., `check.sh`)
130125
- `templates` – Android/iOS project templates under `src/pythonnative/templates/`
131126
- `tests` – unit/integration/E2E tests under `tests/`
132127
- `workflows` – CI pipelines under `.github/workflows/`

scripts/check.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
# Run the same checks as .github/workflows/ci.yml locally, in the same order.
3+
# Stops at the first failure. If this script is green, CI should be green too.
4+
#
5+
# Uses uv to manage the project venv and CI dependencies. Install uv first:
6+
# curl -LsSf https://astral.sh/uv/install.sh | sh
7+
#
8+
# Usage:
9+
# ./scripts/check.sh
10+
11+
set -euo pipefail
12+
13+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14+
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
15+
cd "$ROOT_DIR"
16+
17+
if ! command -v uv > /dev/null; then
18+
echo "Error: 'uv' is not installed." >&2
19+
echo "Install: https://docs.astral.sh/uv/getting-started/installation/" >&2
20+
exit 1
21+
fi
22+
23+
if [[ ! -x ".venv/bin/python" ]]; then
24+
printf "\n==> Creating .venv (uv venv --seed)\n"
25+
uv venv --seed
26+
fi
27+
28+
printf "\n==> Syncing CI dependencies\n"
29+
uv pip install --python .venv/bin/python -e ".[ci]" build
30+
31+
PY=".venv/bin/python"
32+
33+
step() {
34+
printf "\n==> %s\n" "$1"
35+
}
36+
37+
step "Lint (Ruff)"
38+
"$PY" -m ruff check .
39+
40+
step "Format check (Black)"
41+
"$PY" -m black --check src examples tests
42+
43+
step "Type check (MyPy)"
44+
"$PY" -m mypy --install-types --non-interactive
45+
46+
step "Build package (sdist + wheel)"
47+
"$PY" -m build
48+
49+
step "Run tests (pytest)"
50+
"$PY" -m pytest -q
51+
52+
printf "\nAll CI checks passed.\n"

0 commit comments

Comments
 (0)