forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-spread
More file actions
executable file
·140 lines (125 loc) · 3.9 KB
/
run-spread
File metadata and controls
executable file
·140 lines (125 loc) · 3.9 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
#!/bin/bash
set -eu
help() {
echo "Usage: $0 [OPTION] [--] [ARGS]"
echo
echo "Options:"
echo " -m, --mode MODE - Use selected mode:"
echo " sru-validation - Ubuntu SRU validation"
echo " native-package - Use native package"
echo " -n, --no-rebuild - Do not rebuild snapd snap (equivalent to NO_REBUILD=1)"
echo " -d, --download - Download latest snapd snap built on master (equivalent to DOWNLOAD_SNAPD_SNAP=1)"
echo " -- - Delimiter for arguments parsed by this script"
echo " ARGS - Arguments passed to spread"
echo
}
mode=""
no_rebuild=0
download=0
while true; do
case "${1-}" in
--help|-h)
help
exit 0
;;
--mode|-m)
shift
maybe_mode="$1"
shift
if [ "$mode" != "" ]; then
echo "already using mode $mode"
exit 1
fi
case "$maybe_mode" in
sru-validation)
mode="sru-validation"
;;
native-package)
mode="native-package"
;;
*)
echo "unsupported mode: $maybe_mode"
exit 1
;;
esac
;;
--no-rebuild|-n)
no_rebuild=1
shift
;;
--download|-d)
download=1
shift
;;
--)
shift
break
;;
*)
break
;;
esac
done
set -x
shopt -s nullglob
if [ "$download" = "1" ] || [ "${DOWNLOAD_SNAPD_SNAP:-0}" = "1" ]; then
run="$(gh run list --repo github.com/canonical/snapd -w ci-master-push.yaml --json databaseId,conclusion --jq 'first(.[] | select(.conclusion == "success") | .databaseId)')"
filename="snap-files-amd64-default-test"
if uname -m | grep -Eq '(aarch64.*|armv8.*)'; then
filename="snap-files-arm64-default-test"
fi
rm -rf built-snap
mkdir -p built-snap
gh run download "$run" -n "$filename" --dir built-snap
find built-snap/ -type f -name "*.snap" -exec mv {} {}.keep \;
elif [ "${NO_REBUILD:-0}" = "1" ] || [ "$no_rebuild" = "1" ]; then
echo "-- $(date) -- requested no snap rebuild"
# check if we have any snaps built at all
built_snaps=(built-snap/snapd_*.snap.keep)
if (( "${#built_snaps[@]}" > 0 )); then
echo "-- $(date) -- found prebuilt snapd snaps:"
for s in "${built_snaps[@]}"; do
echo "-- $s"
done
else
echo "-- $(date) -- no prebuilt snaps found"
echo "either drop the no-rebuild option (--no-rebuild or NO_REBUILD=1) to build snapd snap or set the download option (--download or DOWNLOAD_SNAPD_SNAP=1) to use the snapd snap built on master"
exit 1
fi
else
echo "-- $(date) -- rebuilding snapd snap"
./tests/build-test-snapd-snap
echo "-- $(date) -- snapd snap rebuild complete"
fi
if [ -t 1 ]; then
export SPREAD_DEBUG_EACH=0
fi
case "$mode" in
sru-validation)
echo "-- SRU validation mode"
export SPREAD_SNAP_REEXEC=0
export SPREAD_SRU_VALIDATION=1
;;
native-package)
echo "-- native package mode"
export SPREAD_SNAP_REEXEC=0
export SPREAD_SNAPD_DEB_FROM_REPO=false
;;
esac
export SPREAD_USE_PREBUILT_SNAPD_SNAP=true
# check that we are passing a test suite (in the form of
# <backend>:<system>:<test>) to spread, otherwise this would turn into a very
# annoyng spread invocation
maybe_has_ts=0
for arg in "$@"; do
if [ "${arg/://}" != "$arg" ]; then
maybe_has_ts=1
break
fi
done
if [ "$maybe_has_ts" = "0" ]; then
echo "error: attempting to run spread without any arguments, this would launch all test suites"
exit 1
fi
# Run spread
exec spread "$@"