/
/
/
1# This workflow will install Python dependencies, run tests and lint
2# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
4name: Test
5
6on:
7 push:
8 branches:
9 - stable
10 - dev
11 pull_request:
12 branches:
13 - stable
14 - dev
15 workflow_dispatch:
16 workflow_call:
17 inputs:
18 ref:
19 description: "Git ref to checkout"
20 required: false
21 type: string
22
23permissions:
24 contents: read
25
26jobs:
27 lint:
28 runs-on: ubuntu-latest
29
30 steps:
31 - name: Check out code from GitHub
32 uses: actions/checkout@v6
33 with:
34 ref: ${{ inputs.ref || github.ref }}
35 - name: Set up Python
36 uses: actions/[email protected]
37 with:
38 python-version: "3.12"
39 # Cache apt .deb files to speed up ffmpeg installation (in home to avoid permission issues).
40 - name: Cache apt packages
41 uses: actions/cache@v5
42 with:
43 path: ~/.cache/apt-packages
44 key: apt-ffmpeg-${{ runner.os }}
45 - name: Install ffmpeg
46 run: |
47 # Restore cached .deb files to apt cache (if any)
48 sudo cp ~/.cache/apt-packages/*.deb /var/cache/apt/archives/ 2>/dev/null || true
49 sudo apt-get update && sudo apt-get install -y ffmpeg
50 # Save .deb files for next run
51 mkdir -p ~/.cache/apt-packages && cp /var/cache/apt/archives/*.deb ~/.cache/apt-packages/ 2>/dev/null || true
52 - name: Install uv
53 run: pip install uv
54 - name: Cache uv packages
55 uses: actions/cache@v5
56 with:
57 path: ~/.cache/uv
58 key: uv-${{ runner.os }}-3.12-${{ hashFiles('requirements_all.txt', 'pyproject.toml') }}
59 - name: Install dependencies
60 run: uv pip install --system . .[test] -r requirements_all.txt
61 - name: Lint/test with pre-commit
62 run: SKIP=no-commit-to-branch pre-commit run --all-files
63
64 test:
65 runs-on: ubuntu-latest
66 strategy:
67 fail-fast: false
68 matrix:
69 python-version:
70 - "3.12"
71
72 steps:
73 - name: Check out code from GitHub
74 uses: actions/checkout@v6
75 with:
76 ref: ${{ inputs.ref || github.ref }}
77 - name: Set up Python ${{ matrix.python-version }}
78 uses: actions/[email protected]
79 with:
80 python-version: ${{ matrix.python-version }}
81 # Cache apt .deb files to speed up ffmpeg installation (in home to avoid permission issues).
82 - name: Cache apt packages
83 uses: actions/cache@v5
84 with:
85 path: ~/.cache/apt-packages
86 key: apt-ffmpeg-${{ runner.os }}
87 - name: Install ffmpeg
88 run: |
89 # Restore cached .deb files to apt cache (if any)
90 sudo cp ~/.cache/apt-packages/*.deb /var/cache/apt/archives/ 2>/dev/null || true
91 sudo apt-get update && sudo apt-get install -y ffmpeg
92 # Save .deb files for next run
93 mkdir -p ~/.cache/apt-packages && cp /var/cache/apt/archives/*.deb ~/.cache/apt-packages/ 2>/dev/null || true
94 - name: Install uv
95 run: pip install uv
96 - name: Cache uv packages
97 uses: actions/cache@v5
98 with:
99 path: ~/.cache/uv
100 key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements_all.txt', 'pyproject.toml') }}
101 - name: Install dependencies
102 run: uv pip install --system . .[test] -r requirements_all.txt
103 - name: Pytest
104 run: pytest --durations 10 --cov-report term-missing --cov=music_assistant --cov-report=xml tests/
105