Skip to content

Commit

Permalink
Coverage badge (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikoOinonen authored Nov 24, 2023
1 parent c13da10 commit bd901e4
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 12 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/ci.yml → .github/workflows/ci_pr.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@

name: Python CI
on: [push, pull_request]
name: CI on PR
on: pull_request

jobs:
run-tests:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11'] # Add 3.12 when pytorch has a wheel

steps:

Expand All @@ -18,21 +15,18 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: 3.11

- name: Install package
run: |
bash ./build.sh
pip install -e .[dev]
- name: Lint with flake8
run: flake8 .

- name: Run pytest
run: pytest --junitxml=pytest.xml --cov-report=term-missing --cov=mlspm tests | tee pytest-coverage.txt
run: pytest --junitxml=pytest.xml --cov-report=term-missing --cov | tee pytest-coverage.txt

- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
junitxml-path: ./pytest.xml
33 changes: 33 additions & 0 deletions .github/workflows/ci_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

name: CI on push
on: push

jobs:
run-tests:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11'] # Add 3.12 when pytorch has a wheel

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install package
run: |
bash ./build.sh
pip install -e .[dev]
- name: Lint with flake8
run: flake8 .

- name: Run pytest
run: pytest

46 changes: 46 additions & 0 deletions .github/workflows/coverage_badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

name: Update coverage badge
on:
push:
branches:
- main

jobs:
update-badge:

runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install package
run: |
bash ./build.sh
pip install -e .[dev]
- name: Run pytest
run: pytest --cov-report=term-missing --cov=mlspm tests | tee pytest-coverage.txt

- name: Pytest coverage comment
id: coverage_comment
uses: MishaKav/pytest-coverage-comment@main
with:
hide-comment: true
pytest-coverage-path: ./pytest-coverage.txt

- name: Create coverage badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.COVERAGE_GIST_SECRET }}
gistID: 913d30e2a2e333eb407353072948042d
filename: coverage.json
label: Coverage
message: ${{ steps.coverage_comment.outputs.coverage }}
color: ${{ steps.coverage_comment.outputs.color }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Machine learning for scanning probe microscopy

[![Documentation Status](https://readthedocs.org/projects/ml-spm/badge/?version=latest)](https://ml-spm.readthedocs.io/en/latest/?badge=latest)

![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/NikoOinonen/913d30e2a2e333eb407353072948042d/raw/cc44c1ee11f6e90c4159e49786ec1c2cedbeb6a9/coverage.json)
## Installation

Install pre-requisites:
Expand Down

0 comments on commit bd901e4

Please sign in to comment.