Merge pull request #162 from Helmholtz-AI-Energy/pre-commit-ci-update… #259
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: Python test | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up MPI | |
uses: mpi4py/setup-mpi@v1 | |
with: | |
mpi: 'openmpi' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install ."[test]" | |
- name: Lint with ruff | |
run: | | |
# Stop the build if there are Python syntax errors or undefined names. | |
ruff check --output-format=github --select=E9,F63,F7,F82 --target-version=py39 . | |
# Default set of ruff rules with GitHub Annotations | |
ruff check --output-format=github --target-version=py39 . | |
- name: Test with pytest and measure coverage | |
run: | | |
coverage run --rcfile=./pyproject.toml -m pytest | |
mpirun -n 8 coverage run --rcfile=./pyproject.toml -m mpi4py -m pytest --with-mpi | |
coverage combine | |
coverage report -m | |
coverage xml | |
genbadge coverage -i coverage.xml -o coverage.svg | |
- name: Verify Changed files | |
uses: tj-actions/verify-changed-files@v19 | |
id: verify-changed-files | |
with: | |
files: coverage.svg | |
- name: Commit files | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git diff | |
git add coverage.svg | |
git commit -m "update coverage badge" | |
- name: Push changes | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.github_token }} | |
branch: ${{ github.ref }} |