-
-
Notifications
You must be signed in to change notification settings - Fork 505
188 lines (153 loc) · 4.89 KB
/
main.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# This workflow will install Python dependencies, run tests and converage with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run tests
on:
pull_request:
push:
branches:
- master
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: Cache pip directory
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.9
- uses: actions/cache@v4
name: Cache poetry deps
with:
path: .venv
key: ${{ runner.os }}-build-${{ hashFiles('poetry.lock') }}-3.9
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install poetry
run: |
pip install poetry
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Lint
run: |
poetry run python -m flake8 sh.py tests/*.py
poetry run black --check --diff sh.py tests/*.py
poetry run rstcheck README.rst
poetry run mypy sh.py
test:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
use-select: [0, 1]
lang: [C, en_US.UTF-8]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: Cache pip directory
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.9
- uses: actions/cache@v4
name: Cache poetry deps
env:
cache-name: poetry-deps
with:
path: .venv
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pip install poetry
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run tests
run: |
SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run --data-file=coverage.data -a -m pytest
- name: Store coverage
uses: actions/upload-artifact@v4
with:
name: coverage.${{ matrix.use-select }}.${{ matrix.lang }}.${{ matrix.python-version }}
path: coverage.data
report:
name: Report Coverage
needs: test
runs-on: ubuntu-latest
steps:
# required because coveralls complains if we're not in a git dir
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install coverage coveralls
- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
path: coverage-artifacts
- name: Combine coverage
run: |
find coverage-artifacts -name coverage.data | xargs coverage combine -a
- name: Report coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coverage report
coveralls --service=github
deploy:
name: Deploy
needs: test
runs-on: ubuntu-latest
if: github.ref_name == 'master'
permissions:
contents: write
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Get current version
id: get_version
run: echo "version=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: pip install build
- name: Build
run: python -m build
- name: Tag commit
run: |
git tag "${{steps.get_version.outputs.version}}" "${{github.ref_name}}"
git push -f origin "${{steps.get_version.outputs.version}}"
- name: Get changes
id: changelog
run: |
python dev_scripts/changelog_extract.py ${{ steps.get_version.outputs.version }} \
> release_changes.md
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.version }}
name: Release ${{ steps.get_version.outputs.version }}
body_path: release_changes.md
draft: false
prerelease: false
files: dist/*
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1