-
Notifications
You must be signed in to change notification settings - Fork 7
250 lines (243 loc) · 9.08 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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
test:
name: Test
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
include:
# Test in Windows
- platform: windows-latest
pytest-version: '7.1.2'
blender-version: '3.1.2'
# Using 3.10 in Windows due to PIP encoding errors:
# https://github.com/pypa/pip/issues/11066
python-version: '3.10'
# Test previous Blender version
- platform: ubuntu-latest
pytest-version: '7.1.2'
blender-version: '2.82'
python-version: '3.8'
# Test against Pytest v7
- platform: ubuntu-latest
pytest-version: '7.2.0'
blender-version: '3.1.1'
python-version: '3.10'
# Test against Pytest v6
- platform: ubuntu-latest
pytest-version: '6.2.5'
blender-version: '2.93.9'
python-version: '3.9'
# Latest Blender (Py311)
- platform: ubuntu-latest
pytest-version: '7.2.0'
blender-version: '3.1.2'
python-version: '3.11'
# Latest Blender (Py312)
- platform: ubuntu-latest
pytest-version: '7.4.0'
blender-version: '3.1.2'
python-version: '3.12.1'
# Test in MacOS (Py39)
- platform: macos-latest
pytest-version: '6.2.5'
blender-version: '2.93.9'
python-version: '3.9'
# Test in MacOS (Py310)
- platform: macos-latest
pytest-version: '7.1.2'
blender-version: '3.1.2'
python-version: '3.10'
steps:
- uses: actions/checkout@v3
- name: Set up Python v${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade PIP
run: python -m pip install --upgrade pip
- name: Cache Blender ${{ matrix.blender-version }}
uses: actions/cache@v3
id: cache-blender
with:
path: |
blender-*
_blender-executable-path.txt
key: ${{ runner.os }}-${{ matrix.blender-version }}
# Download Blender on Linux and MacOS
- name: Download Blender ${{ matrix.blender-version }}
if: |
steps.cache-blender.outputs.cache-hit != 'true' &&
runner.os != 'Windows'
run: |
set -x
python -m pip install --upgrade blender-downloader
python -m pip list
printf "%s" "$(blender-downloader ${{ matrix.blender-version }} --extract --remove-compressed --print-blender-executable --quiet)" > _blender-executable-path.txt
cat _blender-executable-path.txt
# Download Blender on Windows
- name: Download Blender ${{ matrix.blender-version }}
if: |
steps.cache-blender.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
Set-PSDebug -Trace 2
python -m pip install --upgrade blender-downloader
python -m pip list
blender-downloader ${{ matrix.blender-version }} --extract --remove-compressed --print-blender-executable --quiet | Out-File -FilePath _blender-executable-path.txt
get-content _blender-executable-path.txt
# Install dependencies on Unix-based systems
- name: Install dependencies
if: runner.os != 'Windows'
id: install-dependencies-unix
run: |
set -x
python -m pip install .[test] pytest==${{ matrix.pytest-version }}
BLENDER_EXECUTABLE="$(< _blender-executable-path.txt)"
echo "BLENDER_EXECUTABLE: $BLENDER_EXECUTABLE"
pytest-blender --blender-executable "$BLENDER_EXECUTABLE"
PYTHON_BLENDER_EXECUTABLE="$(pytest-blender --blender-executable $BLENDER_EXECUTABLE)"
echo "PYTHON_BLENDER_EXECUTABLE: $PYTHON_BLENDER_EXECUTABLE"
$PYTHON_BLENDER_EXECUTABLE -m ensurepip
$PYTHON_BLENDER_EXECUTABLE -m pip install pytest==${{ matrix.pytest-version }} pytest-cov
echo "blender-executable=$BLENDER_EXECUTABLE" >> $GITHUB_OUTPUT
# Install dependencies on Windows
- name: Install dependencies
if: runner.os == 'Windows'
id: install-dependencies-windows
run: |
Set-PSDebug -Trace 2
python -m pip install .[test] pytest==${{ matrix.pytest-version }}
$BLENDER_EXECUTABLE = get-content _blender-executable-path.txt
echo "BLENDER_EXECUTABLE: $BLENDER_EXECUTABLE"
pytest-blender --blender-executable $(Get-Variable -Name BLENDER_EXECUTABLE -ValueOnly)
$PYTHON_BLENDER_EXECUTABLE = pytest-blender --blender-executable "$(Get-Variable -Name BLENDER_EXECUTABLE -ValueOnly)"
echo "PYTHON_BLENDER_EXECUTABLE: $PYTHON_BLENDER_EXECUTABLE"
Invoke-Expression "$PYTHON_BLENDER_EXECUTABLE -m pip install pytest==${{ matrix.pytest-version }} pytest-cov"
echo "blender-executable=$BLENDER_EXECUTABLE" >> $env:GITHUB_OUTPUT
- name: Unit tests
if: runner.os != 'Windows'
run: pytest -svv --strict-config --strict-markers tests
env:
BLENDER_EXECUTABLE: ${{ steps.install-dependencies-unix.outputs.blender-executable }}
- name: Unit tests
if: runner.os == 'Windows'
# Created empty pytest.ini file to avoid the reading of setup.cfg
# because there is a problem with encoding on Windows, see:
# https://github.com/pytest-dev/pytest/issues/4441
#
# Note that pytest.ini will always take precedence, even if empty, see:
# https://docs.pytest.org/en/7.1.x/reference/customize.html#finding-the-rootdir
run: |
New-Item -Path 'pytest.ini' -ItemType File
pytest -svv -p no:pytest-blender -p pytester --strict-config --strict-markers tests
env:
BLENDER_EXECUTABLE: ${{ steps.install-dependencies-windows.outputs.blender-executable }}
- name: Integration tests
if: runner.os != 'Windows'
run: sh tests/integration.sh
env:
BLENDER_EXECUTABLE: ${{ steps.install-dependencies-unix.outputs.blender-executable }}
# TODO: integration tests on Windows?
build-sdist:
if: startsWith(github.ref, 'refs/tags/')
needs: test
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: '3.11'
- name: Build sdist
run: python setup.py sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build-wheel:
if: startsWith(github.ref, 'refs/tags/')
needs: test
name: Build wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Set up Python
with:
python-version: '3.11'
- name: Install wheel
run: python -m pip install --upgrade wheel
- name: Build wheel
run: python setup.py bdist_wheel
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl
pypi-upload:
name: Upload to PyPI
needs:
- build-sdist
- build-wheel
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip_existing: true
# repository_url: https://test.pypi.org/legacy/
release:
name: Release
needs:
- build-sdist
- build-wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get tag metadata
id: tag
run: |
TAG_TITLE=${GITHUB_REF#refs/*/}
echo "title=$TAG_TITLE" >> $GITHUB_OUTPUT
git -c protocol.version=2 fetch --prune --progress \
--no-recurse-submodules origin \
+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
TAG_BODY="$(git tag -l --format='%(contents)' $TAG_TITLE)"
TAG_BODY="${TAG_BODY//'%'/'%25'}"
TAG_BODY="${TAG_BODY//$'\n'/'%0A'}"
TAG_BODY="${TAG_BODY//$'\r'/'%0D'}"
echo "body=$TAG_BODY" >> $GITHUB_OUTPUT
- name: Create Release
uses: actions/[email protected]
id: create-release
with:
tag_name: ${{ steps.tag.outputs.title }}
release_name: ${{ steps.tag.outputs.title }}
body: ${{ steps.tag.outputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
name: Download builds
with:
name: artifact
path: dist
- uses: shogo82148/[email protected]
name: Upload release assets
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dist/*