Skip to content

add OSes to workflow matrix for Python and Rust tests #338

add OSes to workflow matrix for Python and Rust tests

add OSes to workflow matrix for Python and Rust tests #338

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: main
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
python-version: ["3.10", "3.11", "3.12"]
steps:
# on Windows, make sure line-endings are consistent for test suite
- if: runner.os == 'Windows'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- name: Install gettext for translation testing (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get install gettext
- name: Install gettext for translation testing (macOS)
if: runner.os == 'macOS'
run: brew install gettext
- name: Install gettext for translation testing (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
LATEST_URL=$(curl -s "https://api.github.com/repos/vslavik/gettext-tools-windows/releases/latest" |
grep -o 'https://github.com/vslavik/gettext-tools-windows/releases/download/[^"]*\.zip')
curl -L "$LATEST_URL" -o "$RUNNER_TEMP/gettext.zip"
unzip "$RUNNER_TEMP/gettext.zip" -d "$RUNNER_TEMP/gettext"
echo "$RUNNER_TEMP/gettext/bin" >> $GITHUB_PATH
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Create and activate virtual environment (Unix)
if: runner.os != 'Windows'
run: |
python -m venv .venv
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Create and activate virtual environment (Windows)
if: runner.os == 'Windows'
run: |
python -m venv .venv
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
echo "$(pwd)/.venv/Scripts" >> $GITHUB_PATH
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pytest-cov
- name: Install Django Rusty Templates
run: |
cargo llvm-cov show-env --export-prefix > llvm-cov-env.sh
source llvm-cov-env.sh
maturin develop
- name: Build translation files
run: |
python -m django compilemessages
- name: Lint test files
run: |
ruff check
- name: Test with pytest
run: |
cargo llvm-cov show-env --export-prefix > llvm-cov-env.sh
source llvm-cov-env.sh
pytest --cov --cov-report=xml -v
- name: Get rust coverage report
run: |
cargo llvm-cov show-env --export-prefix > llvm-cov-env.sh
source llvm-cov-env.sh
cargo llvm-cov report --codecov --output-path codecov.json
- name: Upload to codecov
uses: codecov/codecov-action@v5
with:
files: coverage.xml, codecov.json
fail_ci_if_error: true