-
Notifications
You must be signed in to change notification settings - Fork 37
259 lines (255 loc) · 9.64 KB
/
tests.yaml
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: Tests
on:
pull_request:
push:
branches:
- main
jobs:
linters:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install python packages and dependencies
run: |
sudo snap install --no-wait ruff
sudo apt update
sudo apt install -y libapt-pkg-dev aspell
pip install python-apt@https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-apt/2.4.0ubuntu1/python-apt_2.4.0ubuntu1.tar.xz
pip install -U -e .[dev]
sudo snap watch --last=install
- name: Run black
run: |
make test-black
- name: Run codespell
run: |
make test-codespell
- name: Run ruff
run: |
make test-ruff
- name: Run mypy
run: |
make test-mypy
- name: Run pydocstyle
run: |
make test-pydocstyle
- name: Run lint-docs
run: |
tox run -e lint-docs
- name: Run pyright
run: |
sudo snap install --classic node
sudo snap install --classic pyright
make test-pyright
- name: Run linkcheck, woke, spelling
run: |
sudo snap install woke
make test-docs
unit-tests:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: |
3.10
3.12
3.13-dev
cache: pip
- name: Install apt build dependencies
run: |
sudo apt update
sudo apt install -y libapt-pkg-dev intltool fuse-overlayfs python3-apt
- name: Install additional test dependencies
run: |
echo "::group::snap install"
sudo snap install chisel --channel latest/candidate --no-wait
echo "::endgroup::"
echo "::group::apt install"
sudo apt install -y ninja-build cmake scons \
autoconf automake autopoint gcc git gperf help2man libtool texinfo
# Install go from the Snap Store
go_job=$(sudo snap install --no-wait --classic go)
# Install RPM dependencies for RPM tests
sudo apt install rpm
# Install poetry. From pipx on focal, from apt on newer systems.
if [[ $(grep VERSION_CODENAME /etc/os-release ) == "VERSION_CODENAME=focal" ]]; then
sudo apt-get install -y pipx
pipx install poetry
else
sudo apt-get install -y python3-poetry
fi
snap watch $go_job
# Ensure we don't have dotnet installed, to properly test dotnet-deps
# Based on https://github.com/actions/runner-images/blob/main/images/linux/scripts/installers/dotnetcore-sdk.sh
sudo apt remove -y dotnet-* || true
echo "::endgroup::"
echo "::group::pip install"
python -m pip install tox
echo "::endgroup::"
echo "::group::dotnet removal"
# Remove manually-installed dotnet from tarballs
sudo rm -rf /usr/share/dotnet
# Remove dotnet tools
rm -rf $HOME/.dotnet
echo "::endgroup::"
echo "::group::Wait for snap to complete"
snap watch --last=install
echo "::endgroup::"
- name: specify node version
uses: actions/setup-node@v4
with:
node-version: 16
- name: Setup Tox environments
run: tox run -m unit-tests --notest
- name: Unit tests
run: .tox/.tox/bin/tox run --skip-pkg-install --no-list-dependencies --result-json results/tox-${{ matrix.platform }}.json -m unit-tests
env:
PYTEST_ADDOPTS: "--no-header -vv -rN"
tests:
strategy:
matrix:
os: [ubuntu-22.04]
python-version: ["3.10", "3.12"]
include:
- adjective: jammy
- os: ubuntu-20.04
python-version: "3.10"
adjective: focal
- os: ubuntu-24.04
python-version: "3.12"
adjective: noble
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install apt build dependencies
run: |
sudo apt update
sudo apt install -y libapt-pkg-dev intltool fuse-overlayfs python3-apt
- name: Install general python dependencies
run: |
pip install python-apt@https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-apt/2.0.1ubuntu0.20.04.1/python-apt_2.0.1ubuntu0.20.04.1.tar.xz
pip install -e .[dev]
- name: Install additional test dependencies
run: |
echo "::group::snap install"
sudo snap install --no-wait core20
sudo snap install chisel --channel latest/candidate --no-wait
sudo snap install go --classic --no-wait
echo "::endgroup::"
echo "::group::apt install"
sudo apt install -y ninja-build cmake scons qt5-qmake p7zip \
autoconf automake autopoint gcc git gperf help2man libtool texinfo \
curl findutils pkg-config rpm \
findutils python3-dev python3-venv
echo "::endgroup::"
echo "::group::dotnet removal"
# Ensure we don't have dotnet installed, to properly test dotnet-deps
# Based on https://github.com/actions/runner-images/blob/main/images/linux/scripts/installers/dotnetcore-sdk.sh
sudo apt remove -y dotnet-* || true
# Remove manually-installed dotnet from tarballs
sudo rm -rf /usr/share/dotnet
# Remove dotnet tools
rm -rf $HOME/.dotnet
echo "::endgroup::"
echo "::group::Wait for snap to complete"
snap watch --last=install
echo "::endgroup::"
echo "::group::Poetry"
# Install poetry. From pipx on focal, from apt on newer systems.
if [[ $(grep VERSION_CODENAME /etc/os-release ) == "VERSION_CODENAME=focal" ]]; then
sudo apt-get install -y pipx
pipx install poetry
else
sudo apt-get install -y python3-poetry
fi
echo "::endgroup::"
- name: specify node version
uses: actions/setup-node@v4
with:
node-version: 16
- name: Run integration tests
run: |
make test-integrations
- name: Run overlay smoke test
if: ${{ matrix.adjective == 'focal' }} # TODO: fix this smoke test for jammy
run: |
wget -q https://cloud-images.ubuntu.com/${{ matrix.adjective }}/current/${{ matrix.adjective }}-server-cloudimg-amd64.squashfs
mkdir base
sudo mount -t squashfs ${{ matrix.adjective }}-server-cloudimg-amd64.squashfs base/
cat <<-EOF > parts.yaml
parts:
foo:
plugin: nil
overlay-packages: [hello]
overlay-script: |
chroot "\$CRAFT_OVERLAY" /bin/bash -c "hello > hello.txt"
echo 1234 > "\$CRAFT_OVERLAY/etc/issue"
overlay:
- "*.txt"
- etc
- usr/bin
bar:
plugin: nil
after: [foo]
overlay-packages: [bison]
overlay-script: |
chroot "\$CRAFT_OVERLAY" /bin/bash -c "rm -Rf /etc/shells /etc/ssh && mkdir /etc/ssh"
echo 5678 > "\$CRAFT_OVERLAY/etc/issue"
overlay:
- -usr/share
- -var/cache
override-build: |
rev "\$CRAFT_OVERLAY/hello.txt" > "\$CRAFT_PART_INSTALL/olleh.txt"
EOF
python_exe=$(command -v python)
cat <<-EOF > run.sh
echo "--- overlay foo"
"${python_exe}" -mcraft_parts --work-dir=work --trace --overlay-base=base --refresh overlay foo
echo "--- next actions plan"
"${python_exe}" -mcraft_parts --work-dir=work --overlay-base=base --dry-run --show-skipped
echo "--- next actions execution"
"${python_exe}" -mcraft_parts --work-dir=work --trace --overlay-base=base
EOF
echo "--- parts.yaml:"
cat parts.yaml
sudo bash -xe run.sh
echo "* Check if hello executables installed"
test -x work/prime/usr/bin/hello && echo "hello"
test -x work/prime/usr/bin/bison && echo "bison"
test -x work/prime/usr/bin/m4 && echo "m4"
echo "* Check if /usr/bin/yacc is a symbolic link"
test -L work/prime/usr/bin/yacc && ls -l work/prime/usr/bin/yacc
echo "* Check if docs excluded"
test ! -d work/usr/share/doc/hello && echo "hello"
test ! -d work/usr/share/doc/bison && echo "bison"
echo "* Check created files"
grep "!dlrow ,olleH" work/prime/olleh.txt
grep "Hello, world!" work/prime/hello.txt
grep 5678 work/prime/etc/issue
echo "* Check whiteout files"
test -f work/prime/etc/.wh.shells && echo "/etc/shells"
test -f work/prime/etc/ssh/.wh..wh.opq && echo "/etc/ssh"
echo "--- prime files:"
find work/prime