name: Test 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/main' }} env: PY_COLORS: 1 jobs: base-install: name: Test base installation runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Install uv uses: astral-sh/setup-uv@v8.1.0 with: python-version: "3.10" - name: Install Python tools run: uv tool install "poethepoet>=0.26,<0.47.0" - name: Install base dependencies run: poe install --no-dev - name: Run beets env: BEETSDIR: ${{ runner.temp }}/beets run: uv run --no-sync beet version test: name: Run tests strategy: fail-fast: false matrix: platform: [ubuntu-latest, windows-latest] python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: ${{ matrix.platform }} env: IS_MAIN_PYTHON: ${{ matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest' }} steps: - uses: actions/checkout@v5 - name: Install uv uses: astral-sh/setup-uv@v8.1.0 with: python-version: ${{ matrix.python-version }} - name: Install Python tools run: uv tool install "poethepoet>=0.26,<0.47.0" - name: Install system dependencies on Windows if: matrix.platform == 'windows-latest' shell: pwsh run: | $maxAttempts = 3 for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) { # mp3gain's Chocolatey install script pulls from a flaky SourceForge # HTTP URL and has no upstream checksums, so allow it and retry. choco install mp3gain -y --allow-empty-checksums --no-progress if ($LASTEXITCODE -eq 0) { break } if ($attempt -eq $maxAttempts) { throw "mp3gain install failed after $maxAttempts attempts." } Start-Sleep -Seconds 3 } - name: Install system dependencies on Ubuntu if: matrix.platform == 'ubuntu-latest' run: | sudo apt update sudo apt install --yes --no-install-recommends \ ffmpeg \ flac \ gobject-introspection \ gstreamer1.0-plugins-base \ imagemagick \ libcairo2-dev \ libgirepository-2.0-dev \ mp3gain \ pandoc \ python3-gst-1.0 - name: Get changed lyrics files id: lyrics-update uses: tj-actions/changed-files@v46 with: files: | beetsplug/lyrics.py test/plugins/test_lyrics.py - name: Add pytest annotator uses: liskin/gh-problem-matcher-wrap@v3 with: linters: pytest action: add - if: ${{ env.IS_MAIN_PYTHON != 'true' }} name: Test without coverage run: | poe install --group test --extra autobpm --extra discogs --extra lyrics --extra replaygain --extra reflink --extra fetchart --extra chroma --extra sonosupdate poe test - if: ${{ env.IS_MAIN_PYTHON == 'true' }} name: Test with coverage env: LYRICS_UPDATED: ${{ steps.lyrics-update.outputs.any_changed }} run: | poe install --group test --extra autobpm --extra discogs --extra lyrics --extra replaygain --extra reflink --extra fetchart --extra chroma --extra sonosupdate --group docs poe docs poe test-with-coverage - if: ${{ !cancelled() }} name: Upload test results to Codecov uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} - if: ${{ env.IS_MAIN_PYTHON == 'true' }} name: Store the coverage report uses: actions/upload-artifact@v4 with: name: coverage-report path: .reports/coverage.xml upload-coverage: name: Upload coverage report needs: test runs-on: ubuntu-latest permissions: id-token: write steps: - uses: actions/checkout@v5 - name: Get the coverage report uses: actions/download-artifact@v5 with: name: coverage-report - name: Upload code coverage uses: codecov/codecov-action@v5 with: files: ./coverage.xml use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}