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: switch to using Poetry for dependencies #180

Merged
merged 7 commits into from
Feb 6, 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
14 changes: 6 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ jobs:
with:
python-version: '3.10'

- name: Install build dependencies
run: python -m pip install build --user
- name: Install Poetry
run: python -m pip install 'poetry>=1.7.1,<1.8'

- name: Build
run: python -m build --sdist --wheel --outdir dist/ .
- name: Set token
run: python -m poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Build and publish to PyPI
run: python -m poetry publish --build
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ jobs:
name: Set up Python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
run: python -m pip install 'poetry>=1.7.1,<1.8'
- name: Install dependencies
run: python -m pip install -r requirements.txt
run: python -m poetry install --all-extras
- name: Test
run: mkdir -p tmp && pytest -svv --cov=bento_lib --cov-branch
run: mkdir -p tmp && poetry run pytest -svv --cov=bento_lib --cov-branch --cov-report=xml
env:
TEST_REDIS_HOST: localhost
TEST_REDIS_PORT: 6379
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
file: ./coverage.xml
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
install:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.idea/rSettings.xml
.idea/workspace.xml
.coverage
coverage.xml
.pytest_cache
.tox/
build
Expand Down
8 changes: 0 additions & 8 deletions .mergify.yml

This file was deleted.

3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,33 @@
Common utilities and helpers for Bento platform services.


## Running Tests
## Installing

`bento_lib` can be added to a new service through normal installation, with any extras
that may be needed:

```bash
# Add to a project using Poetry for dependencies
poetry add bento_lib

# Install using pip with the FastAPI extra
pip install bento_lib[fastapi]

# etc...
```


## Developing

Clone the repository and set up the Poetry environment using the following commands:

```bash
git clone [email protected]:bento-platform/bento_lib.git
poetry install --all-extras
```


### Running Tests

For tests to complete successfully, the following external servers must be running:

Expand All @@ -19,29 +45,27 @@ For tests to complete successfully, the following external servers must be runni
Then, tests and linting can be run with the following command:

```bash
python3 -m tox
poetry run tox
```


## Releasing
### Releasing


### 1. Release Checklist
#### 1. Release Checklist

* [ ] All tests pass and test coverage has not been reduced

* [ ] Package version has been updated (following semver) in
`bento_lib/package.cfg`
* [ ] Package version has been updated (following semver) in `pyproject.toml`

* [ ] The latest changes have been merged from the `develop` branch into the
`master` branch
* [ ] The latest changes have been merged into the `master` branch

* [ ] A release has been created, tagged in the format of `v#.#.#` and named
in the format of `Version #.#.#`, listing any changes made, in the GitHub
releases page **tagged from the master branch!**


#### 1A. Note on Versioning
##### 1A. Note on Versioning

The `bento_lib` project uses [semantic versioning](https://semver.org/) for
releasing. If the API is broken in any way, including minor differences in the
Expand All @@ -51,11 +75,11 @@ way, we guarantee that projects relying on this API do not accidentally break
upon upgrading.


### 2. Releasing automatically
#### 2. Releasing automatically

When a version is tagged on GitHub, a build + release CI pipeline is automatically triggered.
Make sure that the tagged version is a valid semantic versioning translation of the version in
`package.cfg`, and that the versions otherwise match.
`pyproject.toml`, and that the versions otherwise match.


## Modules
Expand Down
11 changes: 2 additions & 9 deletions bento_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import configparser
import os
from importlib import metadata

from . import auth
from . import drs
Expand All @@ -9,11 +8,5 @@
from . import service_info
from . import workflows


config = configparser.ConfigParser()
config.read(os.path.join(os.path.dirname(os.path.realpath(__file__)), "package.cfg"))


name = config["package"]["name"]
__version__ = config["package"]["version"]
__version__ = metadata.version(__name__)
__all__ = ["__version__", "auth", "drs", "events", "schemas", "search", "service_info", "workflows"]
5 changes: 0 additions & 5 deletions bento_lib/package.cfg

This file was deleted.

7 changes: 7 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
comment:
layout: " diff, flags, files"
behavior: default
require_changes: false
require_base: false
require_head: true
hide_project_coverage: false
Loading