[pre-commit.ci] pre-commit autoupdate #489
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
# Copyright 2023 Jan-Hendrik Ewers | |
# SPDX-License-Identifier: GPL-3.0-only | |
name: CI | |
on: | |
push: | |
branches: [master, dev] | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
run-tests: | |
name: Run tests | |
runs-on: ${{ matrix.platform }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
max-parallel: 1 | |
matrix: | |
include: | |
- python-version: "3.11" | |
pytest-flags: "" | |
codecov: true | |
platform: "ubuntu-latest" | |
- python-version: "3.11" | |
pytest-flags: "" | |
codecov: false | |
platform: "ubuntu-latest" | |
- python-version: "3.10" | |
pytest-flags: "" | |
codecov: false | |
platform: "ubuntu-latest" | |
- python-version: "3.11" | |
pytest-flags: "--only-integration" | |
codecov: false | |
platform: "ubuntu-latest" | |
- python-version: "3.10" | |
pytest-flags: "--only-integration" | |
codecov: false | |
platform: "ubuntu-latest" | |
- python-version: "3.11" | |
pytest-flags: "--only-slow-integration" | |
codecov: false | |
platform: "ubuntu-latest" | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
cache: "pip" | |
python-version: ${{ matrix.python-version }} | |
cache-dependency-path: | | |
**/requirements*.txt | |
- uses: syphar/restore-virtualenv@v1 | |
id: cache-virtualenv | |
- name: Install dependencies | |
if: steps.cache-virtualenv.outputs.cache-hit != 'true' | |
run: | | |
pip install -r requirements.txt -r tests/requirements.txt | |
- name: Install jdrones | |
run: pip install . | |
- name: Run tests | |
run: | | |
NUMBA_DISABLE_JIT=${{ matrix.codecov }} \ | |
PYTHONPATH=tests \ | |
pytest tests \ | |
--cov-report=xml \ | |
--cov-branch \ | |
--cov jdrones \ | |
--cov-report term-missing \ | |
${{ matrix.pytest-flags }} | |
- name: Upload code test coverage report | |
uses: codecov/[email protected] | |
if: ${{ ! contains(github.actor, '[bot]') && ( matrix.codecov ) && ( !env.ACT ) }} | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.xml,./coverage.info | |
fail_ci_if_error: true | |
build-python: | |
name: Build python | |
needs: run-tests | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Build wheels | |
run: pip wheel . --no-deps | |
run-doc-tests: | |
name: Run doctests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
cache: "pip" | |
python-version: "3.11" | |
cache-dependency-path: | | |
docs/requirements.txt | |
- name: Install dependencies | |
run: | | |
pip install . -r requirements.txt -r tests/requirements.txt | |
- name: Run doctests | |
run : | | |
python -m doctest $(\ | |
find src/jdrones -iname "*.py" -not -iname "__main__.py" -not -iname "__init__.py"| \ | |
tr '\n' ' ' \ | |
) | |
docstr-cov: | |
runs-on: ubuntu-latest | |
if: ${{ ! contains(github.actor, '[bot]') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
cache: "pip" | |
cache-dependency-path: | | |
.github/workflows/requirements.docstr-cov.txt | |
- name: Install docstr-coverage | |
run: pip install -r .github/workflows/requirements.docstr-cov.txt | |
- name: Get SHAs | |
run: | | |
git config advice.detachedHead false | |
if [[ ${{ github.event_name }} == 'push' ]]; then | |
echo "BASE=$(git rev-parse --short HEAD^)" >> $GITHUB_ENV | |
echo "HEAD=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
elif [[ ${{ github.event_name }} == 'pull_request' ]]; then | |
echo "BASE=$(git rev-parse --short ${{ github.event.pull_request.base.sha }})" >> $GITHUB_ENV | |
echo "HEAD=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV | |
else | |
echo "Unexpected event trigger" | |
exit 1 | |
fi | |
- name: Get $HEAD coverage | |
run: | | |
P=$(docstr-coverage -F0 -p) | |
if [ -z "$P" ] | |
then | |
P=0 | |
fi | |
echo "HEAD_COV=$P" >> $GITHUB_ENV | |
- name: Get $BASE coverage | |
run: | | |
git checkout $BASE | |
P=$(docstr-coverage -F0 -p) | |
if [ -z "$P" ] | |
then | |
P=0 | |
fi | |
echo "BASE_COV=$P" >> $GITHUB_ENV | |
- name: Test $HEAD coverage | |
run: | | |
printf "%s coverage was: %.2f%%\n" $BASE $BASE_COV | |
printf "%s coverage was: %.2f%%\n" $HEAD $HEAD_COV | |
printf "Difference: %.2f%%\n" $(python -c "print($HEAD_COV - $BASE_COV)") | |
git checkout $HEAD | |
docstr-coverage --fail-under=$BASE_COV |