ci.scm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
  3. ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
  4. ;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org>
  5. ;;; Copyright © 2017, 2020, 2021 Mathieu Othacehe <m.othacehe@gmail.com>
  6. ;;; Copyright © 2017, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
  7. ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (gnu packages ci)
  24. #:use-module ((guix licenses) #:prefix l:)
  25. #:use-module (gnu packages)
  26. #:use-module (guix packages)
  27. #:use-module (guix download)
  28. #:use-module (guix git-download)
  29. #:use-module (guix download)
  30. #:use-module (gnu packages autotools)
  31. #:use-module (gnu packages base)
  32. #:use-module (gnu packages boost)
  33. #:use-module (gnu packages check)
  34. #:use-module (gnu packages docbook)
  35. #:use-module (gnu packages compression)
  36. #:use-module (gnu packages databases)
  37. #:use-module (gnu packages guile)
  38. #:use-module (gnu packages guile-xyz)
  39. #:use-module (gnu packages gnupg)
  40. #:use-module (gnu packages lisp-xyz)
  41. #:use-module (gnu packages mail)
  42. #:use-module (gnu packages package-management)
  43. #:use-module (gnu packages perl)
  44. #:use-module (gnu packages perl-compression)
  45. #:use-module (gnu packages pkg-config)
  46. #:use-module (gnu packages serialization)
  47. #:use-module (gnu packages sqlite)
  48. #:use-module (gnu packages tls)
  49. #:use-module (gnu packages texinfo)
  50. #:use-module (gnu packages version-control)
  51. #:use-module (gnu packages web)
  52. #:use-module (gnu packages xml)
  53. #:use-module (guix build-system cmake)
  54. #:use-module (guix build-system gnu))
  55. (define-public guile-squee-dev
  56. (let ((commit "e0614273ad4067af82f508db51c8a100131151ea")
  57. (revision "3"))
  58. (package
  59. (inherit guile-squee)
  60. (name "guile-squee")
  61. (version (string-append "0-" revision "." (string-take commit 7)))
  62. (home-page "https://notabug.org/mothacehe/guile-squee.git")
  63. (source (origin
  64. (method git-fetch)
  65. (uri (git-reference
  66. (url home-page)
  67. (commit commit)))
  68. (sha256
  69. (base32
  70. "1jps14z8653ah2kr367iayzyi3ql2s55l77xrafz7gk3mzcvgrrg"))
  71. (file-name (string-append name "-" version "-checkout")))))))
  72. (define-public cuirass
  73. (let ((commit "60190401ce4ccc890629ec3cb22a84a8ab8c2645")
  74. (revision "4"))
  75. (package
  76. (name "cuirass")
  77. (version (git-version "1.1.0" revision commit))
  78. (source
  79. (origin
  80. (method git-fetch)
  81. (uri (git-reference
  82. (url "https://git.savannah.gnu.org/git/guix/guix-cuirass.git")
  83. (commit commit)))
  84. (file-name (git-file-name name version))
  85. (sha256
  86. (base32
  87. "0b0bs32lzk5ck7lw8ac9dj2h70sqc5y430vhi7rcnwj48mdrchma"))))
  88. (build-system gnu-build-system)
  89. (arguments
  90. `(#:modules ((guix build utils)
  91. (guix build gnu-build-system)
  92. (ice-9 rdelim)
  93. (ice-9 popen))
  94. #:configure-flags '("--localstatedir=/var") ;for /var/log/cuirass
  95. ;; XXX: HTTP tests fail on aarch64 due to Fibers errors, disable them
  96. ;; on that architecture for now.
  97. #:tests? ,(let ((s (or (%current-target-system)
  98. (%current-system))))
  99. (not (string-prefix? "aarch64" s)))
  100. #:parallel-tests? #f
  101. #:phases
  102. (modify-phases %standard-phases
  103. (add-before 'bootstrap 'fix-version-gen
  104. (lambda _
  105. (patch-shebang "build-aux/git-version-gen")
  106. (call-with-output-file ".tarball-version"
  107. (lambda (port)
  108. (display ,version port)))))
  109. (add-before 'check 'set-PATH-for-tests
  110. (lambda* (#:key inputs #:allow-other-keys)
  111. (let ((pg (assoc-ref inputs "ephemeralpg"))
  112. (path (getenv "PATH")))
  113. (setenv "PATH" (string-append pg "/bin:" path))
  114. #t)))
  115. ;; Disable the remote tests that require a Guix daemon connection.
  116. (add-before 'check 'disable-remote-tests
  117. (lambda _
  118. (substitute* "Makefile.am"
  119. (("tests/remote.scm") ""))
  120. #t))
  121. (add-after 'install 'wrap-program
  122. (lambda* (#:key inputs outputs #:allow-other-keys)
  123. ;; Wrap the 'cuirass' command to refer to the right modules.
  124. (let* ((out (assoc-ref outputs "out"))
  125. (avahi (assoc-ref inputs "guile-avahi"))
  126. (gcrypt (assoc-ref inputs "guile-gcrypt"))
  127. (json (assoc-ref inputs "guile-json"))
  128. (zmq (assoc-ref inputs "guile-simple-zmq"))
  129. (squee (assoc-ref inputs "guile-squee"))
  130. (git (assoc-ref inputs "guile-git"))
  131. (bytes (assoc-ref inputs "guile-bytestructures"))
  132. (fibers (assoc-ref inputs "guile-fibers"))
  133. (zlib (assoc-ref inputs "guile-zlib"))
  134. (matd (assoc-ref inputs "guile-mastodon"))
  135. (tls (assoc-ref inputs "gnutls"))
  136. (mail (assoc-ref inputs "mailutils"))
  137. (guix (assoc-ref inputs "guix"))
  138. (deps (list avahi gcrypt json zmq squee git bytes
  139. fibers zlib matd tls mail guix))
  140. (guile (assoc-ref inputs "guile"))
  141. (effective
  142. (read-line
  143. (open-pipe* OPEN_READ
  144. (string-append guile "/bin/guile")
  145. "-c" "(display (effective-version))")))
  146. (mods
  147. (string-drop-right ;drop trailing colon
  148. (string-join deps
  149. (string-append "/share/guile/site/"
  150. effective ":")
  151. 'suffix)
  152. 1))
  153. (objs
  154. (string-drop-right
  155. (string-join deps
  156. (string-append "/lib/guile/" effective
  157. "/site-ccache:")
  158. 'suffix)
  159. 1)))
  160. ;; Make sure 'cuirass' can find the relevant Guile modules.
  161. (wrap-program (string-append out "/bin/cuirass")
  162. `("PATH" ":" prefix (,(string-append out "/bin")))
  163. `("GUILE_LOAD_PATH" ":" prefix (,mods))
  164. `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs)))
  165. #t))))))
  166. (inputs
  167. `(("guile" ,guile-3.0-latest)
  168. ("guile-avahi" ,guile-avahi)
  169. ("guile-fibers" ,guile-fibers)
  170. ("guile-gcrypt" ,guile-gcrypt)
  171. ("guile-json" ,guile-json-4)
  172. ("guile-simple-zmq" ,guile-simple-zmq)
  173. ("guile-squee" ,guile-squee-dev)
  174. ("guile-git" ,guile-git)
  175. ("guile-zlib" ,guile-zlib)
  176. ("guile-mastodon" ,guile-mastodon)
  177. ("gnutls" ,gnutls)
  178. ("mailutils" ,mailutils)
  179. ;; FIXME: this is propagated by "guile-git", but it needs to be among
  180. ;; the inputs to add it to GUILE_LOAD_PATH.
  181. ("guile-bytestructures" ,guile-bytestructures)
  182. ("guix" ,guix)))
  183. (native-inputs
  184. `(("autoconf" ,autoconf)
  185. ("automake" ,automake)
  186. ("pkg-config" ,pkg-config)
  187. ("texinfo" ,texinfo)
  188. ("ephemeralpg" ,ephemeralpg)))
  189. (native-search-paths
  190. ;; For HTTPS access, Cuirass itself honors these variables, with the
  191. ;; same semantics as Git and OpenSSL (respectively).
  192. (list (search-path-specification
  193. (variable "GIT_SSL_CAINFO")
  194. (file-type 'regular)
  195. (separator #f) ;single entry
  196. (files '("etc/ssl/certs/ca-certificates.crt")))
  197. (search-path-specification
  198. (variable "SSL_CERT_DIR")
  199. (files '("etc/ssl/certs")))))
  200. (synopsis "Continuous integration system")
  201. (description
  202. "Cuirass is a continuous integration tool using GNU Guix. It is
  203. intended as a replacement for Hydra.")
  204. (home-page "https://guix.gnu.org/cuirass/")
  205. (license l:gpl3+))))
  206. (define-public laminar
  207. (package
  208. (name "laminar")
  209. (version "1.0")
  210. (source
  211. (origin (method url-fetch)
  212. (uri (string-append "https://github.com/ohwgiles/laminar/archive/"
  213. version
  214. ".tar.gz"))
  215. (file-name (string-append name "-" version ".tar.gz"))
  216. (sha256
  217. (base32
  218. "11m6h3rdmj2rsmsryy7r40gqccj4gg1cnqwy6blscs87gx4s423g"))))
  219. (build-system cmake-build-system)
  220. (arguments
  221. `(#:tests? #f ; TODO Can't build tests
  222. #:configure-flags
  223. (list "-DCMAKE_CXX_STANDARD=17"
  224. ;; "-DBUILD_TESTS=true" TODO: objcopy: js/stPskyUS: can't add
  225. ;; section '.note.GNU-stack': file format not recognized
  226. (string-append "-DLAMINAR_VERSION=" ,version))
  227. #:phases
  228. (modify-phases %standard-phases
  229. (add-after 'unpack 'patch-CMakeLists.txt
  230. (lambda _
  231. (substitute* "CMakeLists.txt"
  232. (("file\\(DOWNLOAD.*\n$")
  233. "# file download removed by Guix --")
  234. (("install\\(FILES etc/laminar.service DESTINATION \\$\\{SYSTEMD\\_UNITDIR\\}\\)")
  235. "")
  236. (("install\\(FILES \\$\\{CMAKE\\_CURRENT\\_BINARY\\_DIR\\}\\/laminar\\.service DESTINATION \\$\\{SYSTEMD\\_UNITDIR\\}\\)")
  237. "")
  238. (("install\\(FILES etc/laminar\\.conf DESTINATION \\/etc\\)") "")
  239. (("\\/usr\\/") ""))
  240. #t))
  241. (add-after 'configure 'copy-in-javascript-and-css
  242. (lambda* (#:key inputs outputs #:allow-other-keys)
  243. (use-modules (ice-9 popen))
  244. (mkdir-p "../build/js")
  245. (for-each (lambda (name)
  246. (let* ((file
  247. (assoc-ref inputs (string-append name ".js")))
  248. (port
  249. (open-pipe* OPEN_READ "uglify-js" file))
  250. (destination
  251. (string-append
  252. "../build/js/" name ".min.js")))
  253. (call-with-output-file destination
  254. (lambda (output-port)
  255. (dump-port port output-port)))
  256. (let ((exit (close-pipe port)))
  257. (unless (zero? exit)
  258. (error "uglify-js failed" exit)))))
  259. '("vue"
  260. "vue-router"
  261. "Chart"))
  262. ;; ansi_up.js isn't minified
  263. (copy-file (assoc-ref inputs "ansi_up.js")
  264. "../build/js/ansi_up.js")
  265. #t)))))
  266. (inputs
  267. `(("capnproto" ,capnproto)
  268. ("rapidjson" ,rapidjson)
  269. ("sqlite" ,sqlite)
  270. ("boost" ,boost)
  271. ("zlib" ,zlib)))
  272. (native-inputs
  273. `(("googletest" ,googletest)
  274. ("uglify-js" ,uglify-js)
  275. ("vue.js"
  276. ,(origin (method url-fetch)
  277. (uri (string-append "https://raw.githubusercontent.com/"
  278. "vuejs/vue/v2.6.12/dist/vue.js"))
  279. (sha256
  280. (base32
  281. "1mq2dn6yqbmzar77xf4x2bvvanf9xc9nwfq06sksl5zmr300m7qm"))))
  282. ("vue-router.js"
  283. ,(origin (method url-fetch)
  284. (uri (string-append "https://raw.githubusercontent.com/"
  285. "vuejs/vue-router/v3.4.8/dist/vue-router.js"))
  286. (sha256
  287. (base32
  288. "1hkrbgzhpnrsb4zdafslqagy1vkac6bkdj7kh49js2lhkp9z4nj5"))))
  289. ("ansi_up.js"
  290. ,(origin (method url-fetch)
  291. (uri (string-append "https://raw.githubusercontent.com/"
  292. "drudru/ansi_up/v1.3.0/ansi_up.js"))
  293. (sha256
  294. (base32
  295. "1993dywxqi2ylnxybwk7m0s0bg2bq7kfllpyr0s8ck6chd0p8i6r"))))
  296. ("Chart.js"
  297. ,(origin (method url-fetch)
  298. (uri (string-append "https://github.com/chartjs/Chart.js/"
  299. "releases/download/v2.7.2/Chart.js"))
  300. (sha256
  301. (base32
  302. "05m3gk6hqjx92j20drnk7q075qpjraywqaf25lnglmsgsgpiqsr7"))))))
  303. (synopsis "Lightweight continuous integration service")
  304. (description
  305. "Laminar is a lightweight and modular continuous integration service. It
  306. doesn't have a configuration web UI instead uses version-controllable
  307. configuration files and scripts.
  308. Laminar encourages the use of existing tools such as bash and cron instead of
  309. reinventing them.")
  310. (home-page "https://laminar.ohwg.net/")
  311. (license l:gpl3+)))