Debian Codegraph @

.github/workflows/ci.yaml

raw
1 name: Test
2 on:
3 pull_request:
4 push:
5 branches:
6 - master
7
8 concurrency:
9 # Cancel previous workflow run when a new commit is pushed to a feature branch
10 group: ${{ github.workflow }}-${{ github.ref }}
11 cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
12
13 env:
14 PY_COLORS: 1
15
16 jobs:
17 base-install:
18 name: Test base installation
19 runs-on: ubuntu-latest
20 steps:
21 - uses: actions/checkout@v5
22 - name: Install uv
23 uses: astral-sh/[email protected]
24 with:
25 python-version: "3.10"
26
27 - name: Install Python tools
28 run: uv tool install "poethepoet>=0.26,<0.47.0"
29
30 - name: Install base dependencies
31 run: poe install --no-dev
32
33 - name: Run beets
34 env:
35 BEETSDIR: ${{ runner.temp }}/beets
36 run: uv run --no-sync beet version
37
38 test:
39 name: Run tests
40 strategy:
41 fail-fast: false
42 matrix:
43 platform: [ubuntu-latest, windows-latest]
44 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
45 runs-on: ${{ matrix.platform }}
46 env:
47 IS_MAIN_PYTHON: ${{ matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest' }}
48 steps:
49 - uses: actions/checkout@v5
50 - name: Install uv
51 uses: astral-sh/[email protected]
52 with:
53 python-version: ${{ matrix.python-version }}
54
55 - name: Install Python tools
56 run: uv tool install "poethepoet>=0.26,<0.47.0"
57
58 - name: Install system dependencies on Windows
59 if: matrix.platform == 'windows-latest'
60 shell: pwsh
61 run: |
62 $maxAttempts = 3
63 for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
64 # mp3gain's Chocolatey install script pulls from a flaky SourceForge
65 # HTTP URL and has no upstream checksums, so allow it and retry.
66 choco install mp3gain -y --allow-empty-checksums --no-progress
67 if ($LASTEXITCODE -eq 0) {
68 break
69 }
70 if ($attempt -eq $maxAttempts) {
71 throw "mp3gain install failed after $maxAttempts attempts."
72 }
73 Start-Sleep -Seconds 3
74 }
75
76 - name: Install system dependencies on Ubuntu
77 if: matrix.platform == 'ubuntu-latest'
78 run: |
79 sudo apt update
80 sudo apt install --yes --no-install-recommends \
81 ffmpeg \
82 flac \
83 gobject-introspection \
84 gstreamer1.0-plugins-base \
85 imagemagick \
86 libcairo2-dev \
87 libgirepository-2.0-dev \
88 mp3gain \
89 pandoc \
90 python3-gst-1.0
91
92 - name: Get changed lyrics files
93 id: lyrics-update
94 uses: tj-actions/changed-files@v46
95 with:
96 files: |
97 beetsplug/lyrics.py
98 test/plugins/test_lyrics.py
99
100 - name: Add pytest annotator
101 uses: liskin/gh-problem-matcher-wrap@v3
102 with:
103 linters: pytest
104 action: add
105
106 - if: ${{ env.IS_MAIN_PYTHON != 'true' }}
107 name: Test without coverage
108 run: |
109 poe install --group test --extra autobpm --extra discogs --extra lyrics --extra replaygain --extra reflink --extra fetchart --extra chroma --extra sonosupdate
110 poe test
111
112 - if: ${{ env.IS_MAIN_PYTHON == 'true' }}
113 name: Test with coverage
114 env:
115 LYRICS_UPDATED: ${{ steps.lyrics-update.outputs.any_changed }}
116 run: |
117 poe install --group test --extra autobpm --extra discogs --extra lyrics --extra replaygain --extra reflink --extra fetchart --extra chroma --extra sonosupdate --group docs
118 poe docs
119 poe test-with-coverage
120
121 - if: ${{ !cancelled() }}
122 name: Upload test results to Codecov
123 uses: codecov/test-results-action@v1
124 with:
125 token: ${{ secrets.CODECOV_TOKEN }}
126
127 - if: ${{ env.IS_MAIN_PYTHON == 'true' }}
128 name: Store the coverage report
129 uses: actions/upload-artifact@v4
130 with:
131 name: coverage-report
132 path: .reports/coverage.xml
133
134 upload-coverage:
135 name: Upload coverage report
136 needs: test
137 runs-on: ubuntu-latest
138 permissions:
139 id-token: write
140 steps:
141 - uses: actions/checkout@v5
142
143 - name: Get the coverage report
144 uses: actions/download-artifact@v5
145 with:
146 name: coverage-report
147
148 - name: Upload code coverage
149 uses: codecov/codecov-action@v5
150 with:
151 files: ./coverage.xml
152 use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}