fix: support Blender's "Reload Scripts" operator #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- dev/* | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
test: | |
# Based on pytest-blender workflow: https://github.com/mondeja/pytest-blender/blob/master/.github/workflows/ci.yml | |
name: Test | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- blender-version: '4.0.2' | |
python-version: '3.10' | |
pytest-version: '7.2.0' | |
pytest-blender-version: '3.0.5' | |
- blender-version: '4.1.0' | |
python-version: '3.11' | |
pytest-version: '7.2.0' | |
pytest-blender-version: '3.0.5' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ 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-* | |
_blender-executable-path.txt | |
key: ${{ runner.os }}-${{ matrix.blender-version }} | |
- name: Download Blender ${{ matrix.blender-version }} | |
if: steps.cache-blender.outputs.cache-hit != 'true' | |
run: | | |
Set-PSDebug -Trace 2 | |
# Use blender-downloader fork with specifes a Sollumz User-Agent since the default python User-Agent is currently blocked | |
# python -m pip install --upgrade blender-downloader | |
python -m pip install git+https://github.com/Sollumz/blender-downloader.git | |
python -m pip list | |
mkdir _blender | |
blender-downloader ${{ matrix.blender-version }} -d _blender --extract --remove-compressed --print-blender-executable --quiet | Out-File -FilePath _blender-executable-path.txt | |
get-content _blender-executable-path.txt | |
- name: Install Dependencies | |
run: | | |
Set-PSDebug -Trace 2 | |
python -m pip install pytest-blender==${{ matrix.pytest-blender-version }} pytest==${{ matrix.pytest-version }} | |
$BLENDER = get-content _blender-executable-path.txt | |
pytest-blender --blender-executable "$BLENDER" | Out-File -FilePath _blender-python-executable-path.txt | |
$BLENDER_PYTHON = get-content _blender-python-executable-path.txt | |
echo "$BLENDER_PYTHON" | |
& "$BLENDER_PYTHON" -m pip install pytest-blender==${{ matrix.pytest-blender-version }} pytest==${{ matrix.pytest-version }} | |
- name: Install Sollumz | |
run: | | |
$BLENDER = get-content _blender-executable-path.txt | |
$BLENDER_RELEASE_VERSION = python -c "print('.'.join('${{ matrix.blender-version }}'.split('.')[:2]))" # extract first two version numbers | |
New-Item -ItemType Directory -Path "$env:APPDATA\Blender Foundation\Blender\$BLENDER_RELEASE_VERSION\scripts\addons" -Force | |
New-Item -ItemType SymbolicLink -Path "$env:APPDATA\Blender Foundation\Blender\$BLENDER_RELEASE_VERSION\scripts\addons" -Name Sollumz -Target $(Get-Location) | |
& "$BLENDER" -b --python-expr "import bpy; bpy.ops.preferences.addon_enable(module='Sollumz'); bpy.ops.wm.save_userpref()" | |
- name: Run Tests | |
run: | | |
$BLENDER = get-content _blender-executable-path.txt | |
$BLENDER_PYTHON = get-content _blender-python-executable-path.txt | |
$env:SOLLUMZ_TEST_TMP_DIR = $(mkdir _test_tmp) | |
& "$BLENDER_PYTHON" -m pytest -svv --ignore _blender --ignore _test_tmp --blender-executable "$BLENDER" |