Skip to content

Commit b3fae4e

Browse files
authored
Merge pull request #107 from lwasser/add-coverage
Fix: add test coverage
2 parents fe96d53 + 82d44a6 commit b3fae4e

File tree

6 files changed

+65
-31
lines changed

6 files changed

+65
-31
lines changed

.github/workflows/run-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ jobs:
2020
- name: Run tests
2121
env:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
run: hatch run test:run-tests
23+
run: hatch run test:run-report
24+
- name: Upload coverage reports to Codecov
25+
uses: codecov/[email protected]
26+
with:
27+
token: ${{ secrets.CODECOV_TOKEN }}
28+
verbose: true
29+
files: ./coverage.xml

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ all_contribs_dict.pickle
99
.idea/
1010
.token
1111
__pycache__
12+
.coverage
13+
coverage.xml
1214

1315

1416
# Distribution / packaging

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Enh: Use `hatch_vcs` for dynamic versioning (@lwasser, #82)
88
- Fix: migrate to pytest for tests and setup hatch scripts (#89, @lwasser)
99
- Add: Partner support to package (#92, @lwasser)
10+
- Add: Code coverage setup (#97, @lwasser)
1011
- Fix: Add validation step to categories attr in pydantic model (#105, @lwasser)
1112

1213
## [v0.15](https://github.com/pyOpenSci/pyosMeta/releases/tag/v0.15)

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
# pyosmeta (was: update-web-metadata)
1+
# pyosmeta
22

33
[![PyPI](https://img.shields.io/pypi/v/pyosmeta.svg)](https://pypi.org/project/pyosmeta/)
44
[![.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)
55
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/pyopensci/update-web-metadata/blob/master/LICENSE)
6+
[![codecov](https://codecov.io/gh/pyOpenSci/pyosMeta/graph/badge.svg?token=GOXKA8Z44X)](https://codecov.io/gh/pyOpenSci/pyosMeta)
67

78
## Description
89

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

17-
*Since pyOpenSci uses this tool for its website, we expect this package to have infrequent releases.*
14+
- `parse-history`
15+
- `update-contributors`
16+
- `update-reviews`
17+
- `update-review-teams`
18+
19+
_Since pyOpenSci uses this tool for its website, we expect this package to have infrequent releases._
1820

1921
## Installation
2022

2123
Using pip:
24+
2225
```
2326
pip install pyosmeta
2427
```
2528

2629
Using conda:
30+
2731
```
2832
conda install pyosmeta
2933
```
@@ -32,7 +36,7 @@ conda install pyosmeta
3236

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

35-
*Note: this section will be rewritten to be more user focused.*
39+
_Note: this section will be rewritten to be more user focused._
3640

3741
## Contributors ✨
3842

development.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,31 @@ pyosMeta uses hatch and hatchling as it's build back end.
66

77
## Running tests
88

9-
To install tests:
9+
We use Hatch scripts to automate workflows. 🚀
1010

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

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

15-
To run tests, you can use:
16+
`hatch run test:run-coverage`
1617

17-
`hatch run test:run-tests`
18+
2. To run tests without code coverage report outs use :
19+
`hatch run test:run-coverage`
20+
21+
3. To run tests with an xml report generated use:
22+
`hatch run test:run-report`
23+
24+
The hatch run-report script is the script used in our CI tests action.
25+
26+
### Modify test scripts
27+
28+
To modify how scripts are run, you can look at this section in our
29+
pyproject.toml file:
30+
31+
```toml
32+
[tool.hatch.envs.test.scripts]
33+
run-coverage = "pytest --cov-config=pyproject.toml --cov=pyosmeta --cov=tests/*"
34+
run-no-cov = "run-coverage --no-cov"
35+
run-report = "run-coverage --cov-report=xml:coverage.xml"
36+
```

pyproject.toml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ dynamic = ["version"]
88
description = "Tools that update the pyOpenSci contributor and review metadata that is posted on our website"
99
authors = [{ name = "Leah Wasser", email = "[email protected]" }]
1010
maintainers = [
11-
{ name = "pyOpenSci", email = "[email protected]" }, # Optional
11+
{ name = "pyOpenSci", email = "[email protected]" }, # Optional
1212
]
1313
classifiers = [
14-
"Development Status :: 4 - Beta",
15-
"Intended Audience :: Developers",
16-
"Topic :: Software Development :: Build Tools",
14+
"Development Status :: 4 - Beta",
15+
"Intended Audience :: Developers",
16+
"Topic :: Software Development :: Build Tools",
1717

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

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

6065
### Hatch config ###
6166

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

6671
[tool.hatch.envs.test]
67-
dependencies = [
68-
"pytest",
69-
"pytest-cov",
70-
]
72+
dependencies = ["pytest", "pytest-cov", "coverage[toml]"]
7173

7274
[tool.hatch.envs.test.scripts]
73-
#run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov=tests"
74-
#run = "run-coverage --no-cov"
75-
run-tests = "pytest"
75+
run-coverage = "pytest --cov-config=pyproject.toml --cov=pyosmeta --cov=tests/*"
76+
run-no-cov = "run-coverage --no-cov"
77+
run-report = "run-coverage --cov-report=xml:coverage.xml"
7678

7779

7880
### Tool configuration ###

0 commit comments

Comments
 (0)