pre-commit update #931
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Package | |
on: | |
push: | |
pull_request: | |
types: [opened, reopened] | |
defaults: | |
run: | |
shell: bash | |
env: | |
git-depth: 0 # Depth to search for tags. | |
jobs: | |
ruff: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Ruff | |
run: pip install ruff | |
- name: Ruff Check | |
run: ruff check . --fix-only --exit-non-zero-on-fix --output-format=github | |
- name: Ruff Format | |
run: ruff format . --check | |
mypy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --depth 1 | |
- name: Install typing dependencies | |
run: pip install mypy pytest -r requirements.txt | |
- name: Mypy | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: mypy | |
run: mypy --show-column-numbers | |
sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- name: APT update | |
run: sudo apt-get update | |
- name: Install APT dependencies | |
run: sudo apt-get install libsdl2-dev | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --depth 1 | |
- name: Install build | |
run: pip install build | |
- name: Build source distribution | |
run: python -m build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: dist/tcod-*.tar.gz | |
retention-days: 7 | |
compression-level: 0 | |
# This makes sure that the latest versions of the SDL headers parse correctly. | |
parse_sdl: | |
needs: [ruff, mypy] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["windows-latest", "macos-latest"] | |
sdl-version: ["2.0.14", "2.0.16"] | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --depth 1 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install build dependencies | |
run: pip install -r requirements.txt | |
- name: Test SDL parsing | |
run: python build_sdl.py | |
env: | |
SDL_VERSION: ${{ matrix.sdl-version }} | |
build: | |
needs: [ruff, mypy] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "windows-latest"] | |
python-version: ["3.8", "pypy-3.8"] | |
architecture: ["x64"] | |
include: | |
- os: "windows-latest" | |
python-version: "3.8" | |
architecture: "x86" | |
- os: "windows-latest" | |
python-version: "pypy-3.8" | |
architecture: "x86" | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Checkout submodules | |
run: | | |
git submodule update --init --recursive --depth 1 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.architecture }} | |
- name: Install APT dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install libsdl2-dev xvfb | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-cov pytest-benchmark pytest-timeout build | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Initialize package | |
run: | | |
pip install -e . # Install the package in-place. | |
- name: Build package | |
run: | | |
python -m build | |
- name: Test with pytest | |
if: runner.os == 'Windows' | |
run: | | |
pytest --cov-report=xml --timeout=300 | |
- name: Test with pytest (Xvfb) | |
if: always() && runner.os != 'Windows' | |
run: | | |
xvfb-run -e /tmp/xvfb.log --server-num=$RANDOM --auto-servernum pytest --cov-report=xml --timeout=300 | |
- name: Xvfb logs | |
if: runner.os != 'Windows' | |
run: cat /tmp/xvfb.log | |
- uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
if: runner.os == 'Windows' | |
with: | |
name: wheels-windows-${{ matrix.architecture }}-${{ matrix.python-version }} | |
path: dist/*.whl | |
retention-days: 7 | |
compression-level: 0 | |
test-docs: | |
needs: [ruff, mypy] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install APT dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install libsdl2-dev | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --depth 1 | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r docs/requirements.txt | |
- name: Install package | |
run: pip install -e . | |
env: | |
TDL_BUILD: DEBUG | |
- name: Test doc generation | |
working-directory: docs | |
run: python -m sphinx -T -E -W --keep-going . _build/html | |
tox: | |
needs: [ruff] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "windows-latest"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Checkout submodules | |
run: git submodule update --init --depth 1 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip tox | |
- name: Install APT dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install libsdl2-dev | |
- name: Run tox | |
run: | | |
tox -vv | |
linux-wheels: | |
needs: [ruff, mypy] | |
runs-on: "ubuntu-latest" | |
strategy: | |
matrix: | |
arch: ["x86_64", "aarch64"] | |
build: ["cp38-manylinux*", "pp38-manylinux*"] | |
env: | |
BUILD_DESC: | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Set up QEMU | |
if: ${{ matrix.arch == 'aarch64' }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Checkout submodules | |
run: | | |
git submodule update --init --recursive --depth 1 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install cibuildwheel==2.19.2 | |
- name: Build wheels | |
run: | | |
python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_BUILD: ${{ matrix.build }} | |
CIBW_ARCHS_LINUX: ${{ matrix.arch }} | |
CIBW_MANYLINUX_*_IMAGE: manylinux2014 | |
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux2014 | |
CIBW_MANYLINUX_PYPY_AARCH64_IMAGE: manylinux2014 | |
CIBW_BEFORE_ALL_LINUX: > | |
yum install -y epel-release && | |
yum-config-manager --enable epel && | |
yum install -y SDL2-devel | |
CIBW_BEFORE_TEST: pip install numpy | |
CIBW_TEST_COMMAND: python -c "import tcod.context" | |
# Skip test on emulated architectures | |
CIBW_TEST_SKIP: "*_aarch64" | |
- name: Remove asterisk from label | |
run: | | |
BUILD_DESC=${{ matrix.build }} | |
BUILD_DESC=${BUILD_DESC//\*} | |
echo BUILD_DESC=${BUILD_DESC} >> $GITHUB_ENV | |
- name: Archive wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.arch }}-${{ env.BUILD_DESC }} | |
path: wheelhouse/*.whl | |
retention-days: 7 | |
compression-level: 0 | |
build-macos: | |
needs: [ruff, mypy] | |
runs-on: "macos-14" | |
strategy: | |
fail-fast: true | |
matrix: | |
python: ["cp38-*_universal2", "pp38-*"] | |
env: | |
PYTHON_DESC: | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.git-depth }} | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --depth 1 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install Python dependencies | |
run: pip install -r requirements.txt | |
- name: Prepare package | |
# Downloads SDL2 for the later step. | |
run: python build_sdl.py | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{ matrix.python }} | |
CIBW_ARCHS_MACOS: x86_64 arm64 universal2 | |
CIBW_BEFORE_BUILD_MACOS: pip install --upgrade delocate | |
CIBW_BEFORE_TEST: pip install numpy | |
CIBW_TEST_COMMAND: python -c "import tcod.context" | |
CIBW_TEST_SKIP: "pp* *-macosx_arm64 *-macosx_universal2:arm64" | |
MACOSX_DEPLOYMENT_TARGET: "10.11" | |
- name: Remove asterisk from label | |
run: | | |
PYTHON_DESC=${{ matrix.python }} | |
PYTHON_DESC=${PYTHON_DESC//\*/X} | |
echo PYTHON_DESC=${PYTHON_DESC} >> $GITHUB_ENV | |
- name: Archive wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos-${{ env.PYTHON_DESC }} | |
path: wheelhouse/*.whl | |
retention-days: 7 | |
compression-level: 0 | |
publish: | |
needs: [sdist, build, build-macos, linux-wheels] | |
runs-on: ubuntu-latest | |
if: github.ref_type == 'tag' | |
environment: | |
name: pypi | |
url: https://pypi.org/project/tcod/${{ github.ref_name }} | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist/ | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
path: dist/ | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true |