-
Notifications
You must be signed in to change notification settings - Fork 2
197 lines (183 loc) · 5.5 KB
/
default.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
name: default
on: [push, pull_request]
jobs:
pre-commit-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
- name: Cache pre-commit dependencies
id: cache_pre_commit
uses: actions/cache@v3
with:
path: |
.pre_commit_venv
~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml','~/.cache/pre-commit/*') }}
- name: Install pre-commit
if: steps.cache_pre_commit.outputs.cache-hit != 'true'
run: |
python -m venv .pre_commit_venv
. .pre_commit_venv/bin/activate
pip install --upgrade pip
pip install pre-commit
pre-commit install --install-hooks
pre-commit gc
- name: Run pre-commit hooks
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
. .pre_commit_venv/bin/activate
pre-commit run --color=always --all-files
test-unit:
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 4s
--health-timeout 2s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.cfg
requirements/test.txt
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev
python -m pip install -U pip setuptools wheel
python -m pip install -U -e ".[build,test,zeromq,redis,thrift,snappy]"
- name: Run unit tests
env:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
python -m pytest --cov tests
- name: Upload coverage report
uses: codecov/codecov-action@v3
test-integration:
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 4s
--health-timeout 2s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.cfg
requirements/test.txt
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev
python -m pip install -U pip setuptools wheel
python -m pip install -U -e ".[build,test,zeromq,redis,thrift,snappy]"
- name: Run integration tests
env:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
./scripts/run-integration-tests.sh
build-distributions:
needs: [pre-commit-check, test-unit, test-integration]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch remote tags
run: git fetch origin 'refs/tags/*:refs/tags/*' -f
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.cfg
requirements/build.txt
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements/build.txt
- name: Build packages
run: |
python -c "import callosum; print(callosum.__version__)" | tee version.txt
python -m build -s -w
- name: Upload the build version
uses: actions/upload-artifact@v3
with:
name: version
path: version.txt
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: distributions
path: dist
publish:
needs: [build-distributions]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download the build version
uses: actions/download-artifact@v3
with:
name: version
path: .
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: distributions
path: dist
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
- name: Extract the release changelog
run: |
python ./scripts/extract-release-changelog.py
python ./scripts/determine-release-type.py
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
body_path: "CHANGELOG_RELEASE.md"
prerelease: ${{ env.IS_PRERELEASE }}
files: |
dist/*.tar.gz
dist/*.whl
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1