start moving actual Jenkins build scripts into the repository
authorLars Hupel <lars.hupel@mytum.de>
Sat, 11 Jun 2016 17:23:24 +0200
changeset 63288 e0513d6e4916
parent 63283 a59801b7f125
child 63289 26134a00d060
start moving actual Jenkins build scripts into the repository
Admin/jenkins/build/ci_build_makeall.scala
Admin/jenkins/build/etc/settings
Admin/jenkins/run_build
src/Pure/Tools/ci_profile.scala
src/Pure/build-jars
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/jenkins/build/ci_build_makeall.scala	Sat Jun 11 17:23:24 2016 +0200
@@ -0,0 +1,17 @@
+object profile extends isabelle.CI_Profile
+{
+
+  import isabelle._
+
+  def threads = 4
+  def jobs = 2
+  def all = true
+  def groups = Nil
+  def exclude = Nil
+  def include = Nil
+  def select = Nil
+
+  def pre_hook(args: List[String]) = {}
+  def post_hook(results: Build.Results) = {}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/jenkins/build/etc/settings	Sat Jun 11 17:23:24 2016 +0200
@@ -0,0 +1,1 @@
+ISABELLE_TOOLS="$COMPONENT:$ISABELLE_TOOLS"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Admin/jenkins/run_build	Sat Jun 11 17:23:24 2016 +0200
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+#
+# Do not run this script manually, it is only to be executed by Jenkins.
+
+set -x
+set -e
+
+PROFILE="$1"
+shift
+
+bin/isabelle components -a
+bin/isabelle jedit -bf
+bin/isabelle "ci_build_$PROFILE" "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/Tools/ci_profile.scala	Sat Jun 11 17:23:24 2016 +0200
@@ -0,0 +1,96 @@
+/*  Title:      Pure/Tools/ci_profile.scala
+    Author:     Lars Hupel
+
+Build profile for continuous integration services.
+*/
+
+package isabelle
+
+
+abstract class CI_Profile extends Isabelle_Tool.Body
+{
+
+  private def print_variable(name: String): Unit =
+  {
+    val value = Isabelle_System.getenv_strict(name)
+    println(s"""$name="$value"""")
+  }
+
+  protected def hg_id(path: Path): String =
+    Isabelle_System.hg("id -i", path.file).out
+
+  private def build(options: Options): Build.Results =
+  {
+    val progress = new Console_Progress(true)
+    progress.interrupt_handler {
+      Build.build(
+        options = options,
+        progress = progress,
+        clean_build = true,
+        verbose = true,
+        max_jobs = jobs,
+        dirs = include,
+        select_dirs = select,
+        session_groups = groups,
+        all_sessions = all,
+        exclude_session_groups = exclude,
+        system_mode = true
+      )
+    }
+  }
+
+
+  override final def apply(args: List[String]): Unit =
+  {
+    List("ML_PLATFORM", "ML_HOME", "ML_SYSTEM", "ML_OPTIONS").foreach(print_variable)
+    val isabelle_home = Path.explode(Isabelle_System.getenv_strict("ISABELLE_HOME"))
+    println(s"Build for repository Isabelle/${hg_id(isabelle_home)}")
+
+    val options =
+      Options.init()
+        .bool.update("browser_info", true)
+        .string.update("document", "pdf")
+        .string.update("document_variants", "document:outline=/proof,/ML")
+        .int.update("parallel_proofs", 2)
+        .int.update("threads", threads)
+
+    pre_hook(args)
+
+    val results = build(options)
+
+    if (!results.ok) {
+      println()
+      println("=== FAILED SESSIONS ===")
+
+      for (name <- results.sessions) {
+        if (results.cancelled(name)) {
+          println(s"Session $name: CANCELLED")
+        }
+        else {
+          val result = results(name)
+          if (!result.ok)
+            println(s"Session $name: FAILED ${result.rc}")
+        }
+      }
+    }
+
+    post_hook(results)
+
+    System.exit(results.rc)
+  }
+
+
+  /* profile */
+
+  def threads: Int
+  def jobs: Int
+  def all: Boolean
+  def groups: List[String]
+  def exclude: List[String]
+  def include: List[Path]
+  def select: List[Path]
+
+  def pre_hook(args: List[String]): Unit
+  def post_hook(results: Build.Results): Unit
+
+}
--- a/src/Pure/build-jars	Fri Jun 10 23:13:04 2016 +0200
+++ b/src/Pure/build-jars	Sat Jun 11 17:23:24 2016 +0200
@@ -101,6 +101,7 @@
   Tools/build_doc.scala
   Tools/check_keywords.scala
   Tools/check_sources.scala
+  Tools/ci_profile.scala
   Tools/debugger.scala
   Tools/doc.scala
   Tools/main.scala