antioxidant-ci.scm 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ;;; Antioxidant --- Building Rust without cargo
  2. ;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
  3. ;;;
  4. ;;; This file is part of Antioxidant.
  5. ;;;
  6. ;;; Antioxidant is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; Antioxidant is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with Antioxidant. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (antioxidant-ci)
  19. #:use-module ((antioxidant-packages)
  20. #:select (vitaminate/auto public-test-package
  21. antioxidant-build-system
  22. antioxidant-workspace-build-system))
  23. #:use-module ((guix build-system cargo) #:select (cargo-build-system))
  24. #:use-module ((guix profiles) #:select (packages->manifest))
  25. #:use-module ((guix packages) #:select (package? package-direct-inputs))
  26. #:use-module ((gnu packages) #:select (fold-packages))
  27. #:use-module ((rnrs exceptions) #:select (guard))
  28. #:use-module (ice-9 vlist)
  29. #:use-module (srfi srfi-1)
  30. #:use-module ((guix packages) #:select (package-build-system package-name package-version))
  31. #:autoload (guix ui) (warning G_)
  32. #:export (all-packages))
  33. (define %fails-to-build-with-cargo ; these are bugs but don't appear to be bugs introduced by antioxidant (TODO: bug reports, etc)
  34. '("git-interactive-rebase-tool"))
  35. (define (is-acceptable-leaf-cargo-rust-package? package)
  36. (and (eq? cargo-build-system (package-build-system package))
  37. ;; Old versions don't build.
  38. (not (and (string=? (package-name package) "skim")
  39. (string=? (package-version package) "0.7.0")))
  40. (or (not (string-prefix? "rust-" (package-name package)))
  41. (member (package-name package)
  42. '("rust-analyzer" "rust-cargo-c"))) ; not libraries
  43. (not (string=? (package-name package) "rust-cargo-c")) ; intentionally removed because build failures in rust-cargo
  44. (not (member (package-name package) %fails-to-build-with-cargo))))
  45. (define (all-packages)
  46. "Return a list of all antioxidated leaf packages (not guaranteed to build yet)"
  47. (define (manually-antioxidated-variant package)
  48. ;; Some leaf package are updated or patched. In that case, vitaminate/auto
  49. ;; will _not_ choose the updated or patched version. However, a ‘manually’
  50. ;; antioxidated will be defined in (antioxidant-packages).
  51. (and=> (module-variable
  52. (resolve-interface '(antioxidant-packages))
  53. (string->symbol (string-append "antioxidated-" (package-name package))))
  54. variable-ref))
  55. (define (add foo list)
  56. (guard (c ((eq? (exception-kind c) 'antioxidant-cycle)
  57. (warning (G_ "skipping ~a for now because of cycle~%") (package-name foo))
  58. list)
  59. ((eq? (exception-kind c) 'keyword-argument-error)
  60. (warning (G_ "skipping ~a for now because of ~a~%") (package-name foo) c)
  61. list))
  62. (cons (or (manually-antioxidated-variant foo)
  63. (public-test-package (vitaminate/auto foo))) list)))
  64. (fold-packages add '() #:select? is-acceptable-leaf-cargo-rust-package?))
  65. (define (package-closure/vhash todo seen descend?)
  66. ;; Compute the closure, depth-first
  67. ;; todo: list of packages
  68. ;; seen: vhash -> #true of packages
  69. (define (only-package input)
  70. (second input))
  71. (define (proc new-package seen)
  72. (cond ((vhash-assq new-package seen) ; already visited
  73. seen)
  74. ((descend? new-package)
  75. (package-closure/vhash
  76. (map only-package (package-direct-inputs new-package))
  77. (vhash-consq new-package #true seen)
  78. descend?))
  79. (#true
  80. (vhash-consq new-package #true seen))))
  81. (fold proc seen todo))
  82. (define (rusty-package-closure packages)
  83. (define (vhash->key-list vhash)
  84. (define (cons-it key _ rest)
  85. (cons key rest))
  86. (vhash-fold cons-it '() vhash))
  87. (define (descend? package)
  88. (and (package? package) ; could be an <origin>
  89. (or (string-prefix? "antioxidated-" (package-name package))
  90. (string-prefix? "rust-" (package-name package))
  91. (eq? (package-build-system package) antioxidant-build-system)
  92. (eq? (package-build-system package) antioxidant-workspace-build-system))))
  93. (vhash->key-list (package-closure/vhash packages vlist-null descend?)))
  94. ;; The idea is to build all packages in (all-packages) by the CI infrastructure.
  95. ;; Apparently returning a manifest is convenient for the CI infrastructure, see
  96. ;; see <https://github.com/emixa-d/antioxidant-fallback/pull/1>.
  97. ;;
  98. ;; By using rusty-package-closure, the intermediate packages are shown as well.
  99. ;;
  100. ;; List all bootstrap Rust, to avoid mixing logs and something that's unclear.
  101. (packages->manifest (cons* (@@ (gnu packages rust) rust-bootstrap)
  102. (@@ (gnu packages rust) rust-1.55)
  103. (@@ (gnu packages rust) rust-1.56)
  104. (@@ (gnu packages rust) rust-1.57)
  105. (@@ (gnu packages rust) rust-1.58)
  106. (@@ (gnu packages rust) rust-1.59)
  107. (@ (gnu packages rust) rust)
  108. (rusty-package-closure (all-packages))))