Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test version matrix for OS + Python and transition to Codecov #163

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 48 additions & 50 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
name: Python test

on: [push]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
mpi: [ "openmpi" ] # "mpich", "intelmpi"
# exclude:
# - os: "macos-latest"
# mpi: "intelmpi"

runs-on: ${{ matrix.os }}

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 }}
- name: Check out repository
uses: actions/checkout@v4

- name: Setup MPI ${{ matrix.mpi }}
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}

- 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 ."[test]"

- 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

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/7785/badge)](https://www.bestpractices.dev/projects/7785)
[![](https://img.shields.io/badge/Contact-propulate%40lists.kit.edu-orange)](mailto:[email protected])
[![Documentation Status](https://readthedocs.org/projects/propulate/badge/?version=latest)](https://propulate.readthedocs.io/en/latest/?badge=latest)
![](./coverage.svg)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Helmholtz-AI-Energy/propulate/main.svg)](https://results.pre-commit.ci/latest/github/Helmholtz-AI-Energy/propulate/main)
[![codecov](https://codecov.io/gh/Helmholtz-AI-Energy/propulate/graph/badge.svg?token=ZG6PEXJOIO)](https://codecov.io/gh/Helmholtz-AI-Energy/propulate)[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Helmholtz-AI-Energy/propulate/main.svg)](https://results.pre-commit.ci/latest/github/Helmholtz-AI-Energy/propulate/main)

# **Click [here](https://www.scc.kit.edu/en/aboutus/16956.php) to watch our 3 min introduction video!**

Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ dev = [

test = [
"coverage",
"genbadge[coverage]",
"ruff",
"pytest",
"pytest-cov",
"pytest-mpi",
Expand Down
Loading