Skip to content

Commit 6ecf1a4

Browse files
authored
Merge pull request #91 from beetbox/modernize-package
Modernize setup, add tests
2 parents 7ce306c + a5ee3fb commit 6ecf1a4

18 files changed

+1948
-257
lines changed

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 2026
2+
# Reformat the codebase
3+
d906c2375d78f81fb27083c9042a87e282ad8789
4+
# Fix lint issues
5+
37f25ae3ed9c1d1cfbb4e17025af8c19f27725d5
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Verify changelog updated
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- ready_for_review
8+
9+
jobs:
10+
check_changes:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
15+
- name: Get all updated Python files
16+
id: changed-python-files
17+
uses: tj-actions/changed-files@v47
18+
with:
19+
files: |
20+
**.py
21+
22+
- name: Check for the changelog update
23+
id: changelog-update
24+
uses: tj-actions/changed-files@v47
25+
with:
26+
files: docs/changelog.rst
27+
28+
- name: Comment under the PR with a reminder
29+
if: steps.changed-python-files.outputs.any_changed == 'true' && steps.changelog-update.outputs.any_changed == 'false'
30+
uses: thollander/actions-comment-pull-request@v3
31+
with:
32+
message: 'Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.'
33+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/lint.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Lint check
2+
run-name: Lint code
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
# Cancel previous workflow run when a new commit is pushed to a feature branch
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
13+
14+
env:
15+
PYTHON_VERSION: "3.10"
16+
17+
jobs:
18+
changed-files:
19+
runs-on: ubuntu-latest
20+
name: Get changed files
21+
outputs:
22+
any_python_changed: ${{ steps.raw-changed-python-files.outputs.any_changed }}
23+
changed_python_files: ${{ steps.changed-python-files.outputs.all_changed_files }}
24+
steps:
25+
- uses: actions/checkout@v6
26+
- name: Get changed python files
27+
id: raw-changed-python-files
28+
uses: tj-actions/changed-files@v47
29+
with:
30+
files: |
31+
**.py
32+
poetry.lock
33+
34+
- name: Check changed python files
35+
id: changed-python-files
36+
env:
37+
CHANGED_PYTHON_FILES: ${{ steps.raw-changed-python-files.outputs.all_changed_files }}
38+
run: |
39+
if [[ " $CHANGED_PYTHON_FILES " == *" poetry.lock "* ]]; then
40+
# if poetry.lock is changed, we need to check everything
41+
CHANGED_PYTHON_FILES="."
42+
fi
43+
echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT"
44+
45+
format:
46+
if: needs.changed-files.outputs.any_python_changed == 'true'
47+
runs-on: ubuntu-latest
48+
name: Check formatting
49+
needs: changed-files
50+
steps:
51+
- uses: actions/checkout@v6
52+
- name: Install Python tools
53+
uses: BrandonLWhite/pipx-install-action@v1.0.3
54+
- uses: actions/setup-python@v6
55+
with:
56+
python-version: ${{ env.PYTHON_VERSION }}
57+
cache: poetry
58+
59+
- name: Install dependencies
60+
run: poetry install
61+
62+
- name: Check code formatting
63+
# the job output will contain colored diffs with what needs adjusting
64+
run: poe check-format --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}
65+
66+
lint:
67+
if: needs.changed-files.outputs.any_python_changed == 'true'
68+
runs-on: ubuntu-latest
69+
name: Check linting
70+
needs: changed-files
71+
steps:
72+
- uses: actions/checkout@v6
73+
- name: Install Python tools
74+
uses: BrandonLWhite/pipx-install-action@v1.0.3
75+
- uses: actions/setup-python@v6
76+
with:
77+
python-version: ${{ env.PYTHON_VERSION }}
78+
cache: poetry
79+
80+
- name: Install dependencies
81+
run: poetry install
82+
83+
- name: Lint code
84+
run: poe lint --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}
85+
86+
mypy:
87+
if: needs.changed-files.outputs.any_python_changed == 'true'
88+
runs-on: ubuntu-latest
89+
name: Check types with mypy
90+
needs: changed-files
91+
steps:
92+
- uses: actions/checkout@v6
93+
- name: Install Python tools
94+
uses: BrandonLWhite/pipx-install-action@v1.0.3
95+
- uses: actions/setup-python@v6
96+
with:
97+
python-version: ${{ env.PYTHON_VERSION }}
98+
cache: poetry
99+
100+
- name: Install dependencies
101+
run: poetry install
102+
103+
- name: Type check code
104+
uses: liskin/gh-problem-matcher-wrap@v3
105+
with:
106+
linters: mypy
107+
run: poe check-types --show-column-numbers --no-error-summary .

.github/workflows/main.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
name: Run tests
11+
permissions:
12+
id-token: write
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v6
20+
- name: Install Python tools
21+
uses: BrandonLWhite/pipx-install-action@v1.0.3
22+
- name: Setup Python with poetry caching
23+
# poetry cache requires poetry to already be installed, weirdly
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
cache: poetry
28+
29+
- name: Install system dependencies
30+
run: |
31+
sudo apt install --yes --no-install-recommends \
32+
gstreamer1.0-plugins-good \
33+
gstreamer1.0-plugins-bad \
34+
gstreamer1.0-plugins-ugly \
35+
libchromaprint-tools
36+
37+
- name: Test
38+
run: |-
39+
poetry install
40+
poe test-with-coverage
41+
42+
- name: Upload test results to Codecov
43+
uses: codecov/test-results-action@v1
44+
with:
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
47+
- name: Upload code coverage
48+
uses: codecov/codecov-action@v5
49+
with:
50+
flags: ${{ matrix.platform}}_python${{ matrix.python-version }}
51+
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Make a release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version of the new release, just as a number with no prepended "v"'
8+
required: true
9+
10+
env:
11+
PYTHON_VERSION: 3.10
12+
NEW_VERSION: ${{ inputs.version }}
13+
NEW_TAG: v${{ inputs.version }}
14+
15+
jobs:
16+
increment-version:
17+
name: Bump version, commit and create tag
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v6
21+
- name: Install Python tools
22+
uses: BrandonLWhite/pipx-install-action@v1.0.3
23+
- uses: actions/setup-python@v6
24+
with:
25+
python-version: ${{ env.PYTHON_VERSION }}
26+
cache: poetry
27+
28+
- name: Bump project version
29+
run: poetry version "${{ env.NEW_VERSION }}"
30+
31+
- uses: EndBug/add-and-commit@v9
32+
id: commit_and_tag
33+
name: Commit the changes and create tag
34+
with:
35+
message: "Increment version to ${{ env.NEW_VERSION }}"
36+
tag: "${{ env.NEW_TAG }} --force"
37+
38+
build:
39+
name: Build the distribution package
40+
runs-on: ubuntu-latest
41+
needs: increment-version
42+
steps:
43+
- uses: actions/checkout@v6
44+
with:
45+
ref: ${{ env.NEW_TAG }}
46+
47+
- name: Install Python tools
48+
uses: BrandonLWhite/pipx-install-action@v1.0.3
49+
- uses: actions/setup-python@v6
50+
with:
51+
python-version: ${{ env.PYTHON_VERSION }}
52+
cache: poetry
53+
54+
- name: Build a binary wheel and a source tarball
55+
run: poetry build
56+
57+
- name: Store the package
58+
uses: actions/upload-artifact@v6
59+
with:
60+
name: python-package-distributions
61+
path: dist/
62+
63+
publish-to-pypi:
64+
name: Publish distribution 📦 to PyPI
65+
runs-on: ubuntu-latest
66+
needs: build
67+
environment:
68+
name: pypi
69+
url: https://pypi.org/p/pyacoustid
70+
permissions:
71+
id-token: write
72+
steps:
73+
- name: Download all the dists
74+
uses: actions/download-artifact@v7
75+
with:
76+
name: python-package-distributions
77+
path: dist/
78+
- name: Publish distribution 📦 to PyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1

MANIFEST.in

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ in C but portable, and the Web service, which provides fingerprint lookups.
1313
Installation
1414
------------
1515

16-
This library works with Python 2 (2.7+, possibly also 2.6) and Python 3
17-
(3.3+).
16+
This library works with Python 3.10+.
1817

1918
First, install the `Chromaprint`_ fingerprinting library by `Lukáš Lalinský`__.
2019
(The library itself depends on an FFT library, but it's smart enough to use an

0 commit comments

Comments
 (0)