-
Notifications
You must be signed in to change notification settings - Fork 65
Modernize setup, add tests #91
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e35eadf
Replace setup.py with pyproject
snejus 5b78111
Migrate to Python 3.10+
snejus d0c5e7e
Upgrade dependencies
snejus c571eda
Add release workflow
snejus 785b262
Add changelog reminder
snejus f4b0d84
Configure linting
snejus d906c23
Reformat the codebase
snejus 37f25ae
Fix lint issues
snejus e818667
Add tests
snejus d5fffeb
Add git blame ignore revs
snejus a5ee3fb
Remove support for Python 3.14
snejus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # 2026 | ||
| # Reformat the codebase | ||
| d906c2375d78f81fb27083c9042a87e282ad8789 | ||
| # Fix lint issues | ||
| 37f25ae3ed9c1d1cfbb4e17025af8c19f27725d5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Verify changelog updated | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - ready_for_review | ||
|
|
||
| jobs: | ||
| check_changes: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Get all updated Python files | ||
| id: changed-python-files | ||
| uses: tj-actions/changed-files@v47 | ||
| with: | ||
| files: | | ||
| **.py | ||
|
|
||
| - name: Check for the changelog update | ||
| id: changelog-update | ||
| uses: tj-actions/changed-files@v47 | ||
| with: | ||
| files: docs/changelog.rst | ||
|
|
||
| - name: Comment under the PR with a reminder | ||
| if: steps.changed-python-files.outputs.any_changed == 'true' && steps.changelog-update.outputs.any_changed == 'false' | ||
| uses: thollander/actions-comment-pull-request@v3 | ||
| with: | ||
| 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.' | ||
| GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: Lint check | ||
| run-name: Lint code | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| concurrency: | ||
| # Cancel previous workflow run when a new commit is pushed to a feature branch | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} | ||
snejus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| env: | ||
| PYTHON_VERSION: "3.10" | ||
|
|
||
| jobs: | ||
| changed-files: | ||
| runs-on: ubuntu-latest | ||
| name: Get changed files | ||
| outputs: | ||
| any_python_changed: ${{ steps.raw-changed-python-files.outputs.any_changed }} | ||
| changed_python_files: ${{ steps.changed-python-files.outputs.all_changed_files }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Get changed python files | ||
| id: raw-changed-python-files | ||
| uses: tj-actions/changed-files@v47 | ||
| with: | ||
| files: | | ||
| **.py | ||
| poetry.lock | ||
|
|
||
| - name: Check changed python files | ||
| id: changed-python-files | ||
| env: | ||
| CHANGED_PYTHON_FILES: ${{ steps.raw-changed-python-files.outputs.all_changed_files }} | ||
| run: | | ||
| if [[ " $CHANGED_PYTHON_FILES " == *" poetry.lock "* ]]; then | ||
| # if poetry.lock is changed, we need to check everything | ||
| CHANGED_PYTHON_FILES="." | ||
| fi | ||
| echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT" | ||
|
|
||
| format: | ||
| if: needs.changed-files.outputs.any_python_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| name: Check formatting | ||
| needs: changed-files | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install Python tools | ||
| uses: BrandonLWhite/pipx-install-action@v1.0.3 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| cache: poetry | ||
|
|
||
| - name: Install dependencies | ||
| run: poetry install | ||
|
|
||
| - name: Check code formatting | ||
| # the job output will contain colored diffs with what needs adjusting | ||
| run: poe check-format --output-format=github ${{ needs.changed-files.outputs.changed_python_files }} | ||
|
|
||
| lint: | ||
| if: needs.changed-files.outputs.any_python_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| name: Check linting | ||
| needs: changed-files | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install Python tools | ||
| uses: BrandonLWhite/pipx-install-action@v1.0.3 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| cache: poetry | ||
|
|
||
| - name: Install dependencies | ||
| run: poetry install | ||
|
|
||
| - name: Lint code | ||
| run: poe lint --output-format=github ${{ needs.changed-files.outputs.changed_python_files }} | ||
|
|
||
| mypy: | ||
| 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@v6 | ||
| - name: Install Python tools | ||
| uses: BrandonLWhite/pipx-install-action@v1.0.3 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| cache: poetry | ||
|
|
||
| - name: Install dependencies | ||
| run: poetry install | ||
|
|
||
| - name: Type check code | ||
| uses: liskin/gh-problem-matcher-wrap@v3 | ||
| with: | ||
| linters: mypy | ||
| run: poe check-types --show-column-numbers --no-error-summary . | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: Test | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run tests | ||
| permissions: | ||
| id-token: write | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install Python tools | ||
| uses: BrandonLWhite/pipx-install-action@v1.0.3 | ||
| - name: Setup Python with poetry caching | ||
| # poetry cache requires poetry to already be installed, weirdly | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: poetry | ||
|
|
||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt install --yes --no-install-recommends \ | ||
| gstreamer1.0-plugins-good \ | ||
| gstreamer1.0-plugins-bad \ | ||
| gstreamer1.0-plugins-ugly \ | ||
| libchromaprint-tools | ||
|
|
||
| - name: Test | ||
| run: |- | ||
| poetry install | ||
| poe test-with-coverage | ||
|
|
||
| - name: Upload test results to Codecov | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
|
|
||
| - name: Upload code coverage | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| flags: ${{ matrix.platform}}_python${{ matrix.python-version }} | ||
| use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Make a release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version of the new release, just as a number with no prepended "v"' | ||
| required: true | ||
|
|
||
| env: | ||
| PYTHON_VERSION: 3.10 | ||
| NEW_VERSION: ${{ inputs.version }} | ||
| NEW_TAG: v${{ inputs.version }} | ||
|
|
||
| jobs: | ||
| increment-version: | ||
| name: Bump version, commit and create tag | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install Python tools | ||
| uses: BrandonLWhite/pipx-install-action@v1.0.3 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| cache: poetry | ||
|
|
||
| - name: Bump project version | ||
| run: poetry version "${{ env.NEW_VERSION }}" | ||
|
|
||
| - uses: EndBug/add-and-commit@v9 | ||
| id: commit_and_tag | ||
| name: Commit the changes and create tag | ||
| with: | ||
| message: "Increment version to ${{ env.NEW_VERSION }}" | ||
| tag: "${{ env.NEW_TAG }} --force" | ||
|
|
||
| build: | ||
| name: Build the distribution package | ||
| runs-on: ubuntu-latest | ||
| needs: increment-version | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ env.NEW_TAG }} | ||
|
|
||
| - name: Install Python tools | ||
| uses: BrandonLWhite/pipx-install-action@v1.0.3 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| cache: poetry | ||
|
|
||
| - name: Build a binary wheel and a source tarball | ||
| run: poetry build | ||
|
|
||
| - name: Store the package | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
|
|
||
| publish-to-pypi: | ||
| name: Publish distribution 📦 to PyPI | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/p/pyacoustid | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - name: Download all the dists | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: python-package-distributions | ||
| path: dist/ | ||
| - name: Publish distribution 📦 to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.