Fix import of custom types (#109) #71
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: pytest | |
on: | |
push: | |
paths: | |
- '**/*.py' | |
- '**/*.rs' | |
- 'pytest.ini' | |
merge_group: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
schedule: | |
- cron: 0 5 * * 1 # Every Monday at 5:00 UTC | |
jobs: | |
unittesting: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
# ubuntu-20.04-arm was not stable enough when testing | |
platform: | |
- runner: ubuntu-latest # x64 | |
- runner: windows-latest # x64 | |
- runner: macos-13 # Intel | |
- runner: macos-14 # arm64 | |
- runner: macos-latest # arm64 | |
if: github.event_name != 'schedule' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Get pip cache directory | |
id: pip-cache | |
shell: bash | |
run: | | |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Use cached venv or create it | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
# The cache key depends on requirements.txt | |
key: ${{ matrix.platform.runner }}-pip-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements*.txt') }}-${{ hashFiles('test_requirements*.txt') }} | |
# Build a virtualenv, but only if it doesn't already exist | |
- name: Populate pip cache | |
# requirements.txt is not reliable since across different platforms and | |
# their versions the pip package versions might vary. We regenerate it | |
# again from pyproject.toml every time when pyproject.toml or | |
# requirements.txt changes. The pinned versions in requirements.txt are | |
# tested by coverage since that is running on ubuntu which is also used | |
# to produce the main requirements.txt file. | |
run: | | |
pip install pip-tools | |
pip-compile --generate-hashes pyproject.toml > requirements.txt | |
pip install -r requirements.txt | |
pip install -r test_requirements.txt | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Save cache | |
id: cache-save | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Install sedpack locally | |
run: pip install --editable . | |
- name: Running unit tests | |
run: | | |
python -m pytest | |
coverage: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Get pip cache directory | |
id: pip-cache | |
shell: bash | |
run: | | |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Use cached venv or create it | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
# The cache key depends on requirements.txt | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }}-${{ hashFiles('test_requirements*.txt') }} | |
# Build a virtualenv, but only if it doesn't already exist | |
- name: Populate pip cache | |
run: | | |
python -m pip install --require-hashes --no-deps -r requirements.txt | |
pip install -r test_requirements.txt | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Save cache | |
id: cache-save | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Installing test requirements and sedpack | |
# Start by "installing" sedpack to be sure all dependencies are listed | |
run: | | |
pip install --editable . | |
echo "PYTHONPATH=./src:$PYTHONPATH" >> $GITHUB_ENV | |
- name: Install workflow dependencies | |
run: pip install --upgrade pytest coverage | |
- name: Running unit tests with coverage | |
env: | |
DISABLE_AUTOGRAPH: 1 | |
# TODO remove the -i (ignore errors) | |
run: | | |
coverage run -m pytest | |
coverage xml -i | |
- name: Upload results | |
uses: coverallsapp/github-action@v2 | |
with: | |
file: coverage.xml | |