-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (80 loc) · 2.81 KB
/
Copy pathlint_and_test.yaml
File metadata and controls
95 lines (80 loc) · 2.81 KB
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
name: List and Test
on:
push:
branches:
- main
pull_request:
branches:
- "*"
jobs:
test:
name: Run Tests and Linters
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
os:
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Poetry
uses: actions/cache@v4
with:
path: |
.venv
~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install poetry
uses: abatilo/actions-poetry@v4
- name: Configure poetry
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: Install dependencies
run: poetry install --no-interaction --with=dev
- name: Run pre-commit (skip pytest hook)
run: poetry run pre-commit run --all-files --hook-stage manual
- name: Run pytest with coverage (terminal, XML, and HTML)
run: poetry run pytest --cov=policy_inspector --cov-report=term-missing --cov-report=html
env:
PYTHONPATH: .
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov/
publish:
name: Build and Publish
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install poetry
uses: abatilo/actions-poetry@v4
- name: Configure poetry
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
poetry config pypi-token.pypi $PYPI_TOKEN
- name: Build and publish the package
if: ${{ success() }}
run: poetry publish --build