-
Notifications
You must be signed in to change notification settings - Fork 3
294 lines (273 loc) · 8.66 KB
/
ci.yml
File metadata and controls
294 lines (273 loc) · 8.66 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
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: CI
on:
push:
#branches: [master]
pull_request:
#branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tox:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.x"]
upstream: ["pypi"]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Detect skipped environments
id: skipenv
env:
UPSTREAM: ${{ matrix.upstream }}
run: |
set -ex
case $UPSTREAM in
upstream)
echo 'skipenv=.*(?<!upstream)$' >> $GITHUB_OUTPUT
;;
*)
echo 'skipenv=.*-upstream$' >> $GITHUB_OUTPUT
;;
esac
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
# Install dependencies for python-ldap
sudo apt-get install -y libsasl2-dev python3-dev libldap2-dev libssl-dev libssh-dev
python -m pip install --upgrade pip
pip install tox tox-gh
- name: Prepare tox environment and install packages
run: |
tox --skip-env '${{ steps.skipenv.outputs.skipenv }}' --colored=yes --notest
- name: Run tests
run: |
tox --skip-env '${{ steps.skipenv.outputs.skipenv }}' --colored=yes --skip-pkg-install
system:
strategy:
fail-fast: false
matrix:
tag:
- fedora-latest
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Checkout sssd-test-framework repository
uses: actions/checkout@v5
with:
# Fetch the entire history of the repository and tags to determine
# correct framework version, as it is constructed from git describe
repository: sssd/sssd-test-framework
fetch-depth: 0
fetch-tags: true
path: sssd-test-framework
- name: Checkout sudo-tests repository
uses: actions/checkout@v5
with:
repository: RedHat-SP-Security/sudo-tests
path: sudo-tests
- name: Setup containers
uses: SSSD/sssd-ci-containers/actions/setup@master
with:
path: sssd-ci-containers
registry: quay.io/sssd
tag: ${{ matrix.tag }}
override: |
services:
dns:
restart: always
image: ${REGISTRY}/ci-dns:latest
container_name: dns
env_file: ./env.containers
volumes:
- ./data/configs/dnsmasq.conf:/etc/dnsmasq.conf
cap_add:
- NET_RAW
- NET_ADMIN
- SYS_CHROOT
security_opt:
- apparmor=unconfined
- label=disable
- seccomp=unconfined
networks:
sssd:
ipv4_address: 172.16.100.2
ipa:
image: ${REGISTRY}/ci-ipa:${TAG}
container_name: ipa
hostname: master.ipa.test
dns: 172.16.100.2
env_file: ./env.containers
volumes:
- ./shared:/shared:rw
cap_add:
- SYS_ADMIN
- SYS_PTRACE
- AUDIT_WRITE
- AUDIT_CONTROL
- SYS_CHROOT
- NET_ADMIN
- CAP_CHOWN
- CAP_DAC_OVERRIDE
- CAP_SETGID
- CAP_SETUID
- CAP_DAC_READ_SEARCH
security_opt:
- apparmor=unconfined
- label=disable
- seccomp=unconfined
networks:
sssd:
ipv4_address: 172.16.100.10
ldap:
image: ${REGISTRY}/ci-ldap:${TAG}
container_name: ldap
hostname: master.ldap.test
dns: 172.16.100.2
env_file: ./env.containers
volumes:
- ./shared:/shared:rw
cap_add:
- SYS_ADMIN
- SYS_PTRACE
- AUDIT_WRITE
- AUDIT_CONTROL
- SYS_CHROOT
- NET_ADMIN
security_opt:
- apparmor=unconfined
- label=disable
- seccomp=unconfined
networks:
sssd:
ipv4_address: 172.16.100.20
client:
image: ${REGISTRY}/ci-client:${TAG}
container_name: client
hostname: client.test
dns: 172.16.100.2
env_file: ./env.containers
volumes:
- ./shared:/shared:rw
cap_add:
- SYS_ADMIN
- SYS_PTRACE
- NET_RAW
- NET_ADMIN
- AUDIT_WRITE
- AUDIT_CONTROL
- SYS_CHROOT
- CAP_CHOWN
- CAP_DAC_OVERRIDE
- CAP_SETGID
- CAP_SETUID
- CAP_DAC_READ_SEARCH
security_opt:
- apparmor=unconfined
- label=disable
- seccomp=unconfined
networks:
sssd:
ipv4_address: 172.16.100.40
networks:
sssd:
name: sssd-ci
driver: bridge
ipam:
config:
- subnet: 172.16.100.0/24
gateway: 172.16.100.1
options:
driver: host-local
- name: Patch the SSH configuration
uses: SSSD/sssd-ci-containers/actions/exec@master
with:
user: root
script: |
#!/bin/bash
test -x /usr/bin/sss_ssh_knownhosts && \
sed -e 's/GlobalKnownHostsFile/#GlobalKnownHostsFile/' \
-e 's/ProxyCommand \/usr\/bin\/sss_ssh_knownhostsproxy -p %p %h/KnownHostsCommand \/usr\/bin\/sss_ssh_knownhosts %H/' \
-i /etc/ssh/ssh_config.d/04-ipa.conf
- name: Install system tests dependencies
shell: bash
working-directory: ./sudo-tests/pytest
run: |
set -ex
sudo apt-get update
# Install dependencies for python-ldap
sudo apt-get install -y libsasl2-dev python3-dev libldap2-dev libssl-dev libssh-dev
# Virtualenv
pip3 install virtualenv
python3 -m venv .venv
source .venv/bin/activate
# Install system tests requirements
pip3 install -r ./requirements.txt
# Install yq to parse yaml files
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod a+x /usr/local/bin/yq
- name: Install test framework
shell: bash
run: |
set -ex
source ./sudo-tests/pytest/.venv/bin/activate
pip3 install ./sssd-test-framework
- name: Remove ad from mhc.yaml
shell: bash
working-directory: ./sudo-tests/pytest
run: |
yq -i 'del(.domains[0].hosts.[] | select(.role == "ad"))' mhc.yaml
- name: Check polarion metadata
shell: bash
working-directory: ./sudo-tests/pytest
run: |
# Run pytest in collect only mode to quickly catch issues in Polarion metadata.
set -ex -o pipefail
mkdir -p $GITHUB_WORKSPACE/artifacts
source .venv/bin/activate
pytest \
--color=yes \
--mh-config=./mhc.yaml \
--mh-artifacts-dir=$GITHUB_WORKSPACE/artifacts \
--polarion-config=../polarion.yaml \
--output-polarion-testcase=$GITHUB_WORKSPACE/artifacts/testcase.xml \
--collect-only . |& tee $GITHUB_WORKSPACE/pytest-collect.log
- name: Run tests
shell: bash
working-directory: ./sudo-tests/pytest/
run: |
set -ex -o pipefail
mkdir -p $GITHUB_WORKSPACE/artifacts
source .venv/bin/activate
pytest \
--durations=0 \
--color=yes \
--show-capture=no \
--mh-config=./mhc.yaml \
--mh-artifacts-dir=$GITHUB_WORKSPACE/artifacts \
--polarion-config=../polarion.yaml \
--output-polarion-testcase=$GITHUB_WORKSPACE/artifacts/testcase.xml \
--output-polarion-testrun=$GITHUB_WORKSPACE/artifacts/testrun.xml \
-vvv . |& tee $GITHUB_WORKSPACE/pytest.log
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: ${{ matrix.tag }}-system
path: |
artifacts
build.log
install.log
pytest.log
pytest-collect.log