1 (* This goal script is responsible for:
2 * - testing each new commit to the libguestfs source repo
3 * - checking for new upstream releases of libguestfs
4 * - testing new upstream releases
5 * - packaging them as a source tarball
6 * - testing the source tarball on a variety of systems
7 * - if all the above works, uploading the external website
8 * Note this doesn't build the Fedora releases. See 'libguestfs_fedora.ml'.
16 (* Enable debugging. *)
18 Unix.putenv "LIBGUESTFS_DEBUG" "1";
19 Unix.putenv "LIBGUESTFS_TRACE" "1"
21 (* Log program output. *)
22 let from = "rjones@redhat.com"
23 let to_ = "rjones@redhat.com"
25 let logfile = log_program_output ()
26 let () = eprintf "logging to %s\n%!" logfile
29 let package = "libguestfs"
31 (* Goal: the website has been updated to 'version'. *)
32 let rec goal website_updated version =
33 target (url_exists version.url &&
34 (if version.is_stable then
35 url_exists version.python_url
39 require (tarball_created version);
40 require (tarball_tested version);
41 if version.is_stable then
42 require (tarball_signed version);
44 (* Python sdists only generated for stable releases. *)
45 if version.is_stable then (
46 require (python_tarball_created version);
47 require (python_tarball_tested version)
50 (* We only update the website for the development releases. *)
51 if not version.is_stable then
52 require (website_built version);
54 require (website_checked_in version);
55 if version.is_stable then
56 require (python_website_checked_in version);
57 require (website_rsync_done version)
59 (* Goal: website has been rsync'd. *)
60 and website_rsync_done version =
61 target (url_contains_string "http://libguestfs.org" version.version &&
62 url_exists version.url);
69 (* Goal: Tarball added to repository and checked in. *)
70 and website_checked_in version =
71 let key = sprintf "libguestfs_website_checked_in_%s" version.version in
72 target (memory_exists key);
73 onrun (fun () -> memory_set key "1");
75 require (tarball_created version);
76 require (tarball_tested version);
77 if version.is_stable then
78 require (tarball_signed version);
83 if %b; then cp %s/tarballs/%s.sig %s.sig; fi
88 git commit -m \"Version %s\"
89 " libguestfs_download_repo
90 buildtmp version.tarball version.urlpath
91 version.is_stable buildtmp version.tarball version.urlpath
93 libguestfs_website_repo
97 (* Goal: website (local copy) has been built. *)
98 and website_built version =
99 let index_file = sprintf "%s/index.html" libguestfs_website_repo in
100 target (file_contains_string index_file version.version);
102 require (tarball_created version);
103 require (tarball_tested version);
105 (* We should only update the website on development releases. *)
106 assert (not version.is_stable);
109 tar zxf %s/tarballs/%s
112 echo %s > localconfigure
113 chmod +x localconfigure
118 make maintainer-upload-website WEBSITESDIR=%s
119 " buildtmp version.tarball
120 version.package_version
121 (quote (libguestfs_localconfigure `Tarball))
122 (quote (libguestfs_localenv (supermin version)))
123 (quote websites_repo)
125 (* Goal: for stable versions, the tarball must be signed. *)
126 and tarball_signed version =
127 let tar_file = sprintf "%s/tarballs/%s" buildtmp version.tarball in
128 let sig_file = tar_file ^ ".sig" in
129 target (file_exists sig_file);
131 require (tarball_created version);
133 sh "sign-tarball %s" tar_file
135 (* Goal: the tarball has passed the required set of tests before
136 * a release is allowed.
138 and tarball_tested version =
139 let key = sprintf "libguestfs_tarball_tested_%s" version.version in
140 target (memory_exists key);
141 onrun (fun () -> memory_set key "1");
143 require (tarball_created version);
146 tar zxf %s/tarballs/%s
149 echo %s > localconfigure
150 chmod +x localconfigure
155 if ! make check-release; then
156 for f in `find -name test-suite.log | xargs grep -l ^FAIL:`; do
162 " buildtmp version.tarball
163 version.package_version
164 (quote (libguestfs_localconfigure `Tarball))
165 (quote (libguestfs_localenv (supermin version)))
167 (* Goal: the tarball has been created from git. *)
168 and tarball_created version =
169 let filename = sprintf "%s/tarballs/%s" buildtmp version.tarball in
170 target (file_exists filename);
172 require (repo_up_to_date version.branch);
174 let repodir = sprintf "%s/repos/%s-%s" buildtmp package version.branch in
176 (* Branches <= 1.32 are tagged with "1.32.11",
177 * branches >= 1.33 are tagged with "v1.33.11".
180 if version.minor >= 33 then "v" ^ version.version
181 else version.version in
188 echo %s > localconfigure
189 chmod +x localconfigure
194 # Ensure the po-docs are updated. Grrr this is ugly ...
197 make -C po-docs update-po
202 # Ensure redhat hardening flags didn't leak into the tarball.
203 # https://bugzilla.redhat.com/show_bug.cgi?id=1214506
204 if zcat %s | grep -q redhat-hardened; then exit 1; fi
209 (quote (libguestfs_localconfigure `Git))
210 (quote (libguestfs_localenv (supermin version)))
212 version.tarball buildtmp version.tarball
214 (* Goal: test a commit. *)
215 and commit_tested branch commit =
218 let subject = sprintf "goal: %s: FAILED" goalname in
219 mailto ~from ~subject (*~attach:[logfile]*) to_
222 let key = sprintf "libguestfs_commit_tested_%s" commit in
223 target (memory_exists key);
224 onrun (fun () -> memory_set key "1");
226 require (repo_up_to_date branch);
228 let repodir = sprintf "%s/repos/%s-%s" buildtmp package branch in
235 echo %s > localconfigure
236 chmod +x localconfigure
241 if ! make check-release; then
242 for f in `find -name test-suite.log | xargs grep -l ^FAIL:`; do
250 (quote (libguestfs_localconfigure `Git))
251 (quote (libguestfs_localenv None))
253 and repo_up_to_date branch =
256 (* Goals for Python sdists. *)
257 and python_website_checked_in version =
258 let key = sprintf "libguestfs_python_website_checked_in_%s" version.version in
259 target (memory_exists key);
260 onrun (fun () -> memory_set key "1");
262 require (python_tarball_created version);
263 require (python_tarball_tested version);
269 git commit -m \"Python sdist version %s\"
270 " libguestfs_download_repo
271 buildtmp version.python_tarball version.python_urlpath
272 version.python_urlpath
275 and python_tarball_tested version =
276 let key = sprintf "libguestfs_python_tarball_tested_%s" version.version in
277 target (memory_exists key);
278 onrun (fun () -> memory_set key "1");
280 require (python_tarball_created version);
284 source ./venv/bin/activate
285 pip install %s/tarballs/%s
286 " buildtmp version.python_tarball
288 and python_tarball_created version =
289 let filename = sprintf "%s/tarballs/%s" buildtmp version.python_tarball in
290 target (file_exists filename);
292 require (tarball_created version);
295 tar zxf %s/tarballs/%s
298 echo %s > localconfigure
299 chmod +x localconfigure
306 " buildtmp version.tarball
307 version.package_version
308 (quote (libguestfs_localconfigure `Tarball))
309 (quote (libguestfs_localenv (supermin version)))
310 version.python_tarball filename
313 (* Add a periodic job to check for new git commits and test them. *)
314 every libguestfs_query_mins minutes ~name:"new libguestfs commit" (
316 require (repo_up_to_date "master");
317 let commit = git_latest_commit "master" in
318 require (commit_tested "master" commit);
321 (* Periodic job to build new tarballs. *)
322 every libguestfs_query_mins minutes ~name:"new libguestfs version" (
324 require (repo_up_to_date "master");
325 let version = git_latest_version "master" in
326 require (website_updated version)
329 (* Allow these jobs to run from the command line. *)
333 | [commit] -> require (commit_tested "master" commit)
334 | [branch; commit] -> require (commit_tested branch commit)
336 failwith "use './libguestfs_upstream commit [<branch>] <commit>'"
340 | [version] -> require (website_updated (vernames version))
342 failwith "use './libguestfs_upstream release <version>'"