Skip to content

Commit

Permalink
misc: add coverage badge
Browse files Browse the repository at this point in the history
  • Loading branch information
tanloong committed Feb 11, 2025
1 parent 8799986 commit 083addc
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: build

on:
push:
branches: [ master ]
paths:
- "src/pytregex/**"
- "tests/**"
- ".github/workflows/python-package.yml"
pull_request:
paths:
- "src/pytregex/**"
- "tests/**"
- ".github/workflows/python-package.yml"
schedule:
- cron: '0 10 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest, macos-latest, macos-13, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
# This is necessary to get the PR head instead of base
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies on macOS and Linux
if: matrix.os != 'windows-latest'
run: |
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: bash
- name: Install dependencies on Windows
if: matrix.os == 'windows-latest'
run: |
python -m pip install --upgrade pip
if (Test-Path -Path '.\requirements-dev.txt' -PathType Leaf) {pip install --upgrade -r requirements-dev.txt}
if (Test-Path -Path '.\requirements.txt' -PathType Leaf) {pip install --upgrade -r requirements.txt}
shell: pwsh
- name: Build dist and test with unittest on macOS and Linux
if: matrix.os != 'windows-latest'
run: |
python -m build
pip install dist/*.whl
python -m unittest
- name: Build dist and test with unittest on Windows
if: matrix.os == 'windows-latest'
run: |
python -m build
pip install (Get-ChildItem dist/*.whl)
python -m unittest
shell: pwsh
- name: Generate coverage report
run: |
coverage run --source pytregex --parallel-mode -m unittest
coverage combine
coverage xml -i
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![coverage](https://img.shields.io/codecov/c/github/tanloong/pytregex)](https://codecov.io/gh/tanloong/pytregex)
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https://raw.githubusercontent.com/tanloong/pytregex/refs/heads/master/pyproject.toml)
[![license](https://img.shields.io/github/license/tanloong/pytregex)](https://github.com/tanloong/pytregex/blob/master/LICENSE)

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
setuptools
wheel
twine
build

# Lint & Coverage
black
Expand Down

0 comments on commit 083addc

Please sign in to comment.