Skip to content

Commit

Permalink
Migrate the project to Poetry (#129)
Browse files Browse the repository at this point in the history
* Prepare poetry config

* Adapt release script

* Add some documentation

* Update check.yaml

* Add comment

* Update CONTRIBUTING.md

* Update tools/release.sh

* Include development related files inside the sdist

* External job

* Update poetry-core to support editable installs.

* Update .github/workflows/check.yaml

* Update lock file and move constraints.txt out of the dist folder

* Update gitignore

* Export dev dependencies to pin pytest during release

* No hashes to avoid pip install failure with unhashed additional dependencies

* Setup pre-install hook to generate the constraints file

* Install pytest along with josepy during release

Co-authored-by: Brad Warren <[email protected]>
  • Loading branch information
adferrand and bmw authored Apr 14, 2022
1 parent e3af949 commit 82068c7
Show file tree
Hide file tree
Showing 17 changed files with 1,367 additions and 245 deletions.
11 changes: 0 additions & 11 deletions .coveragerc

This file was deleted.

33 changes: 22 additions & 11 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('constraints.txt') }}
path: ~/.cache/pypoetry
# Look to see if there is a cache hit for the corresponding lock file
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-poetry-
${{ runner.os }}-
- name: Install Dependencies
run: pip install -r constraints.txt
- name: Install Poetry & Tox
run: pip install poetry>1.0.0 tox>3.3.0
# TEST
- name: Run Tox
- name: Run pytest and coverage
run: tox -e py
# STATIC CHECK
- name: Run mypy
Expand All @@ -47,17 +47,28 @@ jobs:
tox -e flake8
tox -e isort
# COVERAGE
- name: Convert Coverage
run: python -m coverage xml
- name: Upload Coverage
- name: Upload coverage
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
# This job runs our tests like external parties such as packagers.
external:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install josepy + pytest
run: pip install .[docs] pytest
- name: Run tests
run: pytest tests
notify:
# Only notify about failed builds, do not notify about failed builds for
# PRs, and only notify about failed pushes to master.
if: ${{ failure() && github.event_name != 'pull_request' && (github.event_name != 'push' || github.ref == 'refs/heads/master') }}
needs: build
needs: [build, external]
runs-on: ubuntu-20.04
steps:
- name: Write Mattermost Message
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ target/

# Pycharm
.idea

# Ignore generated constraints.txt file generated by tools/release.sh
constraints.txt
14 changes: 14 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.10"
jobs:
pre_install:
- curl -sSL https://install.python-poetry.org | python3 -
- ${HOME}/.local/bin/poetry export -f requirements.txt --dev -E docs --without-hashes > constraints.txt

python:
install:
- requirements: docs/requirements.txt
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,36 @@ started. In particular, we recommend you read these sections
- [Finding issues to work on](https://certbot.eff.org/docs/contributing.html#find-issues-to-work-on)
- [Coding style](https://certbot.eff.org/docs/contributing.html#coding-style)
- [Submitting a pull request](https://certbot.eff.org/docs/contributing.html#submitting-a-pull-request)

# Specific instructions for Josepy

## Configure a development environment

1) Install Poetry: https://python-poetry.org/docs/#installation
2) Setup a Python virtual environment
```bash
$ poetry install -E docs
```
3) Activate the Python virtual environment
```bash
# (On Linux)
$ source .venv/bin/activate
# (On Windows Powershell)
$ .\.venv\Script\activate
```

## Run the tests and quality checks

1) Configure a development environment ([see above](#configure-a-development-environment))
2) Run the unit tests
```bash
$ tox -e py
```
3) Run the linter and import format checker
```bash
$ tox -e flake8 isort
```
4) Run the type checker
```bash
$ tox -e mypy
```
8 changes: 0 additions & 8 deletions MANIFEST.in

This file was deleted.

73 changes: 0 additions & 73 deletions constraints.txt

This file was deleted.

5 changes: 0 additions & 5 deletions mypy.ini

This file was deleted.

Loading

0 comments on commit 82068c7

Please sign in to comment.