From 3046e73b4c773a43ffa9ea583c0b469aaa8c5256 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 1 Mar 2020 19:11:36 +0100 Subject: ci: Move 'cross-jobs' procedure to the top level. * gnu/ci.scm (cross-jobs): New procedure. Moved from... (hydra-jobs): ... here. --- gnu/ci.scm | 89 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 44 deletions(-) (limited to 'gnu/ci.scm') diff --git a/gnu/ci.scm b/gnu/ci.scm index 89f499e25f..9094cc0794 100644 --- a/gnu/ci.scm +++ b/gnu/ci.scm @@ -135,6 +135,49 @@ SYSTEM." "i686-w64-mingw32" "x86_64-w64-mingw32")) +(define (cross-jobs store system) + "Return a list of cross-compilation jobs for SYSTEM." + (define (from-32-to-64? target) + ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack + ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to + ;; mips64el-linux-gnuabi64. + (and (or (string-prefix? "i686-" system) + (string-prefix? "i586-" system) + (string-prefix? "armhf-" system)) + (string-contains target "64"))) ;x86_64, mips64el, aarch64, etc. + + (define (same? target) + ;; Return true if SYSTEM and TARGET are the same thing. This is so we + ;; don't try to cross-compile to 'mips64el-linux-gnu' from + ;; 'mips64el-linux'. + (or (string-contains target system) + (and (string-prefix? "armhf" system) ;armhf-linux + (string-prefix? "arm" target)))) ;arm-linux-gnueabihf + + (define (pointless? target) + ;; Return #t if it makes no sense to cross-build to TARGET from SYSTEM. + (match system + ((or "x86_64-linux" "i686-linux") + (if (string-contains target "mingw") + (not (string=? "x86_64-linux" system)) + #f)) + (_ + ;; Don't try to cross-compile from non-Intel platforms: this isn't + ;; very useful and these are often brittle configurations. + #t))) + + (define (either proc1 proc2 proc3) + (lambda (x) + (or (proc1 x) (proc2 x) (proc3 x)))) + + (append-map (lambda (target) + (map (lambda (package) + (package-cross-job store (job-name package) + package target system)) + %packages-to-cross-build)) + (remove (either from-32-to-64? same? pointless?) + %cross-targets))) + (define %guixsd-supported-systems '("x86_64-linux" "i686-linux" "armhf-linux")) @@ -417,48 +460,6 @@ Return #f if no such checkout is found." (define source (assq-ref checkout 'file-name)) - (define (cross-jobs system) - (define (from-32-to-64? target) - ;; Return true if SYSTEM is 32-bit and TARGET is 64-bit. This hack - ;; prevents known-to-fail cross-builds from i686-linux or armhf-linux to - ;; mips64el-linux-gnuabi64. - (and (or (string-prefix? "i686-" system) - (string-prefix? "i586-" system) - (string-prefix? "armhf-" system)) - (string-contains target "64"))) ;x86_64, mips64el, aarch64, etc. - - (define (same? target) - ;; Return true if SYSTEM and TARGET are the same thing. This is so we - ;; don't try to cross-compile to 'mips64el-linux-gnu' from - ;; 'mips64el-linux'. - (or (string-contains target system) - (and (string-prefix? "armhf" system) ;armhf-linux - (string-prefix? "arm" target)))) ;arm-linux-gnueabihf - - (define (pointless? target) - ;; Return #t if it makes no sense to cross-build to TARGET from SYSTEM. - (match system - ((or "x86_64-linux" "i686-linux") - (if (string-contains target "mingw") - (not (string=? "x86_64-linux" system)) - #f)) - (_ - ;; Don't try to cross-compile from non-Intel platforms: this isn't - ;; very useful and these are often brittle configurations. - #t))) - - (define (either proc1 proc2 proc3) - (lambda (x) - (or (proc1 x) (proc2 x) (proc3 x)))) - - (append-map (lambda (target) - (map (lambda (package) - (package-cross-job store (job-name package) - package target system)) - %packages-to-cross-build)) - (remove (either from-32-to-64? same? pointless?) - %cross-targets))) - ;; Turn off grafts. Grafting is meant to happen on the user's machines. (parameterize ((%graft? #f)) ;; Return one job for each package, except bootstrap packages. @@ -483,14 +484,14 @@ Return #f if no such checkout is found." #:source source #:commit commit) (tarball-jobs store system) - (cross-jobs system)))) + (cross-jobs store system)))) ((core) ;; Build core packages only. (append (map (lambda (package) (package-job store (job-name package) package system)) %core-packages) - (cross-jobs system))) + (cross-jobs store system))) ((hello) ;; Build hello package only. (if (string=? system (%current-system)) -- cgit v1.2.3 From dd1ee160be8ba4e211432c08e161c24901cd670e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 3 Mar 2020 12:35:46 +0100 Subject: tests: "make check-system" no longer interns source upfront. * gnu/ci.scm (channel-build-system)[build, lower]: Honor #:source. (channel-source->package): New procedure. (system-test-jobs): Remove 'instance' and call to 'checkout->channel-instance'. Use 'channel-source->package'. * build-aux/run-system-tests.scm (tests-for-channel-instance): Rename to... (tests-for-current-guix): ... this. Change 'instance' to 'source'. (run-system-tests): Use 'local-file' instead of 'interned-file' for SOURCE. --- build-aux/run-system-tests.scm | 17 ++++++++--------- gnu/ci.scm | 32 ++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 23 deletions(-) (limited to 'gnu/ci.scm') diff --git a/build-aux/run-system-tests.scm b/build-aux/run-system-tests.scm index b0cb3bd2bf..a4c019ab0b 100644 --- a/build-aux/run-system-tests.scm +++ b/build-aux/run-system-tests.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2018, 2019 Ludovic Courtès +;;; Copyright © 2016, 2018, 2019, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,7 +19,8 @@ (define-module (run-system-tests) #:use-module (gnu tests) #:use-module (gnu packages package-management) - #:use-module ((gnu ci) #:select (channel-instance->package)) + #:use-module ((gnu ci) #:select (channel-source->package)) + #:use-module (guix gexp) #:use-module (guix store) #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module (guix monads) @@ -51,15 +52,15 @@ lst) (lift1 reverse %store-monad)))) -(define (tests-for-channel-instance instance) - "Return a list of tests for perform, using Guix from INSTANCE, a channel +(define (tests-for-current-guix source) + "Return a list of tests for perform, using Guix built from SOURCE, a channel instance." ;; Honor the 'TESTS' environment variable so that one can select a subset ;; of tests to run in the usual way: ;; ;; make check-system TESTS=installed-os (parameterize ((current-guix-package - (channel-instance->package instance))) + (channel-source->package source))) (match (getenv "TESTS") (#f (all-system-tests)) @@ -80,14 +81,12 @@ instance." ;; Intern SOURCE so that 'build-from-source' in (guix channels) sees ;; "fresh" file names and thus doesn't find itself loading .go files ;; from ~/.cache/guile when it loads 'build-aux/build-self.scm'. - ;; XXX: It would be best to not do it upfront because we may need it. - (mlet* %store-monad ((source (interned-file source "guix-source" + (mlet* %store-monad ((source -> (local-file source "guix-source" #:recursive? #t #:select? (or (git-predicate source) (const #t)))) - (instance -> (checkout->channel-instance source)) - (tests -> (tests-for-channel-instance instance)) + (tests -> (tests-for-current-guix source)) (drv (mapm %store-monad system-test-value tests)) (out -> (map derivation->output-path drv))) (format (current-error-port) "Running ~a system tests...~%" diff --git a/gnu/ci.scm b/gnu/ci.scm index 9094cc0794..9dc530b01e 100644 --- a/gnu/ci.scm +++ b/gnu/ci.scm @@ -28,6 +28,7 @@ #:use-module (guix derivations) #:use-module (guix build-system) #:use-module (guix monads) + #:use-module (guix gexp) #:use-module (guix ui) #:use-module ((guix licenses) #:select (gpl3+ license? license-name)) @@ -54,7 +55,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 match) - #:export (channel-instance->package + #:export (channel-source->package hydra-jobs)) ;;; Commentary: @@ -239,29 +240,35 @@ system.") (define channel-build-system ;; Build system used to "convert" a channel instance to a package. (let* ((build (lambda* (store name inputs - #:key instance system + #:key source commit system #:allow-other-keys) (run-with-store store - (channel-instances->derivation (list instance)) + (mlet* %store-monad ((source (lower-object source)) + (instance + -> (checkout->channel-instance + source #:commit commit))) + (channel-instances->derivation (list instance))) #:system system))) - (lower (lambda* (name #:key system instance #:allow-other-keys) + (lower (lambda* (name #:key system source commit + #:allow-other-keys) (bag (name name) (system system) (build build) - (arguments `(#:instance ,instance)))))) + (arguments `(#:source ,source + #:commit ,commit)))))) (build-system (name 'channel) (description "Turn a channel instance into a package.") (lower lower)))) -(define (channel-instance->package instance) - "Return a package for the given channel INSTANCE." +(define* (channel-source->package source #:key commit) + "Return a package for the given channel SOURCE, a lowerable object." (package (inherit guix) - (version (or (string-take (channel-instance-commit instance) 7) - (string-append (package-version guix) "+"))) + (version (string-append (package-version guix) "+")) (build-system channel-build-system) - (arguments `(#:instance ,instance)) + (arguments `(#:source ,source + #:commit ,commit)) (inputs '()) (native-inputs '()) (propagated-inputs '()))) @@ -269,9 +276,6 @@ system.") (define* (system-test-jobs store system #:key source commit) "Return a list of jobs for the system tests." - (define instance - (checkout->channel-instance source #:commit commit)) - (define (test->thunk test) (lambda () (define drv @@ -308,7 +312,7 @@ system.") ;; expensive. It also makes sure we get a valid Guix package when this ;; code is not running from a checkout. (parameterize ((current-guix-package - (channel-instance->package instance))) + (channel-source->package source #:commit commit))) (map ->job (all-system-tests))) '())) -- cgit v1.2.3 From bc8b2ffdac3f55414629ace5b1a0db32e9656c0a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 5 Mar 2020 23:36:01 +0100 Subject: ci: Adjust 'channel-build-system' for when the source is a file name. Fixes an evaluation error introduced in dd1ee160be8ba4e211432c08e161c24901cd670e: when invoked via 'build-aux/cuirass/gnu-system.scm', SOURCE is a store file name, not a as it is when invoked via 'etc/system-tests.scm'. * gnu/ci.scm (channel-build-system)[build]: Call 'lower-object' only when SOURCE is not a string. --- gnu/ci.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gnu/ci.scm') diff --git a/gnu/ci.scm b/gnu/ci.scm index 9dc530b01e..e024c09ebc 100644 --- a/gnu/ci.scm +++ b/gnu/ci.scm @@ -243,7 +243,11 @@ system.") #:key source commit system #:allow-other-keys) (run-with-store store - (mlet* %store-monad ((source (lower-object source)) + ;; SOURCE can be a lowerable object such as + ;; or a file name. Adjust accordingly. + (mlet* %store-monad ((source (if (string? source) + (return source) + (lower-object source))) (instance -> (checkout->channel-instance source #:commit commit))) -- cgit v1.2.3