Skip to content

Commit

Permalink
Merge pull request #2 from alpaka-group/codeCoverage
Browse files Browse the repository at this point in the history
add code coverage (via upstream branch)
  • Loading branch information
SimeonEhrig authored Jan 23, 2024
2 parents 66c06bb + b69d09f commit 3207d45
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/codeCoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CodeCov
on: [push, pull_request]
jobs:
code-coverage:
runs-on: ubuntu-latest
env:
OS: ubuntu-latest
PYTHON: '3.12'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.12
- name: Install bashi
run: |
pip install .
- name: Generate Report
run: |
pip install coverage
coverage run
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dist/
bashi.egg-info
# user created python environment
env
# coverage report generated by coverage.py
.coverage

####################
# IDE files
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project will be the successor to the [alpaka-job-matrix-library](https://gi

# bashi

[![codecov](https://codecov.io/github/alpaka-group/bashi/graph/badge.svg?token=QEF8G02ZST)](https://codecov.io/github/alpaka-group/bashi)

A library to provide a job generator for CI's for alpaka based projects.

# Developing
Expand All @@ -20,14 +22,18 @@ If the example works correctly, a `job.yml` will be created in the current direc

Now the library is available in the environment. Therefore you can easily use the library in your own projects via `import bashi`.

## Formatting the source code

The source code is formatted using the [black](https://pypi.org/project/black/) formatter and the default style guide. You must install it and run `black /path/to/file` to format a file. A CI job checks that all files are formatted correctly. If the job fails, a PR cannot be merged.

## Contribution

This section contains some hints for developing new functions. The hints are mainly for people who have no experience with `setuptools` and building `pip` packages.

* The `pip install --editable .` command installs the source code files as a symbolic link. This means that changes in the source code of the Python files in the `src/bashi` folder are directly available without any additional installation step (only a restart of the Python process/interpreter is required).
* The software requirements are defined in `pyproject.toml` and not in an additional `requirements.txt`.
* It is necessary to increase the version number in `version.txt` before a new feature can be merged in the master branch. Otherwise the upload to pypy.org will fail because existing versions cannot be changed.

## Formatting the Source Code

The source code is formatted using the [black](https://pypi.org/project/black/) formatter and the default style guide. You must install it and run `black /path/to/file` to format a file. A CI job checks that all files are formatted correctly. If the job fails, a PR cannot be merged.

## Check Code Coverage locally

The project supports code coverage with [coverage.py](https://coverage.readthedocs.io). To create a coverage report locally, you must first install the package via `pip install coverage`. Then run `coverage run` in the project folder to calculate the coverage and `coverage report` to display the result.
Empty file added codecov.yml
Empty file.
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ version = {file = "version.txt"}
Homepage = "https://github.com/alpaka-group/bashi"
Repository = "https://github.com/alpaka-group/bashi"
Issues = "https://github.com/alpaka-group/bashi/issues"

[tool.coverage.run]
command_line = "-m unittest discover -s tests/"
branch = true
source = ["bashi"]

0 comments on commit 3207d45

Please sign in to comment.