summaryrefslogtreecommitdiff
path: root/src/crawl-actions-wrapper.scm
diff options
context:
space:
mode:
authorbdunahu <bdunahu@operationnull.com>2026-04-27 22:16:12 -0400
committerbdunahu <bdunahu@operationnull.com>2026-04-28 00:15:09 -0400
commit9e143d1d84817ec7e6d139d234f0fff07749621c (patch)
tree7565eac131cc3528d33d5ea3597cdd8006fdb968 /src/crawl-actions-wrapper.scm
initial commitHEADmaster
Diffstat (limited to 'src/crawl-actions-wrapper.scm')
-rw-r--r--src/crawl-actions-wrapper.scm61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/crawl-actions-wrapper.scm b/src/crawl-actions-wrapper.scm
new file mode 100644
index 0000000..2f42dea
--- /dev/null
+++ b/src/crawl-actions-wrapper.scm
@@ -0,0 +1,61 @@
+;; 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 crawl-actions-wrapper)
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 string-fun)
+ #:use-module ((src utils) #:prefix util:)
+ #:use-module ((src config) #:prefix conf:)
+ #:use-module (ice-9 textual-ports)
+ #:use-module ((src poll-repos) #:prefix poll:)
+ #:export (crawl-actions
+ external-file))
+
+(define mapdir (dirname poll:outfile))
+(define mapfile (in-vicinity mapdir "repos-to-actions-map.txt"))
+(define actiondir (in-vicinity conf:cache-dir "actions"))
+(define external-file (in-vicinity actiondir "external.txt"))
+(define docker-file (in-vicinity actiondir "docker.txt"))
+(define file->regex `((,external-file .
+ "^[A-Za-z0-9][A-Za-z0-9_.-]*(/[A-Za-z0-9_.-]+)*(\\s(\\S+))?$")
+ (,docker-file . "^docker://")
+ (,(in-vicinity actiondir "internal.txt") .
+ "^\\./[A-Za-z0-9_./-]+(\\s(\\S+))?$")))
+
+(define (get-uniq-actions str)
+ (define (kill-comments str)
+ (let ((pos (string-index str #\#)))
+ (if pos (substring str 0 pos) str)))
+ (let* ((lines (filter (lambda (s) (not (string=? s "")))
+ (string-split str #\newline)))
+ (lines (map kill-comments lines))
+ (actions (map (lambda (l) (cadr (string-split
+ l char-set:whitespace)))
+ lines))
+ (uniq-actions (delete-duplicates actions)))
+ (map (lambda (a) (string-replace-substring a "@" " "))
+ uniq-actions)))
+
+(define (crawl-actions)
+ (let* ((repos-to-actions-map-sh (in-vicinity conf:scripts-dir
+ "repos_to_actions_map.sh")))
+ (system (string-append repos-to-actions-map-sh " < "
+ poll:outfile " >> " mapfile))) ;append mode
+ ;; again, we do this separately after writing everything to another file
+ ;; github can cut me off at any time. I would prefer the choice of
+ ;; restarting again with a manually modified input file than lose all data.
+ (util:normalize-file mapfile)
+ (util:filter-actions-on-regex mapfile file->regex get-uniq-actions))