/
/
/
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 continue-on-error: true
30
31 steps:
32 - name: Check out code from GitHub
33 uses: actions/checkout@v6
34 with:
35 ref: ${{ inputs.ref || github.ref }}
36 - name: Set up Python
37 uses: actions/[email protected]
38 with:
39 python-version: "3.12"
40 # Cache apt .deb files to speed up ffmpeg installation (in home to avoid permission issues).
41 - name: Cache apt packages
42 uses: actions/cache@v5
43 with:
44 path: ~/.cache/apt-packages
45 key: apt-ffmpeg-${{ runner.os }}
46 - name: Install ffmpeg
47 run: |
48 # Restore cached .deb files to apt cache (if any)
49 sudo cp ~/.cache/apt-packages/*.deb /var/cache/apt/archives/ 2>/dev/null || true
50 sudo apt-get update && sudo apt-get install -y ffmpeg
51 # Save .deb files for next run
52 mkdir -p ~/.cache/apt-packages && cp /var/cache/apt/archives/*.deb ~/.cache/apt-packages/ 2>/dev/null || true
53 - name: Install uv
54 run: pip install uv
55 - name: Cache uv packages
56 uses: actions/cache@v5
57 with:
58 path: ~/.cache/uv
59 key: uv-${{ runner.os }}-3.12-${{ hashFiles('requirements_all.txt', 'pyproject.toml') }}
60 - name: Install dependencies
61 run: uv pip install --system . .[test] -r requirements_all.txt
62 - name: Lint/test with pre-commit
63 run: SKIP=no-commit-to-branch pre-commit run --all-files
64
65 test:
66 runs-on: ubuntu-latest
67 continue-on-error: true
68 strategy:
69 fail-fast: false
70 matrix:
71 python-version:
72 - "3.12"
73
74 steps:
75 - name: Check out code from GitHub
76 uses: actions/checkout@v6
77 with:
78 ref: ${{ inputs.ref || github.ref }}
79 - name: Set up Python ${{ matrix.python-version }}
80 uses: actions/[email protected]
81 with:
82 python-version: ${{ matrix.python-version }}
83 # Cache apt .deb files to speed up ffmpeg installation (in home to avoid permission issues).
84 - name: Cache apt packages
85 uses: actions/cache@v5
86 with:
87 path: ~/.cache/apt-packages
88 key: apt-ffmpeg-${{ runner.os }}
89 - name: Install ffmpeg
90 run: |
91 # Restore cached .deb files to apt cache (if any)
92 sudo cp ~/.cache/apt-packages/*.deb /var/cache/apt/archives/ 2>/dev/null || true
93 sudo apt-get update && sudo apt-get install -y ffmpeg
94 # Save .deb files for next run
95 mkdir -p ~/.cache/apt-packages && cp /var/cache/apt/archives/*.deb ~/.cache/apt-packages/ 2>/dev/null || true
96 - name: Install uv
97 run: pip install uv
98 - name: Cache uv packages
99 uses: actions/cache@v5
100 with:
101 path: ~/.cache/uv
102 key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements_all.txt', 'pyproject.toml') }}
103 - name: Install dependencies
104 run: uv pip install --system . .[test] -r requirements_all.txt
105 - name: Pytest
106 run: pytest --durations 10 --cov-report term-missing --cov=music_assistant --cov-report=xml tests/
107