summaryrefslogtreecommitdiff
path: root/src/build-actions.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/build-actions.scm')
-rw-r--r--src/build-actions.scm74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/build-actions.scm b/src/build-actions.scm
new file mode 100644
index 0000000..f2b1d02
--- /dev/null
+++ b/src/build-actions.scm
@@ -0,0 +1,74 @@
+;; kenku --- crawl and reproduce github actions
+;; Copyright © 2026 bdunahu <bdunahu@operationnull.com>
+;;
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (src build-actions)
+ #:use-module (srfi srfi-1)
+ #:use-module (guix scripts environment)
+ #:use-module ((src utils) #:prefix util:)
+ #:use-module ((src config) #:prefix conf:)
+ #:use-module ((ice-9 rdelim))
+ #:use-module ((src crawl-lockfiles) #:prefix lock:)
+ #:export (build-actions))
+
+(define (make-in-vicinity dir f)
+ (let ((dir (in-vicinity dir f)))
+ (util:mkdir-p dir)
+ dir))
+
+(define (build-actions)
+ (let* ((build-action-sh (in-vicinity conf:scripts-dir "build-action.sh"))
+ (time (strftime "%Y-%m-%d_%H-%M-%S" (localtime (current-time))))
+ (dir (string-append conf:cache-dir "/build-" time))
+ (bf (make-in-vicinity dir "build-failures"))
+ (ma (make-in-vicinity dir "missing-artifact"))
+ (mr (make-in-vicinity dir "maybe-reproducible"))
+ (r (make-in-vicinity dir "reproducible"))
+ (packages '("bash"
+ "coreutils"
+ "diffoscope"
+ "dos2unix"
+ "findutils"
+ "gawk"
+ "git"
+ "grep"
+ "node"
+ "nss-certs"
+ "python"
+ "sed"
+ "xxd"
+ "diffutils"))
+ (opts '("--network" "--emulate-fhs" "--container"
+ "--preserve='^TERM$'")) ;diffoscope needs this
+ (cmd `("--" "bash" ,build-action-sh
+ "~a" "~a" "./~a" "~a" "~a" "~a" "~a")))
+ (call-with-input-file lock:npm-file
+ (lambda (port)
+ (let loop ()
+ (let ((line (read-line port)))
+ (unless (eof-object? line)
+ (let* ((list (string-split line char-set:whitespace))
+ (repo (car list))
+ (sha (cadr list))
+ (lock-dir (dirname (caddr list))))
+ (format #t "Starting build of ~a@~a~%" repo sha)
+ (system (format #f (string-join (append '("guix" "shell")
+ opts
+ packages
+ cmd)
+ " ")
+ repo sha lock-dir bf ma mr r)))
+ (loop))))))
+ (format #t "Done! Check ~a.~%" dir)))