Repository navigation
183 lines (160 loc) · 5.96 KB
/
Copy pathpull_request.yml
File metadata and controls
183 lines (160 loc) · 5.96 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Pull Request
permissions: read-all
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
jobs:
CodeCheck:
runs-on: ubuntu-24.04
steps:
- name: Setup Environment
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-git python3-ply git shellcheck perl codespell wget
sudo mkdir -p /usr/share/codespell
sudo wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txt -O /usr/share/codespell/dictionary.txt
sudo wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/spelling.txt -O /usr/bin/spelling.txt
sudo wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/const_structs.checkpatch -O /usr/bin/const_structs.checkpatch
sudo wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl -O /bin/checkpatch.pl
sudo chmod +x /bin/checkpatch.pl
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Code
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
./.github/scripts/pr_check "origin/${{ github.base_ref }}" "${{ github.sha }}"
BuildCheck:
runs-on: ubuntu-24.04
steps:
- name: Show runner info
shell: bash
run: |
set -euo pipefail
echo "===== GitHub runner context ====="
echo "Runner OS: ${RUNNER_OS:-unknown}"
echo "Runner arch: ${RUNNER_ARCH:-unknown}"
echo "GitHub ref: ${GITHUB_REF:-unknown}"
echo "GitHub SHA: ${GITHUB_SHA:-unknown}"
echo "===== /etc/os-release ====="
cat /etc/os-release || true
echo "===== uname ====="
uname -a || true
echo "===== docker ====="
docker --version
docker info >/dev/null && echo "Docker daemon is ready."
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Build Docker Image
run: docker build -f BM/Dockerfile.build.ddt -t builder BM
- name: Build Project
run: ./.github/scripts/build_check
python-style-check:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install sphinx
pip install -r ./.github/scripts/requirements-ci.txt
- name: Run inspekt
run: inspekt checkall ./KVM --disable-style E501,E265,W601,E402,E722,E741 --disable-lint=W,R,C,E0601,E1002,E1101,E1103,E1120,F0401,I0011,I1101 --enable-lint W0611,W1201 --no-license-check
- run: echo "This job's status is ${{ job.status }}."
cfg-lint-check:
name: Cfg lint
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed cfg files
id: cfg-files
shell: bash
run: |
set -euo pipefail
BASE="${{ github.event.pull_request.base.sha }}"
HEAD="${{ github.event.pull_request.head.sha }}"
MERGE_BASE="$(git merge-base "${BASE}" "${HEAD}")"
echo "Base SHA: ${BASE}"
echo "Head SHA: ${HEAD}"
echo "Merge base: ${MERGE_BASE}"
# Include added, copied, modified, renamed, and type-changed cfg files; exclude deleted files.
git diff --name-only --diff-filter=ACMRT "${MERGE_BASE}" "${HEAD}" -- 'KVM/qemu/*.cfg' > changed_cfg_files.txt
echo "Changed cfg files:"
cat changed_cfg_files.txt || true
{
echo "all_changed_files<<EOF"
cat changed_cfg_files.txt
echo "EOF"
} >> "$GITHUB_OUTPUT"
if [ -s changed_cfg_files.txt ]; then
echo "any_changed=true" >> "$GITHUB_OUTPUT"
else
echo "any_changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Set matrix
id: set-matrix
shell: bash
run: |
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
with open("changed_cfg_files.txt", "r", encoding="utf-8") as f:
files = [line.strip() for line in f if line.strip()]
print(f"matrix={json.dumps(files)}")
PY
- name: Check cfg files lint
if: steps.cfg-files.outputs.any_changed == 'true'
shell: bash
run: |
set -euo pipefail
mapfile -t cfg_files < changed_cfg_files.txt
echo "Linting cfg files:"
printf ' %s\n' "${cfg_files[@]}"
./.github/scripts/cfg-lint-check.py "${cfg_files[@]}"
cartesian-syntax-check:
name: Cartesian syntax
runs-on: ubuntu-24.04
needs: cfg-lint-check
if: ${{ needs.cfg-lint-check.outputs.matrix != '[]' }}
strategy:
matrix:
file: ${{ fromJson(needs.cfg-lint-check.outputs.matrix) }}
fail-fast: false
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse ${{ matrix.file }} into Cartesian configuration
env:
CFG_FILE: ${{ matrix.file }}
run: |
echo "Parse ${CFG_FILE} into Cartesian configuration"
sed -i '1s/^/variants:\n/' ${CFG_FILE}
curl -fsSL https://raw.githubusercontent.com/avocado-framework/avocado-vt/master/virttest/cartesian_config.py | python3 - -f ${CFG_FILE}