-
Notifications
You must be signed in to change notification settings - Fork 11
123 lines (106 loc) · 4.16 KB
/
Copy pathci.yml
File metadata and controls
123 lines (106 loc) · 4.16 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
116
117
118
119
120
121
122
123
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cqfd
run: |
git clone https://github.com/savoirfairelinux/cqfd.git /tmp/cqfd
cd /tmp/cqfd
sudo make install
- name: Initialize cqfd container
run: cqfd init
- name: Check formatting
run: cqfd -b check_format
- name: Run flake8
run: cqfd -b flake
test:
runs-on: ubuntu-24.04
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
# SonarCloud needs the full history to blame each line. Without
# it, every line of a file the pull request touches counts as new
# code, which drags pre-existing issues into the quality gate.
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
qemu-system-x86 \
libvirt-daemon-system \
libvirt-dev \
pkg-config
- name: Start libvirtd and grant access
run: |
sudo systemctl start libvirtd
sudo usermod -aG libvirt "$USER"
- name: Install package with test deps
# Editable on purpose: coverage instruments the vm_manager package in
# the checkout, so the tests must import it from there. A regular
# install copies it to site-packages, the tests import that copy, and
# coverage reports 0% on every module.
#
# Constrained so a run does not pick up a new release on its own,
# and restricted to wheels so no dependency gets to run a setup
# script during the install. libvirt-python is the one exception:
# it publishes no wheel and compiles against the system libvirt
# headers, which is why libvirt-dev and pkg-config are installed
# above. Naming it keeps the exception to that single package
# instead of reopening source builds for the whole graph.
run: |
pip install -e ".[test]" -c requirements-ci.txt \
--only-binary :all: --no-binary libvirt-python
- name: Run tests
run: |
sg libvirt -c "pytest tests/ -v --tb=short \
--cov --cov-report=term-missing --cov-report=xml --cov-report=html \
--ignore=tests/test_vm_manager_cluster.py \
--ignore=tests/test_vm_manager_cmd_cluster.py"
- name: Add coverage to job summary
if: always()
run: |
if [ -f .coverage ]; then
echo '## Coverage' >> "$GITHUB_STEP_SUMMARY"
python -m coverage report --format=markdown >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.xml
htmlcov/
if-no-files-found: ignore
# Automatic Analysis must stay off in the SonarCloud project
# settings, otherwise SonarCloud rejects this analysis. Skipped when
# SONAR_TOKEN is unavailable, which is the case for pull requests
# opened from a fork.
- name: SonarCloud analysis
if: env.SONAR_TOKEN != ''
uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1
env:
SONAR_HOST_URL: https://sonarcloud.io
- name: Install documentation dependencies
# Editable too, so this step adds the docs extra instead of
# replacing the editable install made above by a copy. Sphinx and
# sphinx-argparse both ship wheels, the exception below is still
# needed because resolving the package pulls its runtime
# dependencies, libvirt-python included.
run: |
pip install -e ".[docs]" -c requirements-ci.txt \
--only-binary :all: --no-binary libvirt-python
- name: Build documentation
run: sphinx-build -b html docs/ docs/_build/html