Skip to content

Commit

Permalink
Merge pull request #107 from lwasser/add-coverage
Browse files Browse the repository at this point in the history
Fix: add test coverage
  • Loading branch information
willingc authored Feb 26, 2024
2 parents fe96d53 + 82d44a6 commit b3fae4e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 31 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ jobs:
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: hatch run test:run-tests
run: hatch run test:run-report
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
files: ./coverage.xml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ all_contribs_dict.pickle
.idea/
.token
__pycache__
.coverage
coverage.xml


# Distribution / packaging
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Enh: Use `hatch_vcs` for dynamic versioning (@lwasser, #82)
- Fix: migrate to pytest for tests and setup hatch scripts (#89, @lwasser)
- Add: Partner support to package (#92, @lwasser)
- Add: Code coverage setup (#97, @lwasser)
- Fix: Add validation step to categories attr in pydantic model (#105, @lwasser)

## [v0.15](https://github.com/pyOpenSci/pyosMeta/releases/tag/v0.15)
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
# pyosmeta (was: update-web-metadata)
# pyosmeta

[![PyPI](https://img.shields.io/pypi/v/pyosmeta.svg)](https://pypi.org/project/pyosmeta/)
[![.github/workflows/test-run-script.yml](https://github.com/pyOpenSci/update-web-metadata/actions/workflows/test-run-script.yml/badge.svg)](https://github.com/pyOpenSci/update-web-metadata/actions/workflows/test-run-script.yml)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/pyopensci/update-web-metadata/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/pyOpenSci/pyosMeta/graph/badge.svg?token=GOXKA8Z44X)](https://codecov.io/gh/pyOpenSci/pyosMeta)

## Description

**pyosmeta** provides the tools and scripts used to manage [pyOpenSci](https://pyopensci.org)'s contributor and peer
review metadata.
This repo contains a small module and several CLI scripts, including:
- `parse-history`
- `update-contributors`
- `update-reviews`
- `update-review-teams`

*Since pyOpenSci uses this tool for its website, we expect this package to have infrequent releases.*
- `parse-history`
- `update-contributors`
- `update-reviews`
- `update-review-teams`

_Since pyOpenSci uses this tool for its website, we expect this package to have infrequent releases._

## Installation

Using pip:

```
pip install pyosmeta
```

Using conda:

```
conda install pyosmeta
```
Expand All @@ -32,7 +36,7 @@ conda install pyosmeta

See [CONTRIBUTING.md](./CONTRIBUTING.md).

*Note: this section will be rewritten to be more user focused.*
_Note: this section will be rewritten to be more user focused._

## Contributors ✨

Expand Down
29 changes: 24 additions & 5 deletions development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@ pyosMeta uses hatch and hatchling as it's build back end.

## Running tests

To install tests:
We use Hatch scripts to automate workflows. 🚀

`python -m pip install ".[tests]"`
To run tests there is a single hatch environment parsed with three
script options that you can chose to run.

We use Hatch scripts to automate workflows.
1. To run only tests with a code coverage report out in the terminal use:

To run tests, you can use:
`hatch run test:run-coverage`

`hatch run test:run-tests`
2. To run tests without code coverage report outs use :
`hatch run test:run-coverage`

3. To run tests with an xml report generated use:
`hatch run test:run-report`

The hatch run-report script is the script used in our CI tests action.

### Modify test scripts

To modify how scripts are run, you can look at this section in our
pyproject.toml file:

```toml
[tool.hatch.envs.test.scripts]
run-coverage = "pytest --cov-config=pyproject.toml --cov=pyosmeta --cov=tests/*"
run-no-cov = "run-coverage --no-cov"
run-report = "run-coverage --cov-report=xml:coverage.xml"
```
38 changes: 20 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ dynamic = ["version"]
description = "Tools that update the pyOpenSci contributor and review metadata that is posted on our website"
authors = [{ name = "Leah Wasser", email = "[email protected]" }]
maintainers = [
{ name = "pyOpenSci", email = "[email protected]" }, # Optional
{ name = "pyOpenSci", email = "[email protected]" }, # Optional
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",

# Pick your license - we suggest MIT, BSD3 or Apache if you are corporate
"License :: OSI Approved :: MIT License",
# Specify the Python versions ensuring that you indicate you support Python 3.
# this is only for pypi and other metadata associated with your package - for your users to see
"Programming Language :: Python :: 3 :: Only", # BE sure to specify that you use python 3.x
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
# Pick your license - we suggest MIT, BSD3 or Apache if you are corporate
"License :: OSI Approved :: MIT License",
# Specify the Python versions ensuring that you indicate you support Python 3.
# this is only for pypi and other metadata associated with your package - for your users to see
"Programming Language :: Python :: 3 :: Only", # BE sure to specify that you use python 3.x
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"pydantic>=2.0",
Expand Down Expand Up @@ -56,6 +56,11 @@ update-contributors = "pyosmeta.cli.update_contributors:main"
update-reviews = "pyosmeta.cli.process_reviews:main"
update-review-teams = "pyosmeta.cli.update_review_teams:main"

[tool.coverage.run]
branch = true
include = ["src/pyosmeta/*"]
# Don't run coverage on tests directory or version file created by scm
omit = ["tests/*", "src/pyosmeta/_version.py"]

### Hatch config ###

Expand All @@ -64,15 +69,12 @@ version.source = "vcs"
build.hooks.vcs.version-file = "src/pyosmeta/_version.py"

[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",
]
dependencies = ["pytest", "pytest-cov", "coverage[toml]"]

[tool.hatch.envs.test.scripts]
#run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov=tests"
#run = "run-coverage --no-cov"
run-tests = "pytest"
run-coverage = "pytest --cov-config=pyproject.toml --cov=pyosmeta --cov=tests/*"
run-no-cov = "run-coverage --no-cov"
run-report = "run-coverage --cov-report=xml:coverage.xml"


### Tool configuration ###
Expand Down

0 comments on commit b3fae4e

Please sign in to comment.