Skip to content

Commit 8368db8

Browse files
authored
Merge branch 'master' into fix/container
2 parents 5b5e7f4 + 60ffd07 commit 8368db8

File tree

235 files changed

+2950
-1131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+2950
-1131
lines changed

Diff for: .circleci/config.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,28 @@ jobs:
1111

1212
style:
1313
docker:
14-
- image: registry.opensuse.org/opensuse/leap:15.3
14+
- image: registry.opensuse.org/opensuse/tumbleweed
1515
steps:
1616
- checkout
1717
- run:
1818
command: |
19-
zypper -n ar https://download.opensuse.org/repositories/devel:/languages:/python:/backports/openSUSE_Leap_15.3 py
20-
zypper --gpg-auto-import-keys ref py
2119
zypper -n in --no-recommends make python3-black python3-importlib-metadata
2220
- checkout
2321
- run: make test_python_style
2422

2523

2624
integration:
2725
machine:
28-
image: ubuntu-1604:201903-01
26+
image: ubuntu-2004:202201-02
2927
steps:
3028
- checkout
31-
- run:
29+
- run:
3230
command: |
3331
pyenv versions
34-
pyenv global 3.7.0
35-
git clone https://github.com/coryb/osht ../osht
32+
pyenv global 3.10.2
3633
docker pull registry.opensuse.org/devel/openqa/ci/containers/serviced
3734
sudo chown -R 1000:1000 .
38-
make test_docker PRIVILEGED_TESTS=1 OSHT_LOCATION=$(pwd)/../osht/osht.sh
35+
make test_docker PRIVILEGED_TESTS=1
3936
4037
workflows:
4138
version: 2.1

Diff for: README.md

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# openqa-trigger-from-obs
2+
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/os-autoinst/openqa-trigger-from-obs/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/os-autoinst/openqa-trigger-from-obs/tree/master)
23

34
This project is aiming to simplify the integration between the Open
45
Build Service (OBS) and openqa.opensuse.org (o3).
@@ -41,10 +42,10 @@ to one of those projects.
4142
## Changes needed for existing projects
4243

4344
Typical steps:
44-
1. Investigate the corresponding part in scriptgen.py and change according to
45+
1. Investigate the corresponding part in *scriptgen.py* and change according to
4546
new requirements.
4647
2. Re-generate scripts in test folders with `make test_regen_all`
47-
3. Update .before scripts in test folders with `make test_update_before_files`
48+
3. Update *.before* scripts in test folders with `make test_update_before_files`
4849
4. Run consistency tests with `make test`
4950
5. Review and acknowledge impact on projects e.g. `git difftool`
5051
The commands will highlight all affected projects and exact changes and side
@@ -60,26 +61,28 @@ commit affects them in the future.
6061

6162
1. Find a project with similar settings, create a copy of its xml file and
6263
tweak changes as needed.
63-
2. Create folder t/obs/ProjectName and generate scripts using
64+
2. Create folder *t/obs/ProjectName* and generate scripts using
6465
`make test_regen_all`
6566
3. Examine the script for the first phase (read `Testability` section above)
66-
t/obs/ProjectName/read_files.sh
67+
*t/obs/ProjectName/read_files.sh*
6768
4. Use generated commands `rsync --list-only` to create files
68-
t/obs/ProjectName/*.lst
69-
the same way they are created in read_files.sh
69+
*t/obs/ProjectName/\*.lst*
70+
the same way they are created in *read_files.sh*
7071
5. Generate rsync and openqa commands based on these new *.lst files
71-
`make test_update_before_files`
72+
`make test_update_before_files`
7273
6. Run consistency test `make test`
7374
7. Review and test bash commands generated in, which will be executed in
7475
production:
75-
t/obs/ProjectName/print_rsync_iso.before
76-
t/obs/ProjectName/print_rsync_repo.before
77-
t/obs/ProjectName/print_openqa.before
78-
8. Add to a new git commit the xml file and t/obs/ProjectName folder
76+
* t/obs/ProjectName/print_rsync_iso.before
77+
* t/obs/ProjectName/print_rsync_repo.before
78+
* t/obs/ProjectName/print_openqa.before
79+
8. Add to a new git commit the xml file and *t/obs/ProjectName* folder
80+
```
7981
git checkout -b add_projectname
8082
git add xml/obs/ProjectName.xml t/obs/ProjectName
8183
git commit -m 'Add ProjectName'
8284
git push origin add_projectname
85+
```
8386
9. Create a pull request from add_projectname branch and make sure CI shows
8487
green outcome
8588

@@ -102,6 +105,11 @@ python3 script/scriptgen.py Leap:15.2:ToTest
102105
bash script/rsync.sh Leap:15.2:ToTest
103106
```
104107

108+
## Further information
109+
110+
Find some presentation slides on
111+
https://slides.com/andriinikitin/obs-to-openqa
112+
105113
## License
106114

107115
This project is licensed under the MIT license, see LICENSE file for details.

Diff for: profiles/apparmor.d/opt.openqa-trigger-from-obs.script.rsync.sh

+16-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
/opt/openqa-trigger-from-obs/*:*/*/.run*/* rw,
1616
/opt/openqa-trigger-from-obs/*:*/*/.run_last rw,
1717
/opt/openqa-trigger-from-obs/*:*/*/files*.lst rw,
18+
/opt/openqa-trigger-from-obs/*:*/*/Media*.lst rw,
19+
/opt/openqa-trigger-from-obs/*:*/*/.Media*.lst* rw,
20+
/opt/openqa-trigger-from-obs/*:*/*/products* rw,
21+
/opt/openqa-trigger-from-obs/*:*/*/.products* rw,
22+
1823
/opt/openqa-trigger-from-obs/*:*/.run*/ rw,
1924
/opt/openqa-trigger-from-obs/*:*/.run*/* rw,
2025
/opt/openqa-trigger-from-obs/*:*/.run_last rw,
@@ -47,14 +52,15 @@
4752
/usr/bin/uniq ix,
4853
/usr/bin/wc ix,
4954
/var/lib/openqa/osc-plugin-factory/factory-package-news/factory-package-news.py rUx,
50-
/usr/share/openqa/script/client rPx -> /opt/openqa-trigger-from-obs/script/rsync.sh//openqa_client,
51-
/var/lib/openqa/share/factory/repo/** rw, # need write permission because sometimes bsdtar iso here
55+
/usr/share/openqa/script/openqa-cli rPx -> /opt/openqa-trigger-from-obs/script/rsync.sh//openqa_cli,
56+
/usr/bin/openqa-cli rPx -> /opt/openqa-trigger-from-obs/script/rsync.sh//openqa_cli,
57+
/var/lib/openqa/share/factory/repo/** rwl, # need write and link permissions, because bsdtar may extract iso here
5258
/var/lib/openqa/share/factory/{iso,hdd,other}/** r,
5359
/{usr/bin,bin}/bash mrix,
5460
owner /proc/*/fd/* w,
5561

5662

57-
profile openqa_client {
63+
profile openqa_cli {
5864
#include <abstractions/base>
5965
#include <abstractions/nameservice>
6066
#include <abstractions/openssl>
@@ -68,8 +74,9 @@
6874
/etc/openqa/client.conf r,
6975
/opt/openqa-trigger-from-obs/*:*/*/.run*/openqa*.log w,
7076
/opt/openqa-trigger-from-obs/*:*/.run*/openqa*.log w,
77+
/usr/bin/openqa-cli rix,
7178
/usr/share/openqa/lib/** r,
72-
/usr/share/openqa/script/client rix,
79+
/usr/share/openqa/script/openqa-cli rix,
7380
/var/lib/openqa/.config/openqa/client.conf r,
7481
/var/lib/openqa/share/factory/{iso,hdd,repo,other}/** r,
7582

@@ -96,6 +103,11 @@
96103
/opt/openqa-trigger-from-obs/*:*/products* rw,
97104
/opt/openqa-trigger-from-obs/*:*/.products* rw,
98105

106+
/opt/openqa-trigger-from-obs/*:*/*/Media*.lst rw,
107+
/opt/openqa-trigger-from-obs/*:*/*/.Media*.lst* rw,
108+
/opt/openqa-trigger-from-obs/*:*/*/products* rw,
109+
/opt/openqa-trigger-from-obs/*:*/*/.products* rw,
110+
99111
/usr/bin/rsync mrix,
100112
/var/lib/openqa/share/factory/{iso,hdd,repo,other}/** rw,
101113

Diff for: script/cfg.py

+42-17
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@
3535
read_files_repo_link3 = '''cp __envdir/REPOLINK/files_iso*.lst __envsub/
3636
'''
3737

38-
def rsync_fix_dest(distri, version, staging):
38+
def rsync_fix_dest(distri, version, staging, use_staging_patterns):
3939
if not staging: return ''
40+
if use_staging_patterns: return '''
41+
staging_pattern=$flavor
42+
[ -z "${flavor_staging[$staging_pattern]}" ] || staging_pattern="${flavor_staging[$staging_pattern]}"
43+
dest=${dest//$staging_pattern/Staging:__STAGING-$staging_pattern}'''
4044
if version != 'Factory' and len(staging) == 1: return '''dest=${dest//$flavor/Staging:__STAGING-Staging-$flavor}'''
4145
return '''dest=${dest//$flavor/Staging:__STAGING-$flavor}'''
4246

@@ -52,19 +56,19 @@ def rsync_commands(checksum):
5256
echo "rsync --timeout=3600 -tlp4 --specials PRODUCTISOPATH/${iso_folder[$flavor]}*$src.sha256 /var/lib/openqa/factory/other/$dest.sha256"'''
5357
return res
5458

55-
rsync_iso = lambda distri, version, archs, staging, checksum, repo0folder: '''
59+
rsync_iso = lambda distri, version, archs, staging, checksum, repo0folder, use_staging_patterns: '''
5660
archs=(ARCHITECTURS)
5761
5862
for flavor in {FLAVORLIST,}; do
5963
for arch in "${archs[@]}"; do
6064
filter=$flavor
61-
[[ ! -v flavor_filter[@] ]] || [ -z "${flavor_filter[$flavor]}" ] || filter=${flavor_filter[$flavor]}
65+
[ -z "${flavor_filter[$flavor]}" ] || filter=${flavor_filter[$flavor]}
6266
[[ ${norsync_filter[$filter]} != 1 ]] || continue
6367
src=$(grep "$filter" __envsub/files_iso.lst | grep $arch | head -n 1)
6468
''' + rsync_iso_fix_src(archs) + '''
6569
[ ! -z "$src" ] || continue
6670
dest=$src
67-
''' + rsync_fix_dest(distri, version, staging) + '''
71+
''' + rsync_fix_dest(distri, version, staging, use_staging_patterns) + '''
6872
asset_folder=other
6973
[[ ! $dest =~ \.iso$ ]] || asset_folder=iso
7074
[[ ! $dest =~ \.(qcow2|raw|vhd|vhdx|xz)$ ]] || asset_folder=hdd
@@ -108,7 +112,7 @@ def pre_rsync_repo(repos):
108112
[ ! -f __envsub/files_iso.lst ] || test -n "$buildid" || buildid=$(cat __envsub/files_iso.lst | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
109113
[ -z "__STAGING" ] || buildid=${buildid//Build/Build__STAGING.}
110114
[ ! -f __envsub/files_repo.lst ] || ! grep -q -- "-POOL-" __envsub/files_repo.lst || additional_repo_suffix=-POOL
111-
[ -n "$buildid" ] || buildid=$(grep -hEo 'Build[0-9]+' __envsub/Media1_*.lst 2>/dev/null | head -n 1)
115+
[ -n "$buildid" ] || buildid=$(grep -hEo 'Build[0-9]+(.[0-9]+)?' __envsub/Media1_*.lst 2>/dev/null | head -n 1)
112116
113117
for repo in {REPOOWNLIST,}; do
114118
while read src; do
@@ -132,24 +136,33 @@ def pre_rsync_repo(repos):
132136

133137
rsync_repodir1 = '''
134138
archs=(ARCHITECTURREPO)
135-
[ ! -f __envsub/files_iso.lst ] || buildid=$(cat __envsub/files_iso.lst | grep -E 'FLAVORORS' | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
136-
[ -n "$buildid" ] || buildid=$(grep -hEo 'Build[0-9]+' __envsub/Media1_*.lst 2>/dev/null | head -n 1)
139+
137140
138141
for arch in "${archs[@]}"; do
142+
[ ! -f __envsub/files_iso.lst ] || buildid=$(cat __envsub/files_iso.lst | grep $arch | grep -E 'FLAVORORS' | grep -o -E '(Build|Snapshot)[^-]*' | head -n 1)
143+
[ -n "$buildid" ] || buildid=$(grep -hEo 'Build[0-9]+(.[0-9]+)?' __envsub/Media1_*.lst 2>/dev/null | head -n 1)
144+
if [[ ! -n $build ]] && [[ ! $buildid =~ (Build|Snapshot)[0-9]*[0-9]$ ]]; then
145+
buildid=${buildid%%\.[[:alpha:]]*}
146+
fi
147+
139148
while read src; do
140149
[ ! -z "$src" ] || continue
141150
dest=$src
151+
dest=${dest%-Build*}
142152
destPrefix=${dest%$arch*}
143153
destSuffix=${dest#$destPrefix}
144154
mid=''
145-
dest=$destPrefix$mid$destSuffix'''
155+
dest=$destPrefix$mid$destSuffix
156+
[[ ! $src =~ .*\.license ]] || [[ $dest == *license* ]] || dest=$dest.license'''
146157

147158
def rsync_repodir2():
148159
return '''
149160
dest=${dest//-Media2/}
150-
echo rsync --timeout=3600 -rtlp4 --delete --specials RSYNCFILTER PRODUCTREPOPATH/*Media2/* /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/
161+
Mdia=Media2
162+
[[ ! $src =~ .*\.license ]] || Mdia=Media2.license
163+
echo rsync --timeout=3600 -rtlp4 --delete --specials RSYNCFILTER PRODUCTREPOPATH/*$Mdia/ /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/
151164
echo rsync --timeout=3600 -rtlp4 --delete --specials --link-dest /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/ /var/lib/openqa/factory/repo/$dest-CURRENT-debuginfo/ /var/lib/openqa/factory/repo/$dest-$buildid-debuginfo
152-
done < <(grep ${arch//i686/i586} __envsub/files_repo.lst | grep Media2)
165+
done < <(grep ${arch//i686/i586} __envsub/files_repo.lst | grep Media2 )
153166
done
154167
'''
155168

@@ -161,7 +174,9 @@ def rsync_repodir2():
161174
while read src; do
162175
[ ! -z "$src" ] || continue
163176
[[ ''' + dest + ''' =~ $arch ]] || [[ ''' + dest + ''' =~ ${arch//i686/i586} ]] || [[ "ARCHITECTURREPO" == . ]] || break
164-
dest=''' + dest
177+
dest=''' + dest + '''
178+
[[ ! $src =~ .*\.license ]] || dest=$dest.license'''
179+
165180

166181

167182
def openqa_call_fix_destiso(distri, version, staging):
@@ -211,8 +226,10 @@ def pre_openqa_call_start(repos):
211226
for arch in "${archs[@]}"; do
212227
filter=$flavor
213228
''' + openqa_call_start_distri(flavor_distri) + '''
214-
[[ ! -v flavor_filter[@] ]] || [ -z "${flavor_filter[$flavor]}" ] || filter=${flavor_filter[$flavor]}
229+
[ -z "${flavor_filter[$flavor]}" ] || filter=${flavor_filter[$flavor]}
215230
[ $filter != Appliance ] || filter="qcow2"
231+
version=VERSIONVALUE
232+
if [ -z "${norsync_filter[$flavor]}" ] || [ -z $build1 ]; then {
216233
iso=$(grep "$filter" __envsub/files_iso.lst 2>/dev/null | grep $arch | head -n 1)
217234
''' + openqa_call_start_fix_iso(archs) + '''
218235
build=$(echo $iso | grep -o -E '(Build|Snapshot)[^-]*' | grep -o -E '[0-9]\.?[0-9]+(\.[0-9]+)*' | tail -n 1) || :
@@ -226,14 +243,15 @@ def pre_openqa_call_start(repos):
226243
buildex=${buildex/.qcow2/}
227244
build1=$build
228245
destiso=$iso
229-
version=VERSIONVALUE
230246
[ -z "__STAGING" ] || build1=__STAGING.$build
231247
''' + openqa_call_fix_destiso(distri, version, staging) + '''
232248
repo0folder=${destiso%.iso}
233249
''' + (repo0folder if repo0folder else "") + '''
234250
[ "$arch" != . ] || arch=x86_64
235251
''' + openqa_call_news(news, news_archs) + '''
236-
echo "/usr/share/openqa/script/client isos post --host localhost \\\\\"
252+
}
253+
fi
254+
echo "/usr/bin/openqa-cli api -X post isos?async=1 \\\\\"
237255
(
238256
echo \" DISTRI=$distri \\\\
239257
ARCH=$arch \\\\
@@ -266,7 +284,7 @@ def openqa_call_start_ex(checksum):
266284
:
267285
elif [[ $destiso =~ \.iso$ ]]; then
268286
echo \" ''' + openqa_call_start_ex1(checksum, 'ISO') + '''\"
269-
elif [[ $destiso =~ \.(hdd|qcow2|raw\.xz|raw\.gz|vhdx\.xz|vmdk\.xz)$ ]]; then
287+
elif [[ $destiso =~ \.(hdd|qcow2|raw|raw\.xz|raw\.gz|vhdx\.xz|vmdk\.xz)$ ]]; then
270288
echo \" ''' + openqa_call_start_ex1(checksum, 'HDD_1') + '''\"
271289
elif [ -n "$destiso" ]; then
272290
echo \" ''' + openqa_call_start_ex1(checksum, 'ASSET_1') + '''\"
@@ -372,13 +390,18 @@ def openqa_call_repot1_debugsource():
372390
openqa_call_repot1 = lambda: '''
373391
while read src; do
374392
dest=$src
393+
dest=${dest%-Build*}
394+
dest=${dest%.license}
375395
destPrefix=${dest%$arch*}
376396
destSuffix=${dest#$destPrefix}
377397
mid=''
378398
dest=$destPrefix$mid$destSuffix
379399
repoPrefix=${dest%-Media*}
380400
repoSuffix=${dest#$repoPrefix}
381-
dest=$repoPrefix-Build$build$repoSuffix
401+
[[ ! $src =~ .license ]] || repoPrefix=$repoPrefix.license
402+
B=$(grep -oE "Build|Snapshot" __envsub/files_iso.lst 2>/dev/null | head -1)
403+
[ ! -z "$B" ] || B=Build
404+
dest=$repoPrefix-$B$build$repoSuffix
382405
repoKey=REPOKEY
383406
repoKey=${repoKey^^}
384407
repoKey=${repoKey//-/_}
@@ -400,7 +423,9 @@ def openqa_call_repot1_debugsource():
400423
openqa_call_repot1_dest = lambda dest: '''
401424
while read src; do
402425
[[ ''' + dest + ''' =~ $arch ]] || [[ ''' + dest + ''' =~ ${arch//i686/i586} ]] || [[ "ARCHITECTURREPO" == . ]] || break
403-
dest=''' + dest + '''-$buildex
426+
dest=''' + dest + '''
427+
[[ ! $src =~ .*\.license ]] || dest=$dest.license
428+
dest=$dest-$buildex
404429
repoKey=REPOKEY
405430
''' + openqa_call_repot1_debugsource() + '''
406431
repoKey=${repoKey^^}

Diff for: script/rsync.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set +e
3636
[ -e "$subfolder/print_openqa.sh" ] || { >&2 echo "No file found: {$subfolder/print_openqa.sh}"; exit 1; }
3737

3838
# nowhere to log yet as we haven't created $logfolder
39-
bash -e "$subfolder/read_files.sh"
39+
bash -e "$subfolder/read_files.sh" || { >&2 echo "read_files.sh failed for $subfolder in enviroment $environ"; exit 1; }
4040

4141
if [ -e $subfolder/.run_last ] && [ -z "$(diff --brief $subfolder $subfolder/.run_last | grep '.lst')" ]; then
4242
>&2 echo "No changes found since last run, skipping {$subfolder}"
@@ -47,12 +47,13 @@ set +e
4747
if [[ "$environ" != *Factory* ]] && [[ "$environ" != *MicroOS* ]]; then
4848
builds="$(grep -h -o -E 'Build[0-9](\.|[0-9]+)*[0-9]+' $subfolder/*.lst 2>/dev/null)" || :
4949
else
50-
builds="$(grep -h -o -E '20[0-9]{6}' $subfolder/*.lst 2>/dev/null)" || :
50+
# for *Factory* we include base branch for checking Snapshot consistency
51+
builds="$(grep -h -o -E '20[0-9]{6}' $environ/base/*.lst 2>/dev/null || : ; grep -h -o -E '20[0-9]{6}' $subfolder/*.lst 2>/dev/null)" || :
5152
fi
5253

5354
if [ -n "$builds" ] && [ $(echo "$builds" | sort | uniq | wc -l) -gt 1 ]; then
54-
>&2 echo "Conflicting builds found {$builds}, skipping {$subfolder}"
55-
continue
55+
>&2 echo "Conflicting builds found {$builds}, exiting because of conflict in {$subfolder}"
56+
exit 0
5657
fi
5758
fi
5859

0 commit comments

Comments
 (0)