Skip to content

fix(motor test): There was a error popup about functools.partial #2193

fix(motor test): There was a error popup about functools.partial

fix(motor test): There was a error popup about functools.partial #2193

Workflow file for this run

name: Pytest
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#packaging-workflow-data-as-artifacts
on:
pull_request:
paths:
- '**/*.py' # Watch for changes in any Python files
- 'pyproject.toml' # Watch for changes in the pyproject.toml file
- '.github/workflows/pytest.yml'
push:
branches:
- master # Only run on push to master branch
paths:
- '**/*.py' # Watch for changes in any Python files
- 'pyproject.toml' # Watch for changes in the pyproject.toml file
- '.github/workflows/pytest.yml'
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
jobs:
pytest:
if: github.event_name == 'pull_request' || (github.event_name == 'push' && !github.event.pull_request) || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
# python-version: ["3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
os: [ubuntu-latest]
python-version: ["3.9", "3.14", "3.14t"]
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# https://docs.astral.sh/uv/guides/integration/github/
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
- name: Install system dependencies for GUI testing
run: |
sudo apt-get update
# Only install system Tcl/Tk for Python < 3.13 (newer versions bundle their own)
if [[ "${{ matrix.python-version }}" < "3.13" ]]; then
echo "Installing system Tcl/Tk 8.6 for Python ${{ matrix.python-version }}"
sudo apt-get install -y python3-tk tcl8.6 tk8.6 libtcl8.6 libtk8.6
else
echo "Python ${{ matrix.python-version }} uses bundled Tcl/Tk, skipping system packages"
# Only install tools, not Tcl/Tk libraries
sudo apt-get install -y scrot xdotool x11-utils gnome-screenshot
fi
python3 --version && python3 -c "import tkinter; print(tkinter.TclVersion, tkinter.TkVersion)"
- name: Ensure Tcl/Tk search paths
run: |
# Only set Tcl/Tk paths for Python < 3.13
if [[ "${{ matrix.python-version }}" < "3.13" ]]; then
echo "Setting Tcl/Tk paths for Python ${{ matrix.python-version }}"
echo "TCL_LIBRARY=/usr/share/tcltk/tcl8.6" >> $GITHUB_ENV
echo "TK_LIBRARY=/usr/share/tcltk/tk8.6" >> $GITHUB_ENV
else
echo "Python ${{ matrix.python-version }} uses bundled Tcl/Tk, no custom paths needed"
fi
- name: Install dependencies and application
# without --editable, the coverage report is not generated correctly
run: |
uv pip install --editable .[dev,ci_headless_tests]
- name: Download ArduCopter SITL (if available)
run: |
# Create cache key based on current quarter (YYYY-Q)
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%m)
QUARTER=$(( (CURRENT_MONTH-1)/3 + 1 ))
CACHE_KEY="${CURRENT_YEAR}-Q${QUARTER}"
echo "Cache key: ${CACHE_KEY}"
# Check if we have cached SITL files for this quarter
if [ -d "sitl-cache/${CACHE_KEY}" ] && [ -f "sitl-cache/${CACHE_KEY}/arducopter" ]; then
echo "Using cached SITL files from ${CACHE_KEY}"
mkdir -p sitl/
cp sitl-cache/${CACHE_KEY}/* sitl/
else
echo "Downloading fresh SITL files for ${CACHE_KEY}"
mkdir -p sitl/ sitl-cache/${CACHE_KEY}/
# Download latest ArduCopter SITL from official firmware server
curl -L -o sitl/arducopter https://firmware.ardupilot.org/Copter/latest/SITL_x86_64_linux_gnu/arducopter
curl -L -o sitl/firmware-version.txt https://firmware.ardupilot.org/Copter/latest/SITL_x86_64_linux_gnu/firmware-version.txt
curl -L -o sitl/git-version.txt https://firmware.ardupilot.org/Copter/latest/SITL_x86_64_linux_gnu/git-version.txt
# Cache the downloaded files
cp sitl/* sitl-cache/${CACHE_KEY}/
fi
# Make executable and verify
chmod +x sitl/arducopter
ls -la sitl/
# Set environment variables
echo "SITL_BINARY=$(pwd)/sitl/arducopter" >> $GITHUB_ENV
echo "SITL_AVAILABLE=true" >> $GITHUB_ENV
echo "SITL version: $(cat sitl/git-version.txt)"
echo "Firmware version: $(cat sitl/firmware-version.txt)"
continue-on-error: true
- name: Cache SITL files
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: sitl-cache/
key: sitl-cache-${{ github.run_id }}
restore-keys: |
sitl-cache-
- name: Test with pytest
id: pytest
continue-on-error: false
run: |
export LIBGL_ALWAYS_SOFTWARE=1
export DISPLAY=:99
# disable X authentication
export XAUTHORITY=/dev/null
# disable access control restrictions
Xvfb :99 -screen 0 1024x768x16 -ac &
# ensure Xvfb is fully started before running tests
sleep 2
if [ "$SITL_AVAILABLE" = "true" ]; then
echo "Running tests with SITL support"
uv run pytest --cov=ardupilot_methodic_configurator --cov-report=xml:tests/coverage.xml --md=tests/results-${{ matrix.python-version }}.md --junit-xml=tests/results-junit.xml -m "sitl or not sitl"
else
echo "Running tests without SITL (mocked tests only)"
uv run pytest --cov=ardupilot_methodic_configurator --cov-report=xml:tests/coverage.xml --md=tests/results-${{ matrix.python-version }}.md --junit-xml=tests/results-junit.xml -m "not sitl"
fi
- name: Fix coverage paths
run: |
sed -i 's|<package name="." |<package name="ardupilot_methodic_configurator" |' tests/coverage.xml
sed -i 's|<source>.*</source>|<source>.</source>|' tests/coverage.xml
sed -i 's|filename="|filename="ardupilot_methodic_configurator/|g' tests/coverage.xml
shell: bash
- name: Display test results as GitHub job summary
run: cat tests/results-${{ matrix.python-version }}.md >> $GITHUB_STEP_SUMMARY
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload coverage xml report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: coverage-${{ matrix.python-version }}-xml
path: tests/*.xml
retention-days: 1
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload coverage report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
include-hidden-files: true
retention-days: 1
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
upload_coverage_to_coveralls:
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') && (success() || failure())
runs-on: ubuntu-latest
needs: pytest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download coverage xml report
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: coverage-3.9-xml
- name: Upload coverage xml report to coveralls.io
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: coverage.xml
# TODO: create a badge that presents the result of the Upload coverage xml report step
check_coverage:
if: success() || failure()
runs-on: ubuntu-latest
needs: pytest # This will ensure this job runs after 'pytest'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download coverage report
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: coverage-3.9
# https://docs.astral.sh/uv/guides/integration/github/
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
with:
python-version: '3.9' # Match with the coverage report Python version
activate-environment: true
- name: Install dependencies
run: |
uv pip install .[dev]
- name: Check coverage
run: |
# Check if pytest job failed
if [ "${{ needs.pytest.result }}" == "failure" ]; then
echo "Pytest failed - failing coverage check"
exit 1
fi
coverage report --fail-under=89
publish-test-results:
if: always()
name: "Publish Tests Results"
runs-on: ubuntu-latest
needs: pytest # This will ensure this job runs after 'pytest'
permissions:
checks: write
# only needed unless run with comment_mode: off
pull-requests: write
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Download Artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@27d65e188ec43221b20d26de30f4892fad91df2f # v2.22.0
id: test-results
with:
files: "artifacts/**/results-junit.xml"
- name: Set badge color
shell: bash
run: |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
success)
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
;;
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: Create badge
uses: emibcn/badge-action@808173dd03e2f30c980d03ee49e181626088eee8
with:
label: Tests
status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
color: ${{ env.BADGE_COLOR }}
path: badge.svg
- name: Upload badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@ab30bf28df67017c7ad696500b218558c7c04db3
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/amilcarlucas/81b511dc0ff92b8072613d1cd100832e
file: badge.svg
add_coverage_to_pullrequest:
if: github.event_name == 'pull_request' && (success() || failure())
runs-on: ubuntu-latest
needs: pytest # This will ensure this job runs after 'pytest'
permissions:
contents: read
pull-requests: write
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download coverage xml report
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: coverage-3.9-xml
- name: Get Cover
uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac # v3.2
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.89