diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87a4b49..8dcc818 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ "steps": [ { "name": "Checkout Code", - "uses": "actions/checkout@v2" + "uses": "actions/checkout@v3" }, { "name": "Grant All Perms to Make Cache Restoring Possible", @@ -34,13 +34,13 @@ { "name": "Get Current Month", "id": "current-month", - "run": "echo \"::set-output name=value::$(date -u \"+%Y-%m\")\"", + "run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT", "shell": "bash" }, { "name": "Cache Roswell Setup", "id": "cache", - "uses": "actions/cache@v2", + "uses": "actions/cache@v3", "with": { "path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot", "key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}" @@ -67,7 +67,7 @@ }, { "name": "Update Qlot", - "run": "qlot update || qlot update", + "run": "qlot update --no-deps", "shell": "bash" }, { @@ -77,7 +77,7 @@ }, { "name": "Run Linter", - "run": "qlot exec 40ants-linter --system \"40ants-asdf-system-docs\" --imports", + "run": "qlot exec 40ants-linter --system \"40ants-asdf-system-docs, 40ants-asdf-system-tests\" --imports", "shell": "bash" } ] @@ -95,12 +95,11 @@ "quicklisp" ], "lisp": [ - "sbcl", + "sbcl-bin", "ccl-bin/1.12.1", "abcl-bin", "allegro", "clasp", - "clisp", "lispworks", "mkcl", "npt", @@ -116,6 +115,111 @@ "os": "ubuntu-latest", "quicklisp": "quicklisp", "lisp": "npt" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "ccl-bin/1.12.1" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "ccl-bin/1.12.1" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "ccl-bin/1.12.1" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "abcl-bin" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "abcl-bin" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "abcl-bin" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "allegro" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "allegro" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "allegro" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "clasp" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "clasp" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "clasp" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "lispworks" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "lispworks" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "lispworks" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "mkcl" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "mkcl" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "mkcl" + }, + { + "os": "ubuntu-latest", + "quicklisp": "quicklisp", + "lisp": "ecl" + }, + { + "os": "macos-latest", + "quicklisp": "quicklisp", + "lisp": "ecl" + }, + { + "os": "macos-latest", + "quicklisp": "ultralisp", + "lisp": "ecl" } ] } @@ -129,7 +233,7 @@ "steps": [ { "name": "Checkout Code", - "uses": "actions/checkout@v2" + "uses": "actions/checkout@v3" }, { "name": "Grant All Perms to Make Cache Restoring Possible", @@ -139,13 +243,13 @@ { "name": "Get Current Month", "id": "current-month", - "run": "echo \"::set-output name=value::$(date -u \"+%Y-%m\")\"", + "run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT", "shell": "bash" }, { "name": "Cache Roswell Setup", "id": "cache", - "uses": "actions/cache@v2", + "uses": "actions/cache@v3", "with": { "path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot", "key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.quicklisp }}-${{ matrix.lisp }}-${{ hashFiles('qlfile.lock', '*.asd') }}" @@ -176,4 +280,4 @@ ] } } -} \ No newline at end of file +} diff --git a/40ants-asdf-system-tests.asd b/40ants-asdf-system-tests.asd new file mode 100644 index 0000000..2bf1e5c --- /dev/null +++ b/40ants-asdf-system-tests.asd @@ -0,0 +1,11 @@ +(defsystem "40ants-asdf-system-tests" + :author "Alexander Artemenko" + :license "BSD" + :class :package-inferred-system + :pathname "t" + :depends-on ("40ants-asdf-system-tests/core") + :description "Test system for 40ants-asdf-system." + + :perform (test-op (op c) + (unless (symbol-call :rove :run c) + (error "Tests failed")))) diff --git a/40ants-asdf-system.asd b/40ants-asdf-system.asd index 9802d05..abafa3d 100644 --- a/40ants-asdf-system.asd +++ b/40ants-asdf-system.asd @@ -11,4 +11,6 @@ :components ((:module "src" :components ((:file "package") (:file "version" :depends-on ("package")) - (:file "system" :depends-on ("version")))))) + (:file "readme" :depends-on ("package")) + (:file "system" :depends-on ("version"))))) + :in-order-to ((test-op (test-op "40ants-asdf-system-tests")))) diff --git a/qlfile b/qlfile index 99bebf8..b91f000 100644 --- a/qlfile +++ b/qlfile @@ -1 +1 @@ -dist ultralisp http://dist.ultralisp.org/ +dist ultralisp http://dist.ultralisp.org diff --git a/qlfile.lock b/qlfile.lock index b9301ab..aac9c68 100644 --- a/qlfile.lock +++ b/qlfile.lock @@ -4,5 +4,5 @@ :version "2022-11-07")) ("ultralisp" . (:class qlot/source/dist:source-dist - :initargs (:distribution "http://dist.ultralisp.org/" :%version :latest) - :version "20221107160500")) + :initargs (:distribution "http://dist.ultralisp.org" :%version :latest) + :version "20221110152000")) diff --git a/src/ci.lisp b/src/ci.lisp index 27cf76e..1841a91 100644 --- a/src/ci.lisp +++ b/src/ci.lisp @@ -10,35 +10,52 @@ #:build-docs)) (in-package #:40ants-asdf-system/ci) +(defparameter *lisp-implementations* + (list "sbcl-bin" + "ccl-bin/1.12.1" + "abcl-bin" + "allegro" + "clasp" + ;; This CL implementation does not work in any matrix combinations + ;; "cmu-bin" + "lispworks" + "mkcl" + "npt" + "ecl") ) + (defworkflow ci :on-push-to "master" :by-cron "0 10 * * 1" :on-pull-request t :cache t - :jobs ((linter :asdf-systems ("40ants-asdf-system-docs") + :jobs ((linter :asdf-systems ("40ants-asdf-system-docs" + "40ants-asdf-system-tests") :check-imports t) (run-tests :os ("ubuntu-latest" "macos-latest") :quicklisp ("ultralisp" "quicklisp") - :lisp ("sbcl" - "ccl-bin/1.12.1" - "abcl-bin" - "allegro" - "clasp" - "clisp" - ;; This CL implementation does not work in any matrix combinations - ;; "cmu-bin" - "lispworks" - "mkcl" - ;; ubuntu, ultralisp|quicklisp - "npt" - "ecl") - ;; These combinations are failed for some reason: - :exclude ((:os "ubuntu-latest" :quicklisp "ultralisp" :lisp "npt") - (:os "ubuntu-latest" :quicklisp "quicklisp" :lisp "npt")) + :lisp *lisp-implementations* + :exclude (append + ;; These combinations are failed for some reason: + '((:os "ubuntu-latest" :quicklisp "ultralisp" :lisp "npt") + (:os "ubuntu-latest" :quicklisp "quicklisp" :lisp "npt")) + ;; All implementations except SBCL and NPT we'll check only on Linux + ;; and Ultralisp dist. + (loop for lisp in *lisp-implementations* + unless (or (string-equal lisp "sbcl-bin") + (string-equal lisp "npt")) + append (list (list :os "ubuntu-latest" + :quicklisp "quicklisp" + :lisp lisp) + (list :os "macos-latest" + :quicklisp "quicklisp" + :lisp lisp) + (list :os "macos-latest" + :quicklisp "ultralisp" + :lisp lisp)))) :coverage t))) diff --git a/src/package.lisp b/src/package.lisp index 3cc5b0d..662290e 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1,4 +1,9 @@ (uiop:define-package #:40ants-asdf-system (:use #:cl) - (:nicknames #:40ants-asdf-system/system)) + (:nicknames #:40ants-asdf-system/system) + (:import-from #:asdf/interface + #:40ants-asdf-system) + (:export #:40ants-asdf-system + #:path-to-changelog + #:path-to-readme)) diff --git a/src/readme.lisp b/src/readme.lisp new file mode 100644 index 0000000..80e2b94 --- /dev/null +++ b/src/readme.lisp @@ -0,0 +1,11 @@ +(in-package #:40ants-asdf-system) + + +(defun retrieve-system-readme (system) + (let* ((filename (let ((path (path-to-readme system))) + (etypecase path + (string (uiop:parse-unix-namestring path)) + (pathname path)))) + (full-path (asdf:system-relative-pathname system filename))) + (when (probe-file full-path) + (uiop:read-file-string full-path)))) diff --git a/src/system.lisp b/src/system.lisp index 714e6ef..396e400 100644 --- a/src/system.lisp +++ b/src/system.lisp @@ -2,32 +2,35 @@ (defclass asdf/interface::40ants-asdf-system (asdf/interface:package-inferred-system) - ((version-from-changelog :initform nil - :type (or null string) - :reader asdf:component-version - :documentation "This slot is used instead of asdf/component:version because it is overwritten by ASDF function parse-component-form and there is no other way to save a version from the changelog.")) + ((path-to-changelog :initform "docs/changelog.lisp" + :initarg :path-to-changelog + :type (or string pathname) + :documentation "System relative path to a changelog, if string is given, then it will be processed using uiop:parse-unix-namestring function." + :reader path-to-changelog) + (path-to-readme :initform "README.md" + :initarg :path-to-readme + :type (or string pathname) + :documentation "System relative path to a README.md, if string is given, then it will be processed using uiop:parse-unix-namestring function." + :reader path-to-readme)) (:documentation "This ASDF system class takes it's version from src/changelog.lisp")) -(defmethod shared-initialize :after ((system asdf/interface::40ants-asdf-system) slot-names &rest rest) - (declare (ignore rest slot-names)) - (unless (asdf:component-version system) - (let ((filenames (list (make-pathname :directory (list :relative "src") - :name "changelog" - :type "lisp") - (make-pathname :directory (list :relative "src" "doc") - :name "changelog" - :type "lisp") - (make-pathname :directory (list :relative "docs") - :name "changelog" - :type "lisp") - (make-pathname :name "changelog" - :type "lisp")))) - (loop for filename in filenames - for full-path = (asdf:system-relative-pathname system filename) - when (probe-file full-path) - do (let ((version (extract-version-from-changelog full-path))) - (when version - (setf (slot-value system 'version-from-changelog) - version))))))) +(defmethod asdf:operate :after ((op asdf:define-op) (system asdf/interface::40ants-asdf-system) &rest rest) + (declare (ignore rest)) + (let ((version nil)) + (flet ((get-version () + (or version + (setf version + (retrieve-system-version system))))) + (unless (asdf:component-version system) + (setf (asdf:component-version system) + (get-version))) + + (unless (asdf:system-version system) + (setf (slot-value system 'asdf:version) + (get-version))) + + (unless (asdf:system-long-description system) + (setf (slot-value system 'asdf::long-description) + (retrieve-system-readme system)))))) diff --git a/src/version.lisp b/src/version.lisp index 4208572..5cf041d 100644 --- a/src/version.lisp +++ b/src/version.lisp @@ -21,3 +21,13 @@ (version-symbol (car version-form)) (version (symbol-name version-symbol))) version)))) + + +(defun retrieve-system-version (system) + (let* ((filename (let ((path (path-to-changelog system))) + (etypecase path + (string (uiop:parse-unix-namestring path)) + (pathname path)))) + (full-path (asdf:system-relative-pathname system filename))) + (when (probe-file full-path) + (extract-version-from-changelog full-path)))) diff --git a/t/core.lisp b/t/core.lisp new file mode 100644 index 0000000..59e8193 --- /dev/null +++ b/t/core.lisp @@ -0,0 +1,17 @@ +(uiop:define-package #:40ants-asdf-system-tests/core + (:use #:cl) + (:import-from #:40ants-asdf-system + #:retrieve-system-version) + (:import-from #:rove + #:testing + #:ok + #:deftest)) +(in-package #:40ants-asdf-system-tests/core) + + +(deftest test-version-extraction + (testing "Checking if it is possible to extract version from our changelog" + (asdf:load-asd (asdf:system-relative-pathname (asdf:registered-system "40ants-asdf-system") + (uiop:parse-unix-namestring "t/test-40ants-system.asd"))) + (ok (equal (retrieve-system-version (asdf:find-system "test-40ants-system")) + "0.2.0")))) diff --git a/t/test-40ants-system.asd b/t/test-40ants-system.asd new file mode 100644 index 0000000..d10d1bd --- /dev/null +++ b/t/test-40ants-system.asd @@ -0,0 +1,4 @@ +(defsystem "test-40ants-system" + :class :40ants-asdf-system + :defsystem-depends-on ("40ants-asdf-system") + :path-to-changelog "test-changelog.lisp" ) diff --git a/t/test-changelog.lisp b/t/test-changelog.lisp new file mode 100644 index 0000000..f4663f4 --- /dev/null +++ b/t/test-changelog.lisp @@ -0,0 +1,12 @@ +(uiop:define-package #:test-40ants-system/changelog + (:use #:cl) + (:import-from #:40ants-doc/changelog + #:defchangelog)) +(in-package #:test-40ants-system/changelog) + + +(defchangelog () + (0.2.0 2022-11-07 + "* Second version") + (0.1.0 2022-08-07 + "* Initial version."))