forked from jumpstarter-dev/jumpstarter
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (99 loc) · 3.38 KB
/
python-tests.yaml
File metadata and controls
115 lines (99 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Python Tests
on:
workflow_dispatch:
push:
branches:
- main
- release-*
pull_request:
merge_group:
permissions:
contents: read
pull-requests: read
jobs:
changes:
if: github.repository_owner == 'jumpstarter-dev'
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.filter.outputs.python }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ github.base_ref || github.event.merge_group.base_ref || 'main' }}
filters: |
python:
- 'python/**'
- '.github/workflows/python-tests.yaml'
pytest-matrix:
needs: changes
if: needs.changes.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
runs-on: [ubuntu-24.04, macos-15]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
with:
version: latest
python-version: ${{ matrix.python-version }}
- name: Install Qemu (Linux)
if: runner.os == 'Linux'
run: |
echo <<EOF | sudo tee /etc/udev/rules.d/99-kvm.rules
KERNEL=="kvm", GROUP="kvm", MODE="0666"
KERNEL=="vhost-vsock", GROUP="kvm", MODE="0666"
KERNEL=="vhost-net", GROUP="kvm", MODE="0666"
EOF
sudo udevadm control --reload-rules
sudo modprobe vhost_vsock
sudo modprobe vhost_net
sudo chmod 0666 /dev/kvm /dev/vhost-vsock /dev/vhost-net
sudo apt-get update
sudo apt-get install -y qemu-system-arm qemu-system-x86
- name: Install libgpiod-dev (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libgpiod-dev liblgpio-dev
- name: Install Qemu (macOS)
if: runner.os == 'macOS'
run: |
brew install qemu
- name: Cache Fedora Cloud images
id: cache-fedora-cloud-images
uses: actions/cache@v5
with:
path: python/packages/jumpstarter-driver-qemu/images
key: fedora-cloud-43-1.6
- name: Download Fedora Cloud images
if: steps.cache-fedora-cloud-images.outputs.cache-hit != 'true'
run: |
for arch in aarch64 x86_64; do
curl -L --fail --output "python/packages/jumpstarter-driver-qemu/images/Fedora-Cloud-Base-Generic-43-1.6.${arch}.qcow2" \
"https://iad.mirror.rackspace.com/fedora/releases/43/Cloud/${arch}/images/Fedora-Cloud-Base-Generic-43-1.6.${arch}.qcow2"
done
- name: Run pytest
working-directory: python
run: |
make test
# https://github.com/orgs/community/discussions/26822
pytest:
runs-on: ubuntu-latest
needs: [changes, pytest-matrix]
if: ${{ always() }}
steps:
- run: exit 1
# Fail on failures or cancellations, but allow skips when no relevant changes
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| (contains(needs.*.result, 'skipped') && needs.changes.outputs.should_run == 'true')
}}