-
-
Notifications
You must be signed in to change notification settings - Fork 2
198 lines (165 loc) · 4.74 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
189
190
191
192
193
194
195
196
197
198
name: Tests
on:
push:
paths-ignore:
- "docs/**"
- "**.md"
- "**.ipynb"
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
- "**.ipynb"
env:
COVERAGE_ALERT: 90
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
name: Cache pip directory
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10
- uses: actions/cache@v2
name: Cache poetry deps
with:
path: .venv
key: ${{ runner.os }}-build-${{ hashFiles('poetry.lock') }}-3.10
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- 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 heimdallm/
poetry run black --check --diff heimdallm/
poetry run mypy heimdallm
poetry run sphinx-build docs/source docs/build -a -W
test:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
name: Cache pip directory
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10
- uses: actions/cache@v2
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@v2
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: |
poetry run coverage run -m pytest heimdallm
- name: Store coverage
uses: actions/upload-artifact@v2
with:
name: coverage.${{ matrix.python-version }}
path: .coverage
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@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install coverage coveralls
- name: Download coverage artifacts
uses: actions/download-artifact@v2
with:
path: coverage-artifacts
- name: Combine coverage
run: |
find coverage-artifacts -name .coverage | xargs coverage combine -a
- name: Report coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coverage report --fail-under ${{ env.COVERAGE_ALERT }}
coveralls --service=github
deploy:
name: Deploy
environment: prod
runs-on: ubuntu-latest
needs:
- lint
- test
permissions:
contents: write
id-token: write
if: github.ref_name == 'main'
steps:
- uses: actions/checkout@v2
- name: Tag commit
id: tag-commit
run: |
version=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml)
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
git tag "$version" "${{github.ref_name}}"
git push origin "$version" || true
- name: Get changes
id: changelog
run: |
python dev_scripts/changelog_extract.py ${{ steps.tag-commit.outputs.VERSION }} \
> release_changes.md
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install poetry
run: |
pip install poetry
- name: Build
run: poetry build
- name: Store packages
uses: actions/upload-artifact@v2
with:
name: packages
path: dist/*
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag-commit.outputs.VERSION }}
name: Release ${{ steps.tag-commit.outputs.VERSION }}
body_path: release_changes.md
draft: false
prerelease: false
files: dist/*
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1