Debian Codegraph @

.github/workflows/ci.yaml

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