Skip to content

Commit 4851a68

Browse files
committed
Adding a GH action to run tests & linting for every commit
Signed-off-by: Cédric Foellmi <cedric@onekiloparsec.dev>
1 parent ad0cfab commit 4851a68

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
pip install pytest pytest-cov
29+
pip install -e .
30+
31+
- name: Test with pytest
32+
run: |
33+
pytest -xvs tests/ --cov=arcsecond --cov-report=xml
34+
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v3
37+
with:
38+
file: ./coverage.xml
39+
fail_ci_if_error: false
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: '3.12'
50+
51+
- name: Install dependencies
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install flake8 black isort
55+
56+
- name: Lint with flake8
57+
run: |
58+
flake8 arcsecond tests --count --select=E9,F63,F7,F82 --show-source --statistics
59+
60+
- name: Check formatting with black
61+
run: |
62+
black --check arcsecond tests
63+
64+
- name: Check imports with isort
65+
run: |
66+
isort --check-only --profile black arcsecond tests

0 commit comments

Comments
 (0)