Skip to content

Commit f9ffc7f

Browse files
committed
Add CI workflow for running tests on PRs
- Run tests on Ubuntu, Windows, and macOS - Test against Python 3.9, 3.10, 3.11, 3.12 - Build .NET binaries before running tests - Include coverage reporting via Codecov - Add separate unit-test-only job for quick feedback - Add linting check with ruff - Add build verification job
1 parent 02aa3b8 commit f9ffc7f

1 file changed

Lines changed: 132 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, windows-latest, macos-latest]
19+
python-version: ['3.9', '3.10', '3.11', '3.12']
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Set up .NET
30+
uses: actions/setup-dotnet@v4
31+
with:
32+
dotnet-version: '8.0.x'
33+
34+
- name: Install Python dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install pytest pytest-cov hatch
38+
39+
- name: Build engine binaries
40+
run: python build_differ.py
41+
42+
- name: Install package
43+
run: pip install -e .
44+
45+
- name: Run tests with coverage
46+
run: |
47+
pytest tests/ -v --cov=python_redlines --cov-report=xml --cov-report=term-missing
48+
49+
- name: Upload coverage reports
50+
uses: codecov/codecov-action@v4
51+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
52+
with:
53+
file: ./coverage.xml
54+
fail_ci_if_error: false
55+
56+
# Quick test without binaries (unit tests only)
57+
test-unit-only:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Set up Python
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: '3.11'
66+
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install pytest pytest-cov
71+
72+
- name: Install package (without building binaries)
73+
env:
74+
SKIP_BINARY_BUILD: "1"
75+
run: pip install -e .
76+
77+
- name: Run unit tests (no integration tests)
78+
run: |
79+
pytest tests/ -v --ignore=tests/test_engines.py -k "not integration"
80+
81+
lint:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Set up Python
87+
uses: actions/setup-python@v5
88+
with:
89+
python-version: '3.11'
90+
91+
- name: Install dependencies
92+
run: |
93+
python -m pip install --upgrade pip
94+
pip install ruff
95+
96+
- name: Check code formatting
97+
run: ruff check src/ tests/ --output-format=github
98+
continue-on-error: true
99+
100+
build:
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Set up Python
106+
uses: actions/setup-python@v5
107+
with:
108+
python-version: '3.11'
109+
110+
- name: Set up .NET
111+
uses: actions/setup-dotnet@v4
112+
with:
113+
dotnet-version: '8.0.x'
114+
115+
- name: Install build dependencies
116+
run: |
117+
python -m pip install --upgrade pip
118+
pip install hatch hatchling
119+
120+
- name: Build package
121+
run: hatch build
122+
123+
- name: Check package
124+
run: |
125+
pip install twine
126+
twine check dist/*
127+
128+
- name: Upload build artifacts
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: dist
132+
path: dist/

0 commit comments

Comments
 (0)