Skip to content

Merge from main

Merge from main #50

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: Unitest with pytest
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
workflow_call:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.12", "3.x"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
# This is the version of the action for setting up Python, not the Python version.
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Check to make sure that the module is in your Python path
run: |
echo $PYTHONPATH
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest
pip install -r requirements.txt
- name: Version check
run: |
pytest --version
- name: Unitest with pytest
run: |
python -m pytest tests/ -v -rP --doctest-modules --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml --cov-report term-missing --cov=lessons --cov-report html:test-coverage-${{ matrix.os }}-${{ matrix.python-version }}.html
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
# Name of the artifact to upload.
# Optional. Default is 'artifact'
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
# A file, directory or wildcard pattern that describes what to upload
# Required.
path: junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml
# If true, an artifact with a matching name will be deleted before a new one is uploaded.
# If false, the action will fail if an artifact for the given name already exists.
# Does not fail if the artifact does not exist.
# Optional. Default is 'false'
overwrite: False
- name: Upload pytest coverage
uses: actions/upload-artifact@v4
with:
name: pytest-coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: test-coverage-${{ matrix.os }}-${{ matrix.python-version }}.html
# The retention-days value cannot exceed the retention limit set by the repository,
# organization, or enterprise.
# You can define a custom retention period for individual artifacts created by a workflow.
# When using a workflow to create a new artifact, you can use retention-days with the upload-artifact action.
retention-days: 7
# If true, an artifact with a matching name will be deleted before a new one is uploaded.
# If false, the action will fail if an artifact for the given name already exists.
# Does not fail if the artifact does not exist.
# Optional. Default is 'false'
overwrite: False
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}