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

Upload code coverage in builds #5

Merged
merged 9 commits into from
Jul 26, 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
42 changes: 38 additions & 4 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ on:

jobs:
validate:
name: "tests & coverage"
runs-on: ubuntu-latest
name: lint and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
Expand All @@ -25,11 +26,44 @@ jobs:

- run: python -m pip install hatch
- run: hatch fmt --check
- run: hatch test
- run: hatch test --cover
- run: hatch run types:check

# Adapted from
# https://github.com/pypa/hatch/blob/master/.github/workflows/test.yml
- run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage*

coverage:
name: report coverage
runs-on: ubuntu-latest
# Make sure coverage reports have been generated.
needs:
- validate
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.12
- run: python -m pip install hatch

- uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true

- run: hatch run coverage:combine
- run: hatch run coverage:report-xml
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

release:
name: "publish to GitHub and PyPi"
name: publish to GitHub and PyPi
runs-on: ubuntu-latest
concurrency: release
environment:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
__pycache__/
/.mypy_cache/
/.ruff_cache/

# Code coverage reports.
/.coverage*
/coverage.xml

/dist/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![PyPI - Version](https://img.shields.io/pypi/v/alpax.svg)](https://pypi.org/project/alpax)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/alpax.svg)](https://pypi.org/project/alpax)
![Test & Release](https://github.com/kmontag/alpax/actions/workflows/test_and_release.yml/badge.svg?branch=main)
[![codecov](https://codecov.io/github/kmontag/alpax/graph/badge.svg?token=5C1JO6YTDL)](https://codecov.io/github/kmontag/alpax)

---

Expand Down
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "alpax"
dynamic = ["version"]
description = 'Generate custom Ableton Live packs'
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = "MIT"
keywords = []
authors = [
Expand Down Expand Up @@ -38,6 +38,16 @@ path = "src/alpax/__about__.py"
# "pytest-asyncio~=0.23.7",
# ]

[tool.hatch.envs.coverage]
detached = true
dependencies = [
"coverage~=7.6.0",
]

[tool.hatch.envs.coverage.scripts]
combine = "coverage combine {args}"
report-xml = "coverage xml"

[tool.hatch.envs.types]
extra-dependencies = [
"mypy>=1.0.0",
Expand Down
3 changes: 1 addition & 2 deletions src/alpax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import json
import os
import textwrap
from collections.abc import Collection, Sequence
from typing import (
TYPE_CHECKING,
Collection,
Generic,
Sequence,
TypedDict,
TypeVar,
)
Expand Down
Loading