1+ name : Python CI
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+
7+ pull_request :
8+ branches : [ main ]
9+
10+ jobs :
11+ lint :
12+ name : Code Quality
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v3
16+
17+ - name : Set up Python
18+ uses : actions/setup-python@v4
19+ with :
20+ python-version : ' 3.11'
21+
22+ - name : Install Poetry
23+ uses : snok/install-poetry@v1
24+ with :
25+ version : latest
26+ virtualenvs-create : true
27+ virtualenvs-in-project : true
28+
29+ - name : Load cached venv
30+ id : cached-poetry-dependencies
31+ uses : actions/cache@v3
32+ with :
33+ path : .venv
34+ key : venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
35+
36+ - name : Install dependencies
37+ if : steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
38+ run : poetry install --no-interaction --no-root
39+
40+ - name : Check imports with isort
41+ run : poetry run isort . --check-only --profile black
42+
43+ - name : Check formatting with Black
44+ run : poetry run black . --check
45+
46+ - name : Lint with flake8
47+ run : poetry run flake8 . --max-line-length=100
48+
49+ test :
50+ name : Tests
51+ needs : lint # This job will only run if lint job passes
52+ runs-on : ubuntu-latest
53+ steps :
54+ - uses : actions/checkout@v3
55+
56+ - name : Set up Python
57+ uses : actions/setup-python@v4
58+ with :
59+ python-version : ' 3.11'
60+
61+ - name : Install Poetry
62+ uses : snok/install-poetry@v1
63+ with :
64+ version : latest
65+ virtualenvs-create : true
66+ virtualenvs-in-project : true
67+
68+ - name : Load cached venv
69+ id : cached-poetry-dependencies
70+ uses : actions/cache@v3
71+ with :
72+ path : .venv
73+ key : venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
74+
75+ - name : Install dependencies
76+ if : steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
77+ run : poetry install --no-interaction --no-root
78+
79+ - name : Run tests
80+ run : poetry run pytest tests/
0 commit comments