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

chore: update CI with decoupled way of running pytest #114

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ jobs:

- name: Install the project's dependencies
shell: bash -el {0}
run: poetry install
run: poetry install -v

- name: Test the codebase
- name: Install the task runner poethepoet
shell: bash -el {0}
run: poetry run pytest
run: poetry self add 'poethepoet[poetry_plugin]'

- name: Test the library
shell: bash -el {0}
run: poetry task check-all

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
155 changes: 155 additions & 0 deletions CONTRIBUTING.md
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Contributing

## Installation for Local Development

1. Install the environment manager [`mamba`](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html)
2. Install the Python build tool [`poetry`](https://python-poetry.org/docs/#installing-with-the-official-installer)
3. Create an environment with Python and [interactive `bwa`](https://github.com/fulcrumgenomics/bwa-aln-interactive):

```console
mamba env create -y -f prymer.yml
```

4. Activate the environment:

```console
mamba activate prymer
```

5. Install `prymer` and development dependencies into the activated virtual environment:

```console
poetry install
```

## Primary Development Commands

To check and resolve linting issues in the codebase, run:

```console
poetry run ruff check --fix
```

To check and resolve formatting issues in the codebase, run:

```console
poetry run ruff format
```

To check the unit tests in the codebase, run:

```console
poetry run pytest
```

To check the typing in the codebase, run:

```console
poetry run mypy
```

To generate a code coverage report after testing locally, run:

```console
poetry run coverage html
```

To check the lock file is up to date:

```console
poetry check --lock
```

## Shortcut Task Commands

To be able to run shortcut task commands, first install the Poetry plugin [`poethepoet`](https://poethepoet.natn.io/index.html):

```console
poetry self add 'poethepoet[poetry_plugin]'
```

> NOTE:
> Upon the release of Poetry [v2.0.0](https://github.com/orgs/python-poetry/discussions/9793#discussioncomment-11043205), Poetry will automatically support bootstrap installation of [project-specific plugins](https://github.com/python-poetry/poetry/pull/9547) and installation of the task runner will become automatic for this project.
> The `pyproject.toml` syntax will be:
>
> ```toml
> [tool.poetry]
> requires-poetry = ">=2.0"
>
> [tool.poetry.requires-plugins]
> poethepoet = ">=0.29"
> ```
###### For Running Individual Checks
```console
poetry task check-lock
poetry task check-format
poetry task check-lint
poetry task check-tests
poetry task check-typing
```
###### For Running All Checks

```console
poetry task check-all
```

###### For Running Individual Fixes

```console
poetry task fix-format
poetry task fix-lint
```

###### For Running All Fixes

```console
poetry task fix-all
```

###### For Running All Fixes and Checks

```console
poetry task fix-and-check-all
```


## Building the Documentation

Use `mkdocs` to build and serve the documentation.

```console
poetry run mkdocs build && poetry run mkdocs serve
```

## Creating a Release on PyPi
clintval marked this conversation as resolved.
Show resolved Hide resolved

1. Clone the repository recursively and ensure you are on the `main` (un-dirty) branch
2. Checkout a new branch to prepare the library for release
3. Bump the version of the library to the desired SemVer with `poetry version #.#.#`
4. Commit the version bump changes with a Git commit message like `chore(release): bump to #.#.#`
5. Push the commit to the upstream remote, open a PR, ensure tests pass, and seek reviews
6. Squash merge the PR
7. Tag the new commit on the main branch of the origin repository with the new SemVer

> NOTE:
> This project follows [Semantic Versioning](https://semver.org/).
> In brief:
>
> - `MAJOR` version when you make incompatible API changes
> - `MINOR` version when you add functionality in a backwards compatible manner
> - `PATCH` version when you make backwards compatible bug fixes
GitHub Actions will take care of the remainder of the deployment and release process with:

1. Unit tests will be run for safety-sake
2. A source distribution will be built
3. Multi-arch multi-Python binary distributions will be built
4. Assets will be deployed to PyPi with the new SemVer
clintval marked this conversation as resolved.
Show resolved Hide resolved
5. A [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/)-aware changelog will be drafted
6. A GitHub release will be created with the new SemVer and the drafted changelog

> WARNING:
> Consider editing the changelog if there are any errors or necessary enhancements.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

## Recommended Installation

The package `prymer` requires installation of [Primer3](https://github.com/primer3-org/primer3) and [interactive `bwa`](https://github.com/fulcrumgenomics/bwa-aln-interactive).
The package `prymer` requires installation of [interactive `bwa`](https://github.com/fulcrumgenomics/bwa-aln-interactive).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like primer3 is nuked, so I got rid of that.


To satisfy these requirements, it is recommended to install using [bioconda](https://bioconda.github.io/):

Expand All @@ -59,4 +59,4 @@ mamba install -c bioconda prymer

See the [developer's instructions][developers-instructions-link] for more information.

[developers-instructions-link]: https://prymer.readthedocs.io/en/latest/installation-and-developers-documentation.html#installation-for-development
[developers-instructions-link]: https://prymer.readthedocs.io/en/latest/CONTRIBUTING
1 change: 1 addition & 0 deletions docs/CONTRIBUTING.md
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This soft-link ensure there is only 1 source of contributor/developer documentation and it will show up nicely in GitHub and also get compiled into our docs website too.

17 changes: 13 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

Python Primer Design Library

## Documentation Contents
## Recommended Installation

The package `prymer` requires installation of [interactive `bwa`](https://github.com/fulcrumgenomics/bwa-aln-interactive).

To satisfy these requirements, it is recommended to install `prymer` using [bioconda](https://bioconda.github.io/):

* [Installation](installation-and-developers-documentation.md)
* [Overview](overview.md)
* [API](reference/prymer/index.md)
```console
mamba install -c bioconda prymer
```

## Documentation Contents

- [Overview](overview.md)
- [API](reference/prymer/index.md)
- [Contributing](CONTRIBUTING.md)
92 changes: 0 additions & 92 deletions docs/installation-and-developers-documentation.md

This file was deleted.

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ plugins:
show_submodules: true
- table-reader
markdown_extensions:
- callouts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little helper that makes "admonitions" look just OK in both GitHub and mkdocs. It's not perfect, but it is better than not having it. So far, this only impacts CONTRIBUTING.md because that's the only file that has to look good rendered in both ways.

- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
Expand Down
Loading
Loading