FEATURE: use a safer eval code, with limited arithmetic capabilities. #208
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 | |
# 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.yml' # Watch for changes in the pyproject.yml file | |
push: | |
paths: | |
- '**/*.py' # Watch for changes in any Python files | |
- 'pyproject.yml' # Watch for changes in the pyproject.yml file | |
workflow_dispatch: | |
release: | |
types: [published] | |
jobs: | |
pytest: | |
if: github.event_name == 'pull_request' || (github.event_name == 'push' && !github.event.pull_request) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
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.13"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[dev] | |
- name: Install apt packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y xvfb | |
- name: Test with pytest | |
id: pytest | |
continue-on-error: true | |
run: | | |
export DISPLAY=:99 | |
Xvfb :99 -screen 0 1024x768x16 & | |
pytest --cov=ardupilot_methodic_configurator --cov-report=xml:tests/coverage.xml --md=tests/results-${{ matrix.python-version }}.md | |
- 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@v4 | |
with: | |
name: coverage-${{ matrix.python-version }}-xml | |
path: tests/coverage.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@v4 | |
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: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download coverage xml report | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-3.9-xml | |
- name: Upload coverage xml report to coveralls.io | |
uses: coverallsapp/github-action@v2 | |
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: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download coverage report | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-3.9 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' # Match with the coverage report Python version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip coverage | |
- name: Check coverage | |
run: | | |
coverage report --fail-under=40 | |
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' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download coverage xml report | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-3.9-xml | |
- name: Get Cover | |
uses: orgoro/[email protected] | |
with: | |
coverageFile: coverage.xml | |
token: ${{ secrets.GITHUB_TOKEN }} |