-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (81 loc) · 2.61 KB
/
ci.yaml
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
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
check-version:
name: Ensure version has been bumped
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request' # Only run on PRs
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install toml package
run: pip install toml
- name: Check version
run: |
# Read current version from PR branch
CURRENT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "Current version: $CURRENT_VERSION"
# Checkout main branch to compare
git fetch origin main
git checkout origin/main
# Read version from main branch
MAIN_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "Main version: $MAIN_VERSION"
# Checkout back to PR branch
git checkout -
# Compare versions
if [ "$CURRENT_VERSION" = "$MAIN_VERSION" ]; then
echo "Error: Version has not been bumped from $MAIN_VERSION"
exit 1
fi
# Check if new version already exists as a tag
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
echo "Error: Version v$CURRENT_VERSION already exists as a tag"
exit 1
fi
echo "Version v$CURRENT_VERSION is new and has been bumped from v$MAIN_VERSION"
test:
name: Run tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: 'uv.lock'
- name: set up python
uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
- name: install pis
run: uv sync --all-extras --dev
- name: run tests
run: uv run pytest
lint:
name: Check code style
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: 'uv.lock'
- name: set up python
uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
- name: install pis
run: uv sync --all-extras --dev
- name: run ruff
run: uv run ruff check --output-format=github .