-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHOP command-line application. (#150)
* First version of SHOP command-line application. This version is simply built with buildapp. * Add DEFGENERIC for PROBLEM-NAME. This lets us handle the case where the PROBLEM argument is a symbol that names a problem, instead of a PROBLEM object. * Fix EVAL-WHEN mistake in Logistics domain file. * Add simple bash test script for application. * Fix buildapp scripts. * Test the command-line apps on GitHub. * Fix bug in buildapp installation * Fix pathname error * Fix variable expansion. * Fix the makefile. * Factor out the app building and test. * Install ASDF when building app * Syntax error. * checkout action only works on GitHub repos ASDF is hosted on common-lisp.net GitLab. * Fix pathname * Test script fix. * Update test.sh Fix a SECOND mktemp template
- Loading branch information
Showing
9 changed files
with
417 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
name: buildapp | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the master branch | ||
push: | ||
branches: [ master, new-random ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
buildapp: | ||
# The type of runner that the job will run on | ||
runs-on: ${{matrix.os}} | ||
container: | ||
image: ${{matrix.cfg.container}} | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
cfg: | ||
- { container: "containers.common-lisp.net/cl-docker-images/sbcl:latest", lisp: sbcl } | ||
- { container: "containers.common-lisp.net/cl-docker-images/ccl:latest", lisp: ccl } | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: install up-to-date ASDF | ||
shell: bash | ||
run: | | ||
cd ${HOME} | ||
mkdir lisp | ||
cd lisp | ||
git clone https://gitlab.common-lisp.net/asdf/asdf.git | ||
cd asdf | ||
git checkout release | ||
make | ||
- name: install quicklisp | ||
shell: bash | ||
run: | | ||
/usr/local/bin/install-quicklisp | ||
- name: install buildapp | ||
shell: bash | ||
run: | | ||
${{ matrix.cfg.lisp }} --load ${HOME}/quicklisp/setup.lisp --eval '(ql:quickload "buildapp")' --eval '(uiop:quit 0)' | ||
- name: build buildapp binary | ||
shell: bash | ||
run: | | ||
cd ${HOME}/quicklisp/dists/quicklisp/software/buildapp* | ||
echo "Building buildapp with lisp = ${{ matrix.cfg.lisp }}" | ||
make LISP=${{ matrix.cfg.lisp }} install | ||
- name: build and install shop app | ||
shell: bash | ||
run: | | ||
cd shop3/buildapp ; make clean ; make LISP=${{ matrix.cfg.lisp }} install | ||
- name: test shop apps | ||
shell: bash | ||
run: | | ||
cd shop3/buildapp ; ./test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shop-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DESTDIR = /usr/local | ||
LISP := sbcl | ||
|
||
shop-app: buildapp-script shop-app-entrypoints.lisp | ||
./buildapp-script | ||
|
||
install: shop-app | ||
install -c -m 555 shop-app ${DESTDIR}/bin/shop | ||
install -c -m 555 shop-app ${DESTDIR}/bin/ess-shop | ||
|
||
clean: | ||
rm -f shop-app | ||
|
||
.PHONY: clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash -x | ||
|
||
ASDF_DIR=${ASDF_DIR:-${HOME}/lisp/asdf/build} | ||
THIS_DIR=$(realpath $(dirname ${BASH_SOURCE})) | ||
QUICKLISP_DIR=${QUICKLISP_DIR:-~/quicklisp} | ||
|
||
# --dispatched-entry "shop/shop-app::main" \ | ||
# --dispatched-entry "ess-shop/shop-app::ess-main" \ | ||
# --entry "shop-app::main" \ | ||
buildapp --logfile "/tmp/buildapp-shop-app.log" \ | ||
--output shop-app \ | ||
--dispatched-entry "/shop-app::main" \ | ||
--dispatched-entry "shop/shop-app::main" \ | ||
--dispatched-entry "ess-shop/shop-app::ess-main" \ | ||
--load "${ASDF_DIR}/asdf.lisp" \ | ||
--asdf-path "${THIS_DIR}/../" \ | ||
--asdf-tree "${THIS_DIR}/../../jenkins/ext/" \ | ||
--eval '(declaim (optimize speed space safety))' \ | ||
--load-system "shop3" \ | ||
--load "${THIS_DIR}/shop-app-entrypoints.lisp" | ||
|
||
|
||
retVal=$? | ||
if [ $retVal -ne 0 ]; then | ||
echo "Build process failed with exit code $retVal" | ||
exit $retVal | ||
fi | ||
exit $retVal | ||
|
||
# Local Variables: | ||
# mode: sh | ||
# End: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
;;;--------------------------------------------------------------------------- | ||
;;; Copyright Robert P. Goldman and Smart Information Flow Technologies, | ||
;;; d/b/a SIFT, LLC | ||
;;; | ||
;;; This file made available under the license terms of the SHOP3 system. | ||
;;;--------------------------------------------------------------------------- | ||
;;; File Description: | ||
;;; | ||
;;; A file that gives entry points to a command-line application that runs the | ||
;;; SHOP3 planner on an input domain and problem. | ||
;;; | ||
;;; History/Bugs/Notes: | ||
;;; | ||
;;; [2023/10/11:rpg] Created. | ||
;;; | ||
;;;--------------------------------------------------------------------------- | ||
(defpackage :shop-app | ||
(:use :shop3 :iterate :common-lisp)) | ||
(in-package :shop-app) | ||
|
||
(defun usage (progname) | ||
(format t "~&~a: file1 [file2]~%" progname) | ||
(format t "~%Runs the SHOP planner on the problem, and prints the result to standard output.~%") | ||
(format t "~%If only one file is given, it should contain both domain and problem definitions.~%~ | ||
If two are given, the first should be the domain file and the second the problem file~%~ | ||
(although in fact, the ordering is not critical).~%~%~ | ||
The output plan is wrapped between two lines of equal signs (=), and is printed ~%~ | ||
in three columns, step number, a colon (:), step, a colon (:), and cost rounded to~%2 decimal places.~%")) | ||
|
||
(defun print-plan (plan) | ||
(let ((*print-length* nil) | ||
(*print-right-margin* 10000) | ||
;; best guess at package for output | ||
(*package* (symbol-package (shop::problem-name shop::*problem*)))) | ||
(flet ((print-separator () | ||
(format t "~&======================================================================~%"))) | ||
(print-separator) | ||
(iter (for (step cost . nil) on plan by 'cddr) | ||
(as i from 1) | ||
(format t "~3d:~t~a:~t~,2f~%" | ||
i step cost)) | ||
(print-separator)))) | ||
|
||
(defun main (argv &key (plan-fun #'shop:find-plans)) | ||
(when (member "--help" (rest argv) :test #'string=) | ||
(usage (first argv)) | ||
(uiop:quit 0)) | ||
(handler-bind ((error | ||
(lambda (x) | ||
(format *error-output* "~a" x) | ||
(uiop:quit 1)))) | ||
(iter (for x in (rest argv)) | ||
(unless (load x :if-does-not-exist t) | ||
(error "File ~a failed to load." x))) | ||
(multiple-value-bind (plans time trees) | ||
(funcall plan-fun shop::*problem*) | ||
(declare (ignore time trees)) ; at least for now... | ||
(unless plans | ||
(error "Unable to find a plan for problem ~a" | ||
(shop::problem-name shop::*problem*))) | ||
(print-plan (first plans)))) | ||
(uiop:quit 0)) | ||
|
||
(defun ess-main (argv) | ||
(when (member "--help" (rest argv) :test #'string=) | ||
(usage (first argv)) | ||
(uiop:quit 0)) | ||
(main argv :plan-fun #'shop:find-plans-stack)) |
Oops, something went wrong.