-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (127 loc) · 3.99 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
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
name: CI
on:
push:
branches: [master]
tags: ["v*.*.*"]
pull_request:
branches: [master]
defaults:
run:
shell: bash
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: |
pipx install poetry
pipx inject poetry "poetry-dynamic-versioning[plugin]"
- name: Install Python
uses: actions/setup-python@v5
id: setup-python
with:
cache: poetry
python-version: ">=3.9"
- name: Install dependencies
run: poetry install
- name: Cache Pre-Commit Dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Lint with Mypy and Ruff
run: |
poetry run pre-commit run -a
build:
needs: [lint]
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install Poetry
run: |
pipx install poetry
pipx inject poetry "poetry-dynamic-versioning[plugin]"
- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
cache: poetry
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: poetry install --only main,test
- name: Test and Generate Coverage Report
run: |
poetry run pytest -n auto --dist=worksteal \
--cov=src/ --cov-report=lcov --cov-branch --durations=10 \
--color=yes -rs
env:
HYPOTHESIS_PROFILE: ci
- name: Upload Coverage Report
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: "./coverage.lcov"
parallel: true
flag-name: run-${{ matrix.os }}-python-${{ matrix.python-version }}
- name: Build the package into a wheel
run: poetry build
finish-coverage:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Finish Coverage Report
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
publish:
needs: [build, finish-coverage]
runs-on: ubuntu-latest
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install commitizen
run: pipx install commitizen
- name: Get 2nd-last commit tag
id: second-last
run: |
tags="$(git tag --sort=creatordate)"
output=''
# length > 1 means we have multiple tags and we need 2nd last one
if [[ "$(echo "$tags" | grep -c ^)" != "1" ]]; then
output="$(echo "$tags" | tail -2 | head -1)"
fi
echo "tag=$output" >> "$GITHUB_OUTPUT"
- name: Generate Changelog
run: |
# from 2nd-last revision upto this current tag.
cz ch --start-rev '${{ steps.second-last.outputs.tag }}' \
--unreleased-version '${{ github.ref_name }}' \
--file-name body.md
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: body.md
tag_name: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Poetry
run: |
pipx install poetry
pipx inject poetry "poetry-dynamic-versioning[plugin]"
- name: Set Up Python
uses: actions/setup-python@v5
with:
cache: poetry
python-version: ">=3.8"
- name: Publish Package
run: |
poetry publish -u __token__ -p ${{ secrets.PYPI_PASSWORD }}