Skip to content

Test

Test #34

Workflow file for this run

name: Test
on:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
linting:
name: Linting
runs-on: windows-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.7.x
architecture: x64
- uses: actions/checkout@v4
- name: Install
run: pip install flake8 pylint codespell
- name: Run scripts
run: |
flake8
python for_dev/lint.py --path=addons/blender_dds_addon
codespell -S ".git,.pytest_cache,external,htmlcov"
test:
# Most code is from pytest-blender's workflow by mondeja.
# https://github.com/mondeja/pytest-blender/blob/master/.github/workflows/ci.yml
name: Test-${{ matrix.platform }}-${{ matrix.blender-version }}
runs-on: ${{ matrix.platform }}
env:
pytest-version: '7.1.2'
python-version: '3.10'
strategy:
fail-fast: false
matrix:
include:
# Test with 2.83, 3.3, 3.6, and 4.0 on Windows
- platform: windows-latest
blender-version: '4.0.2'
- platform: windows-latest
blender-version: '3.6.9'
- platform: windows-latest
blender-version: '3.3.16'
- platform: windows-latest
blender-version: '2.83.20'
# Test with 3.6 on Unix/Linux systems
- platform: ubuntu-latest
blender-version: '3.6.9'
- platform: macos-latest
blender-version: '3.6.9'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: get sal.h (for Unix)
if: runner.os!='Windows'
run: bash external/Texconv-Custom-DLL/shell_scripts/get_sal.sh
- name: build dll (for Windows)
if: runner.os=='Windows'
run: |
external/Texconv-Custom-DLL/batch_files/build_without_vcruntime.bat
cp external/Texconv-Custom-DLL/texconv.dll addons/blender_dds_addon/directx
external/build_astcenc.bat
cp external/astc-encoder/astcenc-sse2-shared.dll addons/blender_dds_addon/astcenc
- name: build shared library (for Unix)
if: runner.os!='Windows'
run: |
bash external/Texconv-Custom-DLL/shell_scripts/build_universal.sh
cp external/Texconv-Custom-DLL/libtexconv.* addons/blender_dds_addon/directx
bash external/build_astcenc_${{ runner.os }}.sh
cp external/astc-encoder/libastcenc* addons/blender_dds_addon/astcenc
- name: Set up Python v${{ env.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
- name: Upgrade PIP
run: python -m pip install --upgrade pip
- name: Cache Blender ${{ matrix.blender-version }}
uses: actions/cache@v4
id: cache-blender
with:
path: |
blender-*
_blender-executable-path.txt
key: blender-${{ runner.os }}-${{ matrix.blender-version }}
# Download Blender on Windows
- name: Download Blender ${{ matrix.blender-version }}
if: |
steps.cache-blender.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
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
# 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
# Install dependencies on Windows
- name: Install dependencies for Windows
if: runner.os == 'Windows'
id: install-dependencies-windows
run: |
python -m pip install pytest-blender pytest==${{ env.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==${{ env.pytest-version }}"
echo "blender-executable=$BLENDER_EXECUTABLE" >> "$env:GITHUB_OUTPUT"
# Install dependencies on Unix-based systems
- name: Install dependencies for Unix
if: runner.os != 'Windows'
id: install-dependencies-unix
run: |
set -x
python -m pip install pytest-blender pytest==${{ env.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==${{ env.pytest-version }}
echo "blender-executable=$BLENDER_EXECUTABLE" >> "$GITHUB_OUTPUT"
- name: Tests for Windows
if: runner.os == 'Windows'
run: pytest tests -svv
env:
BLENDER_EXECUTABLE: ${{ steps.install-dependencies-windows.outputs.blender-executable }}
- name: Tests for Unix
if: runner.os != 'Windows'
run: pytest -svv tests -- -noaudio
env:
BLENDER_EXECUTABLE: ${{ steps.install-dependencies-unix.outputs.blender-executable }}