-
-
Notifications
You must be signed in to change notification settings - Fork 99
251 lines (220 loc) · 8.52 KB
/
fake-bge-module-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
251
---
# yamllint disable rule:line-length
name: fake-bge-module CI
on: # yamllint disable-line rule:truthy
push:
branches:
- main
- 'run-ci/**'
pull_request:
release:
types:
- released
jobs:
set_versions:
name: Set build versions
runs-on: ubuntu-latest
outputs:
module_version: ${{ steps.set_module_version.outputs.module_version }}
file_version: ${{ steps.set_file_version.outputs.file_version }}
steps:
# Use ISO 8601 date (in UTC) + timestamp (in UTC)
- name: Create generic module version
run: echo "MODULE_VERSION=$(date -u +%Y%m%d).dev$(date -u +%H%M%S)" >> $GITHUB_ENV
# Use the tag name for a release
- name: Override release module version
if: github.event_name == 'release'
run: echo "MODULE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# Add addtional git sha ref
- name: Override PR module version
if: github.event_name == 'pull_request'
run: echo "MODULE_VERSION=${MODULE_VERSION}+${GITHUB_SHA::8}" >> $GITHUB_ENV
# Set module version output
- name: Set module version
id: set_module_version
run: echo ::set-output name=module_version::${MODULE_VERSION}
# Use ISO 8601 timestamps (in UTC) for output/file version
- name: Set file version
id: set_file_version
run: echo ::set-output name=file_version::$(date -u +%Y%m%dT%H%M%SZ)
build_modules:
name: Build modules
runs-on: ubuntu-latest
needs: [set_versions]
strategy:
fail-fast: false
matrix:
upbge_version:
[
"0.2.5",
"0.30", "0.36"
]
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: 'src/requirements.txt'
- name: Install python dependencies
run: |
pip install -r src/requirements.txt
- name: UPBGE downloads cache
uses: actions/cache@v3
id: upbge-bin-cache
with:
path: upbge-bin
key: upbge-binaries-${{ runner.os }}-${{ matrix.upbge_version }}-${{ hashFiles('**/tools/utils/download_upbge.sh') }}
- name: Test fake_bpy_module core module
run: bash tests/run_pre_tests.sh src
- name: Install UPBGE binary dependencies
run: |
sudo apt update
sudo apt install --no-install-recommends -y libglu1-mesa libegl1 libxxf86vm1 libxfixes3 libxi6 libxkbcommon0 libgl1 libjack0 libopenimageio-dev libpulse-dev
- name: Install fake-bge-module tools
run: sudo apt install --no-install-recommends -y pandoc
- name: Download UPBGE files
if: steps.upbge-bin-cache.outputs.cache-hit != 'true'
run: bash tools/utils/download_upbge.sh ${{ matrix.upbge_version }} upbge-bin
- name: Checkout UPBGE from Github
uses: actions/checkout@v4
with:
repository: "upbge/upbge"
path: upbge
- name: Generate pip Packages
if: contains(github.ref, 'run-ci/')
env:
RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }}
GEN_MODULE_CODE_FORMAT: "ruff"
GEN_MODULE_OUTPUT_LOG_LEVEL: "debug"
ENABLE_PYTHON_PROFILER: false
run: bash tools/pip_package/build_pip_package.sh upbge ${{ matrix.upbge_version }} ./upbge ./upbge-bin/upbge-v${{ matrix.upbge_version }}-bin ${{ matrix.upbge_version }}
- name: Generate pip Packages
if: "!contains(github.ref, 'run-ci/')"
env:
RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }}
GEN_MODULE_CODE_FORMAT: "ruff"
GEN_MODULE_OUTPUT_LOG_LEVEL: "warn"
ENABLE_PYTHON_PROFILER: false
run: bash tools/pip_package/build_pip_package.sh upbge ${{ matrix.upbge_version }} ./upbge ./upbge-bin/upbge-v${{ matrix.upbge_version }}-bin ${{ matrix.upbge_version }}
- name: Archive pip packages
uses: actions/upload-artifact@v3
with:
name: fake_bge_modules_${{ matrix.upbge_version}}_pip_${{ needs.set_versions.outputs.file_version }}
path: release
- name: Archive raw modules
uses: actions/upload-artifact@v3
with:
name: fake_bge_modules_${{ matrix.upbge_version}}_raw_${{ needs.set_versions.outputs.file_version }}
path: "raw_modules/fake_bge_module*"
- name: Run Ruff flake8-pyi checks
run: bash tools/pip_package/run_ruff_flake8_pyi.sh upbge ${{ matrix.upbge_version }}
- name: Test Generated Modules
run: bash tests/run_tests.sh raw_modules
- name: Test generated pip module against Cycles addon
# Using a wildcard instead of
# ${{ needs.set_versions.outputs.module_version }} below, because the
# pip filenames do not respect leading zeros:
#
# For example: 00:29:45 UTC will create a file version
# "...dev2945-py3-none..." and not use {{ module_version }}
# "...dev002945-py3-none..."
run: bash tests/pylint_cycles.sh upbge ${{ matrix.upbge_version }} ./upbge/ ./release/${{ matrix.upbge_version }}/fake_bge_module_${{ matrix.upbge_version }}-*-py3-none-any.whl
- name: Collect failure state
if: failure()
run: bash tools/collect_failure_state/collect_failure_state.sh /tmp/failure_state_${{ matrix.upbge_version}}
- name: Store failure state
if: failure()
uses: actions/upload-artifact@v3
with:
name: failure_state_${{ matrix.upbge_version}}
path: /tmp/failure_state_${{ matrix.upbge_version}}
pypi_release_test:
name: PyPI Release test
needs: [build_modules]
if: |
github.repository == 'nutti/fake-bge-module' &&
github.event_name != 'pull_request'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
upbge_version:
[
"0.2.5",
"0.30", "0.36"
]
steps:
- name: Fetch artifacts
uses: actions/download-artifact@v3
with:
path: dist
# Publish to TestPyPi on each merge to main
- name: Publish distribution 📦 to Test PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.test_pypi_token }}
repository_url: https://test.pypi.org/legacy/
packages_dir: "dist/fake_bge_modules_${{ matrix.upbge_version }}_pip_*/*/"
pypi_release:
name: PyPI Release fake-bge-module
needs: [pypi_release_test]
if: |
github.repository == 'nutti/fake-bge-module' &&
github.event_name == 'release'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
upbge_version:
[
"0.2.5",
"0.30", "0.36"
]
steps:
- name: Fetch Artifacts
uses: actions/download-artifact@v3
with:
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.pypi_token }}
packages_dir: "dist/fake_bge_modules_${{ matrix.upbge_version }}_pip_*/*/"
upload_github_release_assets:
name: Upload Artifacts to GitHub Release
needs: [pypi_release_test]
if: |
github.repository == 'nutti/fake-bge-module' &&
github.event_name == 'release'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
upbge_version:
[
"0.2.5",
"0.30", "0.36"
]
steps:
- name: Fetch Artifacts
uses: actions/download-artifact@v3
with:
path: dist
- name: Store Asset Information
run: |
export FAKE_BGE_MODULE_FILEPATH=$(ls -1 dist/fake_bge_modules_${{ matrix.upbge_version }}_raw_*/*.zip | head -n 1) && echo ${FAKE_BGE_MODULE_FILEPATH}
echo "FAKE_BGE_MODULE_FILEPATH=${FAKE_BGE_MODULE_FILEPATH}" >> $GITHUB_ENV
echo "FAKE_BGE_MODULE_FILENAME=$(basename "${FAKE_BGE_MODULE_FILEPATH}")" >> $GITHUB_ENV
echo "MIME_TYPE=$(file --mime-type -b "${FAKE_BGE_MODULE_FILEPATH}")" >> $GITHUB_ENV
- name: Upload ${{ matrix.upbge_version }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_FOR_ACTIONS }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.FAKE_BGE_MODULE_FILEPATH }}
asset_name: ${{ env.FAKE_BGE_MODULE_FILENAME }}
asset_content_type: ${{ env.MIME_TYPE }}