From ceeaec39413d4b16cacb274bebb4859d78076625 Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Wed, 3 Feb 2021 02:55:43 +0300 Subject: [PATCH] Trying to add qlfile template support. --- .github/actions/setup/action.yml | 34 ++++++++++------------------- .github/actions/setup/run-tests.ros | 2 +- .github/actions/setup/templater.ros | 24 ++++++++++++++++++-- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 8935560..8d47173 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,19 +1,15 @@ name: 'Install Roswell & Qlot' inputs: - qlfile-template: - description: 'Jinja template for qlfile' - required: false - default: 'The Template' asdf-system: description: 'ASDF system to install and test' required: true run-tests: description: A command to run tests required: false - # default: | - # qlot exec ros --eval '(asdf:test-system :{{ lisp-system }})' --quit - + qlfile-template: + description: 'Mustache template for qlfile' + required: false runs: using: composite @@ -57,28 +53,20 @@ runs: echo .qlot/bin >> $GITHUB_PATH echo ::endgroup:: - # - name: Run a custom Roswell Script - # shell: ros -Q -- {0} "$@" - # run: | - # (progn - # (ros:ensure-asdf) - # #+quicklisp - # (ql:quickload '() :silent t)) - - # (defun main (args) - # (declare (ignore args)) - # (format t "::group::Custom Roswell Script~%") - # (format t "Lisp: ~A ~A~%ASDF: ~A~%" - # (lisp-implementation-version) - # (lisp-implementation-type) - # (asdf:asdf-version)) - # (format t "::endgroup::~%")) - name: Create Qlot Environment shell: bash run: | echo ::group::Create Qlot Environment + + if [[ -n "${QLFILE_TEMPLATE}" ]]; then + echo "${QLFILE_TEMPLATE} | .github/actions/setup/templater.ros > qlfile + rm -f qlfile.lock + fi + qlot install echo ::endgroup:: + env: + QLFILE_TEMPLATE: ${{ qlfile-template }} # This step will install system and # all possible roswell scripts, if the system diff --git a/.github/actions/setup/run-tests.ros b/.github/actions/setup/run-tests.ros index 6fc6e20..ace09f7 100755 --- a/.github/actions/setup/run-tests.ros +++ b/.github/actions/setup/run-tests.ros @@ -69,7 +69,7 @@ exec ros -Q -- $0 "$@" "Please specify ASDF system as a first argument.~%") (uiop:quit 1)) - (let* ((user-script (uiop/stream:slurp-stream-forms *standard-input*)) + (let* ((user-script (uiop:slurp-stream-forms *standard-input*)) (result (cond (user-script diff --git a/.github/actions/setup/templater.ros b/.github/actions/setup/templater.ros index eba3734..37d46a0 100755 --- a/.github/actions/setup/templater.ros +++ b/.github/actions/setup/templater.ros @@ -6,7 +6,7 @@ exec ros -Q -- $0 "$@" (progn (ros:ensure-asdf) #+quicklisp - (ql:quickload '(cl-mustache) + (ql:quickload '(djula) :silent t)) (defpackage :ros.script.templater @@ -14,7 +14,27 @@ exec ros -Q -- $0 "$@" (in-package :ros.script.templater) +(defun collect-arguments () + (let* ((env-output (with-output-to-string (s) + (uiop:run-program "env" :output s))) + (lines (uiop:with-input (env-output) + (uiop:slurp-stream-lines env-output)))) + (loop for line in lines + for (key value) = (cl-ppcre:split "=" line + :limit 2) + appending (list (alexandria:make-keyword key) + value)))) + + (defun main (&rest argv) - (declare (ignorable argv))) + (declare (ignore argv)) + (let* ((lines (uiop:slurp-stream-lines *standard-input*)) + (template-text (apply #'concatenate 'string lines)) + (template (djula::compile-string template-text)) + (arguments (collect-arguments))) + (apply #'djula:render-template* + template + *standard-output* + arguments))) ;;; vim: set ft=lisp lisp: