-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (104 loc) · 3.55 KB
/
ci.yml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: CI and release pipeline
on:
pull_request:
push:
branches: ["main", "develop"]
tags: ["*"]
jobs:
static-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
check:
- name: Check code-formatting
run: poetry run black --check .
- name: Check import sorting
run: poetry run isort --check-only .
- name: pylint
run: poetry run pylint goppy
steps:
- uses: actions/checkout@v3
- run: git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main
- name: Set up Python
uses: actions/setup-python@v4.3.0
with:
python-version: '3.11'
- uses: actions/cache@v3.0.11
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- uses: actions/cache@v3.0.11
with:
path: .venv
key: ${{ runner.os }}-py3.11-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-py3.11-venv-
- uses: ./.github/actions/setup-project
- name: ${{ matrix.check.name }}
run: ${{ matrix.check.run }}
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3.0.11
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- uses: actions/cache@v3.0.11
with:
path: .venv
key: ${{ runner.os }}-py${{ matrix.python-version }}-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-py${{ matrix.python-version }}-venv-
- uses: ./.github/actions/setup-project
- name: Test and measure coverage with pytest
run: poetry run pytest --verbose --cov=goppy --cov-report=xml
- uses: codecov/codecov-action@v3
release:
runs-on: ubuntu-latest
needs: [static-analysis, test]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4.3.0
with:
python-version: '3.11'
- uses: actions/cache@v3.0.11
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- uses: actions/cache@v3.0.11
with:
path: .venv
key: ${{ runner.os }}-py3.11-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-py3.11-venv-
- uses: ./.github/actions/setup-project
- name: Publish to PyPI
run: poetry publish --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
- name: Set version
id: version
run: echo "version=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT
- name: Extract changelog
id: changelog
run: sed -E -n '/^\[${{ steps.version.outputs.version }}\]/,/^\[[0-9\.]+\]/{/^\[[0-9\.]+\]|^-+$/!p;}' CHANGELOG.rst > release-body.rst
- uses: docker://pandoc/core:2.10
with:
args: --standalone --wrap none -f rst -t gfm --output=release-body.md release-body.rst
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
body_path: release-body.md
tag_name: v${{ steps.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}