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

Replace setup.py packaging by Poetry #5266

Merged
merged 29 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
614ba1d
Configure pyproject.toml
snejus May 13, 2024
90263a9
Use poetry in workflows
snejus Jun 9, 2024
e30ee3f
Update workflows
snejus Jun 9, 2024
7bbd215
Update all docs with Poetry
snejus May 13, 2024
1aad6e0
release.py: introduce pyproject.toml
snejus Jun 4, 2024
347911c
Introduce Poe the Poet task runner and define tasks.
snejus Jun 7, 2024
bfd9753
Remove tox
snejus May 28, 2024
4a8e6e9
Update workflows
snejus Jun 5, 2024
5ccc69d
Lint only changed files
snejus Jun 7, 2024
4494acd
Simplify logic ci.yaml
Serene-Arc Jun 9, 2024
6b2ec01
Search for changed doc and python files separately
Serene-Arc Jun 9, 2024
b57c0dd
Rename action
Serene-Arc Jun 9, 2024
4f566f1
Only format correct directories
Serene-Arc Jun 9, 2024
35533b3
Add poethepoet to dependencies for devs
Serene-Arc Jun 9, 2024
4d5b821
Use poetry prefix
Serene-Arc Jun 9, 2024
f3c9f03
Use poetry action instead of pipx
Serene-Arc Jun 9, 2024
6d7a6df
Simplify workflow
Serene-Arc Jun 9, 2024
b00a83c
Partially revert "Simplify logic ci.yaml"
snejus Jun 10, 2024
627c069
Revert "Only format correct directories"
snejus Jun 10, 2024
f3df90c
Revert "Add poethepoet to dependencies for devs"
snejus Jun 10, 2024
fee65ba
Revert "Use poetry prefix"
snejus Jun 10, 2024
17ec590
Revert "Simplify workflow"
snejus Jun 10, 2024
6763722
Revert "Use poetry action instead of pipx"
snejus Jun 10, 2024
4752fb0
Do not use fetch-depth: 2 to get changed-files, and fix small typo
snejus Jun 10, 2024
6d3b76d
Update dependencies
snejus Jun 10, 2024
a4ed6ab
Document the changes
snejus Jun 10, 2024
50cf70e
Check all python files for formatting issues
snejus Jun 11, 2024
c2a13ee
Format docs/conf.py
snejus Jun 11, 2024
0507f6f
Fix sphinx docs linting
snejus Jun 12, 2024
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
16 changes: 0 additions & 16 deletions .github/flake8-problem-matcher.json

This file was deleted.

25 changes: 11 additions & 14 deletions .github/sphinx-problem-matcher.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"problemMatcher": [
"problemMatcher": [
{
"owner": "sphinx",
"pattern": [
{
"owner": "sphinx",
"pattern": [
{
"regexp": "^Warning, treated as error:$"
},
{
"regexp": "^(.*?):(\\d+):(.*)$",
"file": 1,
"line": 2,
"message": 3
}
]
"regexp": "^([^:]+):(\\d+): (WARNING: )?(.+)$",
"file": 1,
"line": 2,
"message": 4
}
]
]
}
]
}
118 changes: 35 additions & 83 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,104 +1,56 @@
name: ci
name: Test
on:
push:
branches:
- master
pull_request:
push:
branches:
- master
env:
PY_COLORS: 1

jobs:
test:
runs-on: ${{ matrix.platform }}
name: Run tests
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.x"]

python-version: ["3.8", "3.9"]
runs-on: ${{ matrix.platform }}
env:
PY_COLORS: 1

IS_MAIN_PYTHON: ${{ matrix.python-version == '3.8' && matrix.platform == 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- name: Setup Python with poetry caching
# poetry cache requires poetry to already be installed, weirdly
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox sphinx

- name: Install optional dependencies
if: matrix.platform != 'windows-latest'
- name: Install PyGobject dependencies on Ubuntu
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install ffmpeg # For replaygain

- name: Test older Python versions with tox
if: matrix.python-version != '3.x'
run: |
tox -e py-test
sudo apt install ffmpeg gobject-introspection libgirepository1.0-dev
poetry install --extras replaygain

- name: Upload code coverage
if: matrix.python-version == '3.8' && matrix.platform == 'ubuntu-latest'
run: |
pip install codecov || true
codecov || true

- name: Test latest Python version with tox and mypy
if: matrix.python-version == '3.x'
# continue-on-error is not ideal since it doesn't give a visible
# warning, but there doesn't seem to be anything better:
# https://github.com/actions/toolkit/issues/399
continue-on-error: true
run: |
tox -vv -e py-mypy
- name: Install Python dependencies
run: poetry install --only=main,test

test-docs:
runs-on: ubuntu-latest
- if: ${{ ! env.IS_MAIN_PYTHON }}
name: Test without coverage
run: poe test --no-cov

env:
PY_COLORS: 1

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.x
uses: actions/setup-python@v2
- if: ${{ env.IS_MAIN_PYTHON }}
name: Test with coverage
uses: liskin/gh-problem-matcher-wrap@v3
with:
python-version: "3.x"

- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox sphinx

- name: Add problem matcher
run: echo "::add-matcher::.github/sphinx-problem-matcher.json"

- name: Build and check docs using tox
run: tox -e docs

lint:
runs-on: ubuntu-latest
linters: pytest
run: poe test

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox sphinx

- name: Add problem matcher
run: echo "::add-matcher::.github/flake8-problem-matcher.json"

- name: Lint with flake8
run: tox -e py-lint
- if: ${{ env.IS_MAIN_PYTHON }}
name: Upload code coverage
continue-on-error: true
run: poetry run codecov
14 changes: 0 additions & 14 deletions .github/workflows/formatting_check.yml

This file was deleted.

33 changes: 14 additions & 19 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,29 @@ name: integration tests
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * SUN' # run every Sunday at midnight
- cron: "0 0 * * SUN" # run every Sunday at midnight
jobs:
test_integration:
runs-on: ubuntu-latest

env:
PY_COLORS: 1

steps:
- uses: actions/checkout@v2

- name: Set up latest Python version
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: 3.9-dev
python-version: 3.8
cache: poetry

- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox sphinx
- name: Install dependencies
run: poetry install

- name: Test with tox
run: |
tox -e int
- name: Test
env:
INTEGRATION_TEST: 1
run: poe test

- name: Check external links in docs
run: |
tox -e links
run: poe check-docs-links

- name: Notify on failure
if: ${{ failure() }}
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Lint check
run-name: Lint code
on:
pull_request:
push:
branches:
- master

env:
PYTHON_VERSION: 3.8

jobs:
changed-files:
runs-on: ubuntu-latest
name: Get changed files
outputs:
any_docs_changed: ${{ steps.changed-doc-files.outputs.any_changed }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Well caught! Completely forgot that the docs are written in a different language 😅

any_python_changed: ${{ steps.changed-python-files.outputs.any_changed }}
changed_doc_files: ${{ steps.changed-doc-files.outputs.all_changed_files }}
changed_python_files: ${{ steps.changed-python-files.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v4
- name: Get changed docs files
id: changed-doc-files
uses: tj-actions/changed-files@v44
with:
files: |
docs/**
- name: Get changed python files
id: changed-python-files
uses: tj-actions/changed-files@v44
with:
files: |
**.py

format:
if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
name: Check formatting
needs: changed-files
steps:
- uses: actions/checkout@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=format

- name: Check code formatting
# the job output will contain colored diffs with what needs adjusting
run: poe check-format

lint:
if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
name: Check linting
needs: changed-files
steps:
- uses: actions/checkout@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=lint

- name: Lint code
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: flake8
run: poe lint ${{ needs.changed-files.outputs.changed_python_files }}

mypy:
Copy link
Member Author

Choose a reason for hiding this comment

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

👍🏼 nice

if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
name: Check types with mypy
needs: changed-files
steps:
- uses: actions/checkout@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=typing

- name: Type check code
uses: liskin/gh-problem-matcher-wrap@v3
continue-on-error: true
with:
linters: mypy
run: poe check-types --show-column-numbers --no-error-summary ${{ needs.changed-files.outputs.changed_python_files }}

docs:
if: needs.changed-files.outputs.any_docs_changed == 'true'
runs-on: ubuntu-latest
name: Check docs
needs: changed-files
steps:
- uses: actions/checkout@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=docs

- name: Add Sphinx problem matcher
run: echo "::add-matcher::.github/sphinx-problem-matcher.json"

- name: Build docs
run: |
poe docs |& tee /tmp/output
# fail the job if there are issues
grep -q " WARNING:" /tmp/output && exit 1 || exit 0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ target/
.env

# virtualenv
env/
venv/
.venv/
ENV/
Expand Down
Loading
Loading