Trying to add qlfile template support.

This commit is contained in:
Alexander Artemenko 2021-02-03 02:55:43 +03:00
parent 3e43e468a8
commit ceeaec3941
3 changed files with 34 additions and 26 deletions

View file

@ -1,19 +1,15 @@
name: 'Install Roswell & Qlot' name: 'Install Roswell & Qlot'
inputs: inputs:
qlfile-template:
description: 'Jinja template for qlfile'
required: false
default: 'The Template'
asdf-system: asdf-system:
description: 'ASDF system to install and test' description: 'ASDF system to install and test'
required: true required: true
run-tests: run-tests:
description: A command to run tests description: A command to run tests
required: false required: false
# default: | qlfile-template:
# qlot exec ros --eval '(asdf:test-system :{{ lisp-system }})' --quit description: 'Mustache template for qlfile'
required: false
runs: runs:
using: composite using: composite
@ -57,28 +53,20 @@ runs:
echo .qlot/bin >> $GITHUB_PATH echo .qlot/bin >> $GITHUB_PATH
echo ::endgroup:: 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 - name: Create Qlot Environment
shell: bash shell: bash
run: | run: |
echo ::group::Create Qlot Environment 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 qlot install
echo ::endgroup:: echo ::endgroup::
env:
QLFILE_TEMPLATE: ${{ qlfile-template }}
# This step will install system and # This step will install system and
# all possible roswell scripts, if the system # all possible roswell scripts, if the system

View file

@ -69,7 +69,7 @@ exec ros -Q -- $0 "$@"
"Please specify ASDF system as a first argument.~%") "Please specify ASDF system as a first argument.~%")
(uiop:quit 1)) (uiop:quit 1))
(let* ((user-script (uiop/stream:slurp-stream-forms *standard-input*)) (let* ((user-script (uiop:slurp-stream-forms *standard-input*))
(result (result
(cond (cond
(user-script (user-script

View file

@ -6,7 +6,7 @@ exec ros -Q -- $0 "$@"
(progn (progn
(ros:ensure-asdf) (ros:ensure-asdf)
#+quicklisp #+quicklisp
(ql:quickload '(cl-mustache) (ql:quickload '(djula)
:silent t)) :silent t))
(defpackage :ros.script.templater (defpackage :ros.script.templater
@ -14,7 +14,27 @@ exec ros -Q -- $0 "$@"
(in-package :ros.script.templater) (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) (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: ;;; vim: set ft=lisp lisp: