Fix some errors #308
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 check for changed files, install Python dependencies and | |
# run tests 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: Python Tests | |
on: | |
# run on each push to every branch of the repository but only on | |
# pull requests to the 'master' and 'branch-*' branches | |
push: | |
pull_request: | |
branches: | |
- 'master' | |
- 'branch-*' | |
jobs: | |
pre_check: | |
name: 'Check for code changes' | |
runs-on: ubuntu-latest | |
outputs: | |
run_tests: ${{ steps.changes.outputs.python_test}} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: .github/filters.yml | |
list-files: 'json' | |
build: | |
name: 'Run tests with Python' | |
needs: pre_check | |
if: needs.pre_check.outputs.run_tests == 'true' | |
runs-on: ubuntu-22.04 | |
strategy: | |
# don't cancel running matrix tests when one test fails | |
fail-fast: false | |
matrix: | |
# current supported Python versions | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# clone submodules as well | |
submodules: 'recursive' | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache pip installation | |
uses: actions/cache@v3 | |
id: pip-cache | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-py_${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'tests/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip-py_${{ matrix.python-version }}- | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
# create the virtual environment | |
run: | | |
python -m pip install --upgrade pip setuptools | |
pip install -r tests/requirements.txt | |
- name: Test with pytest | |
id: pytest_run | |
run: | | |
pip freeze | |
python -b -m pytest -v --cov=privacyidea --cov-report=xml tests/ | |
env: | |
# Output DeprecationWarnings only once | |
PYTHONWARNINGS: "once::DeprecationWarning" | |
- name: Codecov upload | |
if: ${{ steps.pytest_run.outcome == 'success' }} | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.xml |