-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IMPROVEMENT: reuse pytest job artifacts by using workflow_run
- Loading branch information
1 parent
9b250be
commit 1abae31
Showing
2 changed files
with
25 additions
and
65 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,29 @@ | ||
name: Codecov | ||
|
||
on: | ||
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] | ||
workflow_run: | ||
workflows: [Pytest] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
run: | ||
upload_coverage_to_codecov: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
- name: Download coverage report | ||
uses: actions/download-artifact@v4 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install pymavlink pytest pytest-cov coverage mock | ||
pip install -U . | ||
- name: Install apt packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y xvfb | ||
- name: Run tests and collect coverage | ||
# run: pytest --cov ardupilot_methodic_configurator | ||
run: | | ||
export DISPLAY=:99 | ||
Xvfb :99 -screen 0 1024x768x16 & | ||
coverage run -m pytest | ||
coverage xml -o tests/coverage.xml | ||
name: coverage-report-3.9 | ||
|
||
- name: Upload coverage report | ||
uses: codecov/codecov-action@v4.0.1 | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
verbose: true | ||
files: tests/coverage-3.9.xml | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,31 @@ | ||
name: Coverage | ||
# Make sure pull requests increase coverage monotonically | ||
|
||
on: [pull_request] | ||
on: | ||
pull_request: | ||
workflow_run: | ||
workflows: [Pytest] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
build: | ||
|
||
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.12"] | ||
jobs: | ||
add_coverage_to_pullrequest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
- name: Download coverage report | ||
uses: actions/download-artifact@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install -U pymavlink pytest pytest-cov coverage mock | ||
pip install build | ||
pip install -U . | ||
- name: Install apt packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y xvfb | ||
- name: Test with unittest | ||
run: | | ||
export DISPLAY=:99 | ||
Xvfb :99 -screen 0 1024x768x16 & | ||
coverage run -m pytest | ||
coverage xml -o tests/coverage.xml | ||
name: coverage-report-3.9 | ||
|
||
- name: Get Cover | ||
uses: andraghetti/[email protected] | ||
with: | ||
coverageFile: tests/coverage.xml | ||
coverageFile: tests/coverage-3.9.xml | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
# Use always() to always run this step to publish test results when there are test failures | ||
if: ${{ always() }} |