From 4c897f919c828a276c30245d53fe52ab79eabb92 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:53:52 -0600 Subject: [PATCH 01/55] - readme: add one feature bullet Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.org b/README.org index 329db84..46216b5 100644 --- a/README.org +++ b/README.org @@ -12,6 +12,7 @@ - An [[https://www.youtube.com/watch?v=RQK_DaaX34Q&list=PLEoMzSkcN8oPQtn7FQEF3D7sroZbXuPZ7][elisp]] package - Bytecode compiling, linting, and test running +- Commands to handle common elisp development gotchas - CI with [[https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs][Github Actions]], configured for Darwin (MacOS) and Linux - [[https://nixos.org/#examples][Nix]] environment for obtaining dependencies or reproducibly developing CI locally @@ -26,6 +27,7 @@ answer all the questions. ** Install elisp-repo-kit #+begin_src elisp + (use-package elisp-repo-kit) ;; straight-use-package-by-default t and you want a git version From 55faf3d6371b10a1775397c62f13fb17c8969531 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:54:32 -0600 Subject: [PATCH 02/55] elpaca installation hunk Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.org b/README.org index 46216b5..70d759c 100644 --- a/README.org +++ b/README.org @@ -39,7 +39,14 @@ answer all the questions. (straight-use-package '(elisp-repo-kit :type git :host github :repo "positron-solutions/elisp-repo-kit")) + ;; using elpaca (recommended to add a hash for reproducibility) + (elpaca-use-package + (example :host github + :repo "positron-solutions/elisp-repo-kit") + :demand t) + ;; or use melpa, manual load-path & require, you brave yak shaver + #+end_src =elisp-repo-kit-new= will ask for: From 865a0e4b25035619768452b395d9de34ede9dc81 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:55:07 -0600 Subject: [PATCH 03/55] Improved accuracy of DCO explanation IANAL. This was a good faith attempt to capture the information from the DCO itself and FSF's own statements about the DCO, but de-distorted to match a realist framing. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/README.org b/README.org index 70d759c..b66987e 100644 --- a/README.org +++ b/README.org @@ -337,21 +337,22 @@ are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. * Licensing, Developer Certificate of Origin This project is distributed with a Developer Certificate of Origin. By adding - a sign-off notice to each commit, and by signing each commit, you will provide - means to authenticate your sign-off later, prevent forgery, and enforce the - DCO & License. + a sign-off notice and GPG signature to each commit, you will provide means to + authenticate your sign-off later strengthening your attestations stated in the + DCO, upholding the overall integrity of the license coverage over the project. If you fail to implement this scheme, Emacs core will have significant reasons not to directly merge changes that accumulate in your package because there - will not be a clear chain of authorship. + will not be a clear attestation of authority to submit changes under the terms + of your project's license. ** License This template project is distributed with the MIT license. Running the rename command will automatically switch to the GPL license. *The MIT license allows re-licensing, and so this change is compatible.* If you accept - non-trivial changes to your project, it will be very hard to change the GPL3 - later, so consider this choice. + non-trivial changes to your project, it will be very hard to change to the + GPL3 later, so consider this choice. ** Developer Certificate of Origin (DCO) @@ -372,11 +373,8 @@ are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. A GPG signed commit shows that the owner of the private key submitted the changes. Wherever signatures are recorded in chains, they can demonstrate participation in changes elsewhere and awareness of what the submitter is - participating in. While forgeries could still allow plagiarized changes to - be submitted, revealing this would cause the submitter to face legal - exposure, and so it is unlikely that the authenticity of a forgery will ever - be proven by the submitter, even though they have clearly provided the means - of incontrovertibly doing so. + participating in. Corroborating user's signature accross a history of works + strengthens that user's attestation provided by DCO sign-off. *** User setup for submitting changes @@ -547,21 +545,30 @@ Changes will likely be rejected if it is aimed at: - [[https://github.com/alphapapa][alphapapa]] for being super prolific at everything, including package writing, documentation, and activity on various social platforms - [[https://github.com/adisbladis][adisbladis]] for the Nix overlay that makes the CI and local development so nice -- [[https://www.fsf.org/][FSF]] for the Yak shaving club - [[https://github.com/NobbZ][NobbZ]] for being all over the Nix & Emacs interwebs +- [[https://www.fsf.org/][FSF]] and all contributors to Emacs & packages for the Yak shaving club * Footnote on FSF and Emacs Core Licensing -Free Software Foundation currently requires copyright assignment on all code -that goes into Emacs core. Many GNU projects have since switched to using a -Developer Certificate of Origin. DCO sign-off is a practice accepted by git, -GCC, and the [[https://wiki.linuxfoundation.org/dco][Linux Kernel]]. Doing DCO sign-off is not the same as copyright -assignment, and serves a slightlly different purpose. DCO is more defensive of -/any/ users while copyright assignment is offensive in the case of GPL -non-compliance. In any case, with DCO sign-off, you can be assured that changes -submitted to a code base you control are incontrovertibly covered by the license -you chose. Using the DCO *may* make it easier for code in your project to be -included in Emacs core later. + Free Software Foundation (FSF) frequently requires copyright assignment on all + code that goes into Emacs core. Many GNU projects have since switched to using + a Developer Certificate of Origin. DCO sign-off is a practice accepted by + git, GCC, and the [[https://wiki.linuxfoundation.org/dco][Linux Kernel]]. + + Doing DCO sign-off is not the same as copyright assignment, and serves a + slightly different purpose. DCO sign-off is an attestation from the submitter + stating that they have sufficient direct or transitive authority make their + submission under the terms of the license of the recieving project. Copyright + assignment serves a more offensive role in the case of GPL non-compliance, + giving FSF alone legal standing. If you don't care about FSF being able to + sue people, the DCO should suffice. + + Using the DCO *may* make it easier for code in your project to be included in + Emacs core later. *It is the intent of this choice to steer FSF towards + DCO-like solutions in order to accelerate code flow into Emacs.* Regardless of + FSF's ongoing position on use of DCO's, by requiring DCO sign-off and GPG + signature, you can be assured that changes submitted to a code base you + control are strongly attested to be covered by the license you chose. # Local Variables: # eval: (require 'org-make-toc) From d650b572105ab7df7f57c6f4a0cacd6137307937 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:56:57 -0600 Subject: [PATCH 04/55] more reliable make toc footer Not everyone will have org-make-toc installed Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.org b/README.org index b66987e..c28674f 100644 --- a/README.org +++ b/README.org @@ -571,8 +571,7 @@ Changes will likely be rejected if it is aimed at: control are strongly attested to be covered by the license you chose. # Local Variables: -# eval: (require 'org-make-toc) -# before-save-hook: org-make-toc +# before-save-hook: (when (require 'org-make-toc nil t) (org-make-toc)) # org-export-with-properties: () # org-export-with-title: t # End: From d52910c8a7f35d883ab0100a6449452b30a0566c Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 09:57:21 -0600 Subject: [PATCH 05/55] Lol yes, please add Guix support Not sure what I was thinking here. Probably just avoiding complexity, but I think either style of providing local development tools and running CI should be fine. Out of the box, both systems should "just work". We can likely support selecting which actions to use with some knobs in the Github UI. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index c28674f..4281e1d 100644 --- a/README.org +++ b/README.org @@ -525,6 +525,7 @@ entirely different. Non-exhaustive list of changes that are very welcome: - Expose trivial options where a structural choice has limited them unnecessarily - Behave the same, but with a less complicated code +- Guix support Changes will likely be rejected if it is aimed at: @@ -534,11 +535,7 @@ Changes will likely be rejected if it is aimed at: - Backwards compatibility for Emacs two versions behind next release. Master, current stable release, and release - 1 are the only versions being supported - pre-flake Nix support -- Guix support without proper lockfile commonality between Emacs, Nix, and Guix. - All pure build systems are good, but if Emacs, Nix, and Guix are not *yet* - benefitting from a common lock format to describe what dependencies will be - obtained, it's not time to support them alongside each other in a single - repository +- Guix support that interferes with Nix support * Shout-outs From 83cd237aac13a61e61ff6b43d8ce4c658b74b6f0 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:00:50 -0600 Subject: [PATCH 06/55] - minor verbeage Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 4281e1d..408dfba 100644 --- a/README.org +++ b/README.org @@ -502,9 +502,9 @@ and how they relate to each other. [[https://github.com/purcell/nix-emacs-ci][nix-emacs-ci]] capture the work needed to provide a running Emacs to CI. Tools like [[https://github.com/doublep/eldev#continuous-integration][eldev]] and [[https://github.com/alphapapa/makem.sh/blob/master/test.yml][makem.sh]] have support for providing dependencies to that Emacs. The Nix flake [[./flake.nix][in this project]] describes both of these tasks. Makem and Eldev -etc document Gihub workflows, but the workflows in this repository are meant to -be used out-of-the-box after cloning, although to be fare, this is very little -work. +etc document Gihub workflows, but *the workflows in this repository are meant to +be used out-of-the-box after cloning*, although to be fair, there's more +decisions than actual work. Nix-emacs-ci provides a lot of backwards-compatibility versions of Emacs. The nix-overlay is more forward looking, providing =emacsGit= and sometimes other From 709aad4c0a8e1bfe34fd191182bc5254b80e7677 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:21:50 -0600 Subject: [PATCH 07/55] shorter action name for some UI's Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/dco.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml index 280c372..18dcae0 100644 --- a/.github/workflows/dco.yml +++ b/.github/workflows/dco.yml @@ -24,7 +24,7 @@ # The check is added as a shield to the project's README.org so that all can see # the license check for the entire commit history. -name: Developer Certificate of Origin Check +name: DCO Check on: pull_request: From 8c8c73070535479fd2f0a79614669fdabd52999c Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:22:15 -0600 Subject: [PATCH 08/55] update nixpkgs branch Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 5a19097..3cd39aa 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,7 @@ # stable branches are recommended for CI, regression spotting. Testing with # multiple versions can be done via input overrides, such as: # nix build .#ci --override-input nixpkgs github:nixpkgs/nixpkgs/unstable - nixpkgs.url = "github:nixos/nixpkgs?ref=release-22.05"; + nixpkgs.url = "github:nixos/nixpkgs?ref=release-22.11"; flake-utils.url = "github:numtide/flake-utils"; emacs-overlay.url = "github:nix-community/emacs-overlay"; # slave Emacs overlay to our nixpkgs. This doesn't do a lot except reduce From ba5934f9a4d14d62bca047bdd4193f1f23041b24 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:22:47 -0600 Subject: [PATCH 09/55] Update flake with newer Emacs versions Also mention how to explore these attributes from the overlay. Seems like buttercut started working, so leaving the comment about buttercup and elsa for now. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- flake.nix | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 3cd39aa..be1563e 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,11 @@ with inputs; flake-utils.lib.eachDefaultSystem (system: let + + # instantaite nixpkgs with the emacs overlay applied. + # to explore available attributes, you can instantiate nixpkgs with the emacs overlay in a nix repl: + # pkgs = import (builtins.getFlake "nixpkgs") { system = builtins.currentSystem; overlays = [ (builtins.getFlake ("emacs-overlay")).overlay ];} + # pkgs.emacs will tab complete pkgs = import nixpkgs { inherit system; overlays = [ emacs-overlay.overlay ]; @@ -49,38 +54,47 @@ # List of Emacsen to generate development shells for emacsPackages = [ - # from emacs-overlay "emacsUnstable" - "emacsNativeComp" - # from nixpkgs "emacsGit" - "emacs" "emacs28" + "emacs" ]; # let's have a development shell per Emacs! devShells = pkgs.lib.genAttrs emacsPackages (emacsPkg: pkgs.mkShell { packages = [ + # pkgs, contains many dependencies you can provide to your elisp + # programs. Search for packages here: + # https://search.nixos.org/packages + pkgs.git # for elisp-repo-kit-clone. # https://github.com/nix-community/emacs-overlay # The emacs overlay provides up-to-date snapshots of Melpa packages. # These will be pure & pinned, so you need to update the flake lock # or use appropriate options. - + # + # This expression builds an Emacs that loads the packages passed + # to emacsWithPackages on startup. ((pkgs.emacsPackagesFor pkgs.${emacsPkg}).emacsWithPackages (epkgs: [ - # List your dependencies here: - - # you can remove after your package no longer calls (require 'dash) - epkgs.melpaPackages.dash + # List your project's dependencies here: + # epkgs.melpaPackages.dash # epkgs.melpaStablePackages.dash # epkgs.elpaPackages.dash # epkgs.dash # Development dependencies + epkgs.elpaPackages.relint epkgs.melpaPackages.elisp-lint + # epkgs.melpaPackages.buttercup # XXX finish after #218 on buttercup + # epkgs.melpaPackages.elsa # XXX did not work out of the box + + # Dependencies of elisp-repo-kit itself. These are no longer + # needed by your repo after cloning. + epkgs.elpaPackages.project + epkgs.melpaPackages.auto-compile ])) ]; }); @@ -92,6 +106,6 @@ # Augment the devShells with a default so that `nix develop` knows what # to do. Run `nix flake show` to see the results. Per-system, # per-Emacs, we have a development environment avaialble. - devShells = devShells // { default = devShells.emacsNativeComp; }; + devShells = devShells // { default = devShells.emacsGit; }; }); } From 7a888b71240ba93751cfc96f76da793f55ec6ca6 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:24:42 -0600 Subject: [PATCH 10/55] update generated Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 78d7943..adbb7aa 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1654922535, - "narHash": "sha256-Hkvx8JWxOrIaEgnUXm2CVMhp+5BaIO8FMJJayapxP7w=", + "lastModified": 1670494225, + "narHash": "sha256-Pb4ZfjIxBznbfTsWEkYc2FVB41yyfqh20nhmLk67LuI=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "ae1a1774095fae839ca2da8ef9d1bedcc33f3f9b", + "rev": "269cf7633d51bd316e00ba35467e8a5f5136d28c", "type": "github" }, "original": { From cad365207cb2a3a64a9f72111b696e4ff1d0f2f0 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 01:51:57 -0600 Subject: [PATCH 11/55] Combine testing and lints into one paramaterized elisp script Saves on load-path and other script infrastructure. CI just uses one program with a command verb. Load paths use the current-directory, which will normalize to load-file-name's directory if possible. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-lint-tests.el | 82 ------------------ test/elisp-repo-kit-lint.el | 83 ------------------ test/elisp-repo-kit-test-setup.el | 76 ---------------- test/run-shim.el | 139 ++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 241 deletions(-) delete mode 100644 test/elisp-repo-kit-lint-tests.el delete mode 100644 test/elisp-repo-kit-lint.el delete mode 100644 test/elisp-repo-kit-test-setup.el create mode 100644 test/run-shim.el diff --git a/test/elisp-repo-kit-lint-tests.el b/test/elisp-repo-kit-lint-tests.el deleted file mode 100644 index a200d73..0000000 --- a/test/elisp-repo-kit-lint-tests.el +++ /dev/null @@ -1,82 +0,0 @@ -;;; elisp-repo-kit-test-setup.el --- Setup and execute all tests - -;; Copyright (C) 2022 Positron Solutions - -;; Author: - -;; Permission is hereby granted, free of charge, to any person obtaining a copy of -;; this software and associated documentation files (the "Software"), to deal in -;; the Software without restriction, including without limitation the rights to -;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -;; the Software, and to permit persons to whom the Software is furnished to do so, -;; subject to the following conditions: - -;; The above copyright notice and this permission notice shall be included in all -;; copies or substantial portions of the Software. - -;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -;; FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -;; COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -;; IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -;;; Commentary: - -;; This package uses elisp-lint to look for byte compile issues or poor code -;; formatting. -;; -;; Usage: -;; -;; Always get a fresh Emacs for your test runs. It will reload features and -;; byte compile where necessary. The Emacs provided by the nix develop shell -;; contains the dependencies declared in the flake.nix. -;; -;; nix develop -;; "emacs" --quick --script test/elisp-repo-kit-test-lint.el -;; -;; elisp-lint will respect many current default settings. Many Emacs -;; preferences are properly reflected in the lint output. - -;;; Code: - -(require 'elisp-lint) - -;; Use this file's directory as default directory so that lisp file locations -;; are fixed with respect to this file. -(setq default-directory (file-name-directory load-file-name)) -;; Add the location of elisp-repo-kit to the load path -(dolist (dir '("../lisp" "../test")) - (let ((dir (concat default-directory dir))) - (add-to-list 'load-path dir))) - -(setq inhibit-startup-screen t) -(prefer-coding-system 'utf-8) - -;; 100-character column limit for lints. If it's good enough for Linux, it's -;; good enough for us. https://lkml.org/lkml/2020/5/29/1038 -(setq-default fill-column 100) -;; Spaces -(setq-default indent-tabs-mode nil) - -;; `command-line-args-left has the same effect as passing command line arguments. -(let ((command-line-args-left - (append - '("--no-package-lint" - ;; "--no- - ;; "--no-byte-compile" - ;; "--no-checkdoc" - ;; "--no-check-declare" - ) - (seq-filter - (lambda (s) (not (string-match-p ".*autoloads.*\.el$" s))) - (file-expand-wildcards "../test/*.el"))))) - - ;; (setq elisp-lint-ignored-validators nil - ;; elisp-lint-file-validators nil - ;; elisp-lint-buffer-validators nil - ;; elisp-lint-batch-files nil) - - (elisp-lint-files-batch)) - -;;; elisp-repo-kit-lint-tests.el ends here diff --git a/test/elisp-repo-kit-lint.el b/test/elisp-repo-kit-lint.el deleted file mode 100644 index 6607cd1..0000000 --- a/test/elisp-repo-kit-lint.el +++ /dev/null @@ -1,83 +0,0 @@ -;;; elisp-repo-kit-test-setup.el --- Setup and execute all tests - -;; Copyright (C) 2022 Positron Solutions - -;; Author: - -;; Permission is hereby granted, free of charge, to any person obtaining a copy of -;; this software and associated documentation files (the "Software"), to deal in -;; the Software without restriction, including without limitation the rights to -;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -;; the Software, and to permit persons to whom the Software is furnished to do so, -;; subject to the following conditions: - -;; The above copyright notice and this permission notice shall be included in all -;; copies or substantial portions of the Software. - -;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -;; FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -;; COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -;; IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -;;; Commentary: - -;; This package uses elisp-lint to look for byte compile issues or poor code -;; formatting. -;; -;; Usage: -;; -;; Always get a fresh Emacs for your test runs. It will reload features and -;; byte compile where necessary. The Emacs provided by the nix develop shell -;; contains the dependencies declared in the flake.nix. -;; -;; nix develop -;; "emacs" --quick --script test/elisp-repo-kit-test-lint.el -;; -;; elisp-lint will respect many current default settings. Many Emacs -;; preferences are properly reflected in the lint output. - -;;; Code: - -(require 'elisp-lint) - -;; Use this file's directory as default directory so that lisp file locations -;; are fixed with respect to this file. -(setq default-directory (file-name-directory load-file-name)) -;; Add the location of elisp-repo-kit to the load path -(dolist (dir '("../lisp" "../test")) - (let ((dir (concat default-directory dir))) - (add-to-list 'load-path dir))) - -(setq inhibit-startup-screen t) -(prefer-coding-system 'utf-8) - -;; 100-character column limit for lints. If it's good enough for Linux, it's -;; good enough for us. https://lkml.org/lkml/2020/5/29/1038 -(setq-default fill-column 100) -;; Spaces -(setq-default indent-tabs-mode nil) - -;; `command-line-args-left has the same effect as passing command line arguments. -(let ((command-line-args-left - (append - '(;; "--no- - ;; "--no-byte-compile" - ;; "--no-checkdoc" - ;; "--no-check-declare" - ) - (seq-filter - (lambda (s) (not (string-match-p ".*autoloads.*\.el$" s))) - (file-expand-wildcards "../lisp/*.el"))))) - - (message "ARGS: %s" command-line-args-left) - - ;; (setq elisp-lint-ignored-validators nil - ;; elisp-lint-file-validators nil - ;; elisp-lint-buffer-validators nil - ;; elisp-lint-batch-files nil) - - (elisp-lint-files-batch)) - -;;; elisp-repo-kit-lint.el ends here diff --git a/test/elisp-repo-kit-test-setup.el b/test/elisp-repo-kit-test-setup.el deleted file mode 100644 index 7a8ddff..0000000 --- a/test/elisp-repo-kit-test-setup.el +++ /dev/null @@ -1,76 +0,0 @@ -;;; elisp-repo-kit-test-setup.el --- Setup and execute all tests - -;; Copyright (C) 2022 Positron Solutions - -;; Author: - -;; Permission is hereby granted, free of charge, to any person obtaining a copy of -;; this software and associated documentation files (the "Software"), to deal in -;; the Software without restriction, including without limitation the rights to -;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -;; the Software, and to permit persons to whom the Software is furnished to do so, -;; subject to the following conditions: - -;; The above copyright notice and this permission notice shall be included in all -;; copies or substantial portions of the Software. - -;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -;; FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -;; COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -;; IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -;;; Commentary: - -;; This package sets up load paths and then loads the test files. -;; -;; Usage: -;; -;; Always get a fresh Emacs for your test runs. It will reload features and -;; byte compile where necessary. The Emacs provided by the nix develop shell -;; contains the dependencies declared in the flake.nix. -;; -;; nix develop -;; "emacs" --quick --script test/elisp-repo-kit-test-setup.el -;; -;; Note that this package assumes that some packages are located in -;; specific locations. - -;;; Code: - -(setq inhibit-startup-screen t) -(prefer-coding-system 'utf-8) - -;; This expression normalizes the behavior of --quick --load and --script -;; behavior. If you don't do this, --script will see every argument -;; passed and the arguments from the Nix wrapper to set load paths. -(when (member (car argv) '("-l" "--")) - (print "Normalizing arguments") - (while (not (member (car argv) '("--" nil))) - (print (format "Normalizing arguments, stripped: %s" (pop argv)))) - (pop argv)) - -(defvar elisp-repo-kit-test-setup-directory - (if load-file-name - (file-name-directory load-file-name) - default-directory)) -(setq default-directory elisp-repo-kit-test-setup-directory) - -;; include all directories with lisp we need -(dolist (dir '("../lisp" "../test")) - (let ((dir (concat elisp-repo-kit-test-setup-directory dir))) - (add-to-list 'load-path dir))) - -;; Extra dependencies required in the package are provided to CI & local -;; development by nix. See the flake.nix for more information. - -(require 'ert) ; load test dependency - -(require 'elisp-repo-kit) ; load main feature - -(require 'elisp-repo-kit-test) ; load each test feature - -(ert t) ; run tests - -;;; elisp-repo-kit-test-setup.el ends here diff --git a/test/run-shim.el b/test/run-shim.el new file mode 100644 index 0000000..56a406c --- /dev/null +++ b/test/run-shim.el @@ -0,0 +1,139 @@ +;;; run-shim.el --- -*-no-byte-compile: t; lexical-binding: t -*- + +;; Copyright (C) 2022 Positron Solutions + +;; Author: + +;; Permission is hereby granted, free of charge, to any person obtaining a copy of +;; this software and associated documentation files (the "Software"), to deal in +;; the Software without restriction, including without limitation the rights to +;; use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +;; the Software, and to permit persons to whom the Software is furnished to do so, +;; subject to the following conditions: + +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. + +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +;; FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +;; COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +;; IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +;;; Commentary: + +;; This package sets up load paths and then loads the test files and runs +;; commands depending on the command line arguments. +;; +;; Usage: +;; +;; Always get a fresh Emacs for your test runs. It will reload features and +;; byte compile where necessary. The Emacs provided by the nix develop shell +;; contains the dependencies declared in the flake.nix. +;; +;; nix develop +;; "emacs" --quick --script test/run-shim.el test +;; "emacs" --quick --script test/run-shim.el lint +;; "emacs" --quick --script test/run-shim.el lint-tests +;; +;; Note that this elisp script assumes that some packages are located in +;; specific locations. + +;;; Code: + +;; This expression normalizes the behavior of --quick --load and --script +;; behavior. If you don't do this, --script will see every argument +;; passed and the arguments from the Nix wrapper to set load paths. You can use +;; this to pass extra options to your scripts in the github actions. +(when (member (car argv) '("-l" "--")) + (print "Normalizing arguments") + (while (not (member (car argv) '("--" nil))) + (print (format "Normalizing arguments, stripped: %s" (pop argv)))) + (pop argv)) + +;; Configure load paths +(setq default-directory (or (file-name-directory load-file-name) default-directory)) +(let* ((tests-dir (expand-file-name (concat default-directory "../tests/"))) + (lisp-dir (expand-file-name (concat default-directory "../lisp/")))) + (push tests-dir load-path) + (push lisp-dir load-path)) + +;; running manually may encounter stale .elc +(setq load-prefer-newer t) + +(defun lint-package () + "Lint the files in the package directory." + + (require 'elisp-lint) + ;; 100-character column limit for lints. If it's good enough for Linux, it's + ;; good enough for us. https://lkml.org/lkml/2020/5/29/1038 + (setq-default fill-column 100) + ;; Spaces + (setq-default indent-tabs-mode nil) + + ;; `command-line-args-left has the same effect as passing command line arguments. + (let ((command-line-args-left + (append + '(;; "--no- + ;; "--no-byte-compile" + ;; "--no-checkdoc" + ;; "--no-check-declare" + ) + (seq-filter + (lambda (s) (not (string-match-p ".*autoloads.*\.el$" s))) + (file-expand-wildcards "../lisp/*.el"))))) + + (message "ARGS: %s" command-line-args-left) + + ;; (setq elisp-lint-ignored-validators nil + ;; elisp-lint-file-validators nil + ;; elisp-lint-buffer-validators nil + ;; elisp-lint-batch-files nil) + + (elisp-lint-files-batch))) + +(defun lint-tests () + "Lint the files in the test directory." + + (require 'elisp-lint) + + ;; Use this file's directory as default directory so that lisp file locations + ;; are fixed with respect to this file. + + ;; 100-character column limit for lints. If it's good enough for Linux, it's + ;; good enough for us. https://lkml.org/lkml/2020/5/29/1038 + (setq-default fill-column 100) + ;; Spaces + (setq-default indent-tabs-mode nil) + + ;; `command-line-args-left has the same effect as passing command line arguments. + (let ((command-line-args-left + (append + '("--no-package-lint" + ;; "--no- + ;; "--no-byte-compile" + ;; "--no-checkdoc" + ;; "--no-check-declare" + ) + (seq-filter + (lambda (s) (not (string-match-p ".*autoloads.*\.el$" s))) + (file-expand-wildcards "../test/*.el"))))) + + ;; (setq elisp-lint-ignored-validators nil + ;; elisp-lint-file-validators nil + ;; elisp-lint-buffer-validators nil + ;; elisp-lint-batch-files nil) + + (elisp-lint-files-batch))) + +;; Consume the command and run one of the routines +(setq command (pop argv)) ; nil-safe +(cond ((string= command "test") + (require 'elisp-repo-kit-test) + (ert t)) + ((string= command "lint") (lint-package)) + ((string= command "lint-tests") (lint-tests)) + t (print "Command not recognized. Use test, lint, lint-tests etc.")) + +;;; run-shim.el ends here From fbdf47bc49b0551e4407717183b9f207e73f5695 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 01:58:02 -0600 Subject: [PATCH 12/55] - Prefer elpaca, remove demand Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index 408dfba..af8d09d 100644 --- a/README.org +++ b/README.org @@ -35,15 +35,14 @@ answer all the questions. :straight (elisp-repo-kit :type git :host github :repo "positron-solutions/elisp-repo-kit")) - ;; if straight-use-package-by-default is nil - (straight-use-package '(elisp-repo-kit :type git :host github - :repo "positron-solutions/elisp-repo-kit")) - ;; using elpaca (recommended to add a hash for reproducibility) (elpaca-use-package (example :host github - :repo "positron-solutions/elisp-repo-kit") - :demand t) + :repo "positron-solutions/elisp-repo-kit")) + + ;; if straight-use-package-by-default is nil + (straight-use-package '(elisp-repo-kit :type git :host github + :repo "positron-solutions/elisp-repo-kit")) ;; or use melpa, manual load-path & require, you brave yak shaver From e9ebf0e426925e8470147ba6cbca514e9105c57f Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:05:51 -0600 Subject: [PATCH 13/55] - indentation, spacing mostly Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 432 +++++++++++++++++++++++++++-------------------------- 1 file changed, 224 insertions(+), 208 deletions(-) diff --git a/README.org b/README.org index af8d09d..8555b73 100644 --- a/README.org +++ b/README.org @@ -175,30 +175,30 @@ There should be a warning about stale byte code. * Finish setting up your new Github repo -You can copy this checklist to your org agenda files: - -- [X] Create a repository (from [[#Install elisp-repo-kit][install]] instructions) -- [ ] Create an empty Github repository and check the git remote configuration -- [ ] Set up your git commit signing (and verification so that it's obvious) - *and* [[#sign-off][sign-off]] so that it will be [[#Footnote-on-FSF-and-Emacs-Core-Licensing][straightforward]] for for FSF to pull in your - changes if they later change to DCO instead of copyright assignment. -- [ ] Sign up for [[https://app.cachix.org/][cachix]] and, create a binary cache - with API tokens and public read access -- [ ] Add secrets necessary for your Github actions =CACHIX_AUTH_TOKEN= and - =CACHIX_CACHE_NAME= -- [ ] Enable actions and add the following actions to your allowed actions - list: - - #+begin_src - actions/checkout@v2.4.2, - cachix/cachix-action@v10, - cachix/install-nix-action@v15, - tisonkun/actions-dco@v1.1 - #+end_src + You can copy this checklist to your org agenda files: + + - [X] Create a repository (from [[#Install elisp-repo-kit][install]] instructions) + - [ ] Create an empty Github repository and check the git remote configuration + - [ ] Set up your git commit signing (and verification so that it's obvious) + *and* [[#sign-off][sign-off]] so that it will be [[#Footnote-on-FSF-and-Emacs-Core-Licensing][straightforward]] for for FSF to pull in your + changes if they later change to DCO instead of copyright assignment. + - [ ] Sign up for [[https://app.cachix.org/][cachix]] and, create a binary cache + with API tokens and public read access + - [ ] Add secrets necessary for your Github actions =CACHIX_AUTH_TOKEN= and + =CACHIX_CACHE_NAME= + - [ ] Enable actions and add the following actions to your allowed actions + list: -- [ ] Get your package working, pushed, actions run, and CI badges all green -- [ ] [[#Publishing-to-melpa][Publish]] to MELPA -- [ ] Make a post on the [[https://old.reddit.com/r/emacs/][subreddit]] about your new package + #+begin_src + actions/checkout@v2.4.2, + cachix/cachix-action@v10, + cachix/install-nix-action@v15, + tisonkun/actions-dco@v1.1 + #+end_src + + - [ ] Get your package working, pushed, actions run, and CI badges all green + - [ ] [[#Publishing-to-melpa][Publish]] to MELPA + - [ ] Make a post on the [[https://old.reddit.com/r/emacs/][subreddit]] about your new package ** Optional Steps @@ -212,126 +212,134 @@ You can copy this checklist to your org agenda files: add, require Actions approval for all outside contributors and leave repository permissions at read-only -Cachix is somewhat optional. It's free for open-source projects. It's about as -easy to sign up and generate the token as to remove the step from the Github -actions. + Cachix is somewhat optional. It's free for open-source projects. It's about as + easy to sign up and generate the token as to remove the step from the Github + actions, so you won't save much time by avoiding it. * Publishing to MELPA -If you have green CI, you have already passed many requirements of publishing a -MELPA package. *You still need to build your package and verify your recipe.* -You are going to clone melpa in order to make your PR. You can use the clone to -verify the recipe. + If you have green CI, you have already passed many requirements of publishing a + MELPA package. *You still need to build your package and verify your recipe.* + You are going to clone melpa in order to make your PR. You can use the clone to + verify the recipe. ** Creating the recipe -Fork MELPA personally (not for organization) and clone it to wherever you keep -your upstreams. It's a good idea to separate upstreams from projects you -actively maintain so you can see and delete upstreams when not in use. + Fork MELPA personally (not for organization) and clone it to wherever you keep + your upstreams. It's a good idea to separate upstreams from projects you + actively maintain so you can see and delete upstreams when not in use. -#+begin_src shell - mkdir -p upstream - cd upstream - git clone git@github.com:$GITHUB_USER/melpa.git # replace $GITHUB_USER -#+end_src + #+begin_src shell -Install package-build + mkdir -p upstream + cd upstream + git clone git@github.com:$GITHUB_USER/melpa.git # replace $GITHUB_USER -#+begin_src elisp - (use-package package-build) -#+end_src + #+end_src -=package-build-create-recipe= will give you something like: + Install package-build -#+begin_src elisp -(elisp-repo-kit :fetcher github :repo "positron-solutions/elisp-repo-kit") -#+end_src + #+begin_src elisp + (use-package package-build) + #+end_src + + =package-build-create-recipe= will give you something like: -The following template can be filled in and pull-requested to MELPA to publish. -You don't need to touch ~:files~. The ~commit~ and ~branch~ are optional -depending on how you version / develop / tag your releases. + #+begin_src elisp + (elisp-repo-kit :fetcher github :repo "positron-solutions/elisp-repo-kit") + #+end_src -Copy the recipe into =recipes/elisp-repo-kit= inside your MELPA clone. + The following template can be filled in and pull-requested to MELPA to publish. + You don't need to touch ~:files~. The ~commit~ and ~branch~ are optional + depending on how you version / develop / tag your releases. + + Copy the recipe into =recipes/elisp-repo-kit= inside your MELPA clone. ** Testing package build -Inside the MELPA clone root: + Inside the MELPA clone root: -#+begin_src shell - # Builds the package - make recipes/elisp-repo-kit - # Test sandbox installation (will affect ~/.emacs.d/elpa So much for sandbox ¯\_(ツ)_/¯ - EMACS_COMMAND=$(which emacs) make sandbox INSTALL=elisp-repo-kit -#+end_src + #+begin_src shell + + # Builds the package + make recipes/elisp-repo-kit + # Test sandbox installation (will affect ~/.emacs.d/elpa So much for sandbox ¯\_(ツ)_/¯ + EMACS_COMMAND=$(which emacs) make sandbox INSTALL=elisp-repo-kit + + #+end_src ** Testing stable package build -You need a tag on your default (usually master) branch of your repo, -=positron-solutions/elisp-repo-kit=. Use =git tag -S v0.1.0= and =git push -origin v0.1.0=. You can also just create a release in the Github interface. + You need a tag on your default (usually master) branch of your repo, + =positron-solutions/elisp-repo-kit=. Use =git tag -S v0.1.0= and =git push + origin v0.1.0=. You can also just create a release in the Github interface. -#+begin_src shell - # Test stable builds against your tags - STABLE=t make recipes/elisp-repo-kit -#+end_src + #+begin_src shell + + # Test stable builds against your tags + STABLE=t make recipes/elisp-repo-kit + + #+end_src ** MELPA Lints -Lastly, install [[https://github.com/riscy/melpazoid][melpazoid]] and call =melpazoid= on your main feature. It does -some additional lints. You may need to install =package-lint= if you don't have -it. It's not declared in melpazoid's requirements. Getting the package in Nix -is not easy yet since melpazoid is not yet on Melpa. + Lastly, install [[https://github.com/riscy/melpazoid][melpazoid]] and call =melpazoid= on your main feature. It does + some additional lints. You may need to install =package-lint= if you don't have + it. It's not declared in melpazoid's requirements. Getting the package in Nix + is not easy yet since melpazoid is not yet on Melpa. -#+begin_src elisp - (straight-use-package - '(melpazoid :type git :host github :repo "riscy/melpazoid" :files ("melpazoid/melpazoid.el"))) -#+end_src + #+begin_src elisp -If everything works, you are ready to make a pull request to MELPA. Push your -changes and check all the boxes in the PR template except the one that requires -you to read the instructions. + (straight-use-package + '(melpazoid :type git :host github :repo "riscy/melpazoid" :files ("melpazoid/melpazoid.el"))) + + #+end_src + + If everything works, you are ready to make a pull request to MELPA. Push your + changes and check all the boxes in the PR template except the one that requires + you to read the instructions. * Overview of file contents and structure -/After cloning and renaming,/ you will have a file tree like this: - -#+begin_src shell - ├── .gitignore # ignores for byte compiles, autoloads etc - ├── flake.nix # dependencies for this project - ├── flake.lock # version controlled lock of flake.nix input versions - ├── .envrc # direnv integration with `nix develop` - ├── Makefile # shorcuts for shell operations - │ - ├── README.org # this file - ├── COPYING # a GPL3 license - ├── DCO # Developer Certificate of Origin - │ - ├── .github - │   ├── pull_request_template.md # reminders for PR contributors - │   └── workflows - │   ├── ci.yml # workflow for lints and tests - │   └── dco.yml # workflow to check DCO sign-offs - │ - ├── lisp - │   └── elisp-repo-kit.el # the package - │ - └── test - ├── elisp-repo-kit-lint.el # elisp-lint shim for /lisp - ├── elisp-repo-kit-lint-tests.el # elisp-lint shim for /test - ├── elisp-repo-kit-test.el # ERT unit tests - └── elisp-repo-kit-test-setup.el # test loading shim -#+end_src + /After cloning and renaming,/ you will have a file tree like this: + + #+begin_src shell + ├── .gitignore # ignores for byte compiles, autoloads etc + ├── flake.nix # dependencies for this project + ├── flake.lock # version controlled lock of flake.nix input versions + ├── .envrc # direnv integration with `nix develop` + ├── Makefile # shorcuts for shell operations + │ + ├── README.org # this file + ├── COPYING # a GPL3 license + ├── DCO # Developer Certificate of Origin + │ + ├── .github + │   ├── pull_request_template.md # reminders for PR contributors + │   └── workflows + │   ├── ci.yml # workflow for lints and tests + │   └── dco.yml # workflow to check DCO sign-offs + │ + ├── lisp + │   └── elisp-repo-kit.el # the package + │ + └── test + ├── elisp-repo-kit-lint.el # elisp-lint shim for /lisp + ├── elisp-repo-kit-lint-tests.el # elisp-lint shim for /test + ├── elisp-repo-kit-test.el # ERT unit tests + └── elisp-repo-kit-test-setup.el # test loading shim + #+end_src -* Maintaining your versions +* Maintaining nixpkgs versions -Nixpkgs has a new release about every six months. You can check their [[https://github.com/NixOS/nixpkgs/branches][branches]] -and [[https://github.com/NixOS/nixpkgs/tags][tags]] to see what's current. To get updated dependencies from MELPA, it's -necessary to update the emacs-overlay with =nix flake lock --update-input -emacs-overlay=. You can also specify revs and branches if you need to roll -back. There is a make shortcut: =make flake-update= MacOS tends to get a little -less test emphasis, and so =nixpkgs-darwin-= branches exist and are -required to pass more Darwin tests before merging. This is more stable if you -are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. + Nixpkgs has a new release about every six months. You can check their [[https://github.com/NixOS/nixpkgs/branches][branches]] + and [[https://github.com/NixOS/nixpkgs/tags][tags]] to see what's current. To get updated dependencies from MELPA, it's + necessary to update the emacs-overlay with =nix flake lock --update-input + emacs-overlay=. You can also specify revs and branches if you need to roll + back. There is a make shortcut: =make flake-update= MacOS tends to get a little + less test emphasis, and so =nixpkgs-darwin-= branches exist and are + required to pass more Darwin tests before merging. This is more stable if you + are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. * Licensing, Developer Certificate of Origin @@ -364,7 +372,9 @@ are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. following: #+begin_src + Signed-off-by: Random J Developer + #+end_src *** GPG signature @@ -394,34 +404,39 @@ are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. **** Automatic GPG signing with per-project keys - In order to specify which projects you intend to sign with which keys, you - will want to configure your git client using path-specific configurations. + In order to specify which projects you intend to sign with which keys, you + will want to configure your git client using path-specific configurations. - Configuing git for this can be done with the following directory structure: + Configuing git for this can be done with the following directory structure: + + #+begin_src - #+begin_src /home/rjdeveloper/ ├── .gitconfig └── .gitconfig.d ├── sco-linux-projects.conf ├── other-projects.conf └── gpg-signing-projects.conf - #+end_src - In your root config, ~.gitconfig~, add an =includeIf= directive that will - load the configuration you use for projects you intend to GPG sign commits - for. + #+end_src + + In your root config, ~.gitconfig~, add an =includeIf= directive that will + load the configuration you use for projects you intend to GPG sign commits + for. + + #+begin_src - #+begin_src [includeIf "gitdir:/home/rjdeveloper/**/gpg-signing/**/.git"] path = "~/.gitconfig.d/gpg-signing-projects.conf" - #+end_src - In the ~gpg-signing-projects.conf~ add your GPG signing configuration from - earlier. =sign= adds the GPG signature automatically. File an issue if you - need help with multiple GPG homes or other configurations. + #+end_src + + In the ~gpg-signing-projects.conf~ add your GPG signing configuration from + earlier. =sign= adds the GPG signature automatically. File an issue if you + need help with multiple GPG homes or other configurations. + + #+begin_src - #+begin_src [user] name = "Random J Developer" email = "random@developer.example.org" @@ -430,119 +445,120 @@ are on MacOS. =nixpkgs-unstable= or =master= are your other less common options. [commit] sign = true gpgSign = true - #+end_src + + #+end_src **** Manually signing & adding sign-off - If you don't like these configurations and want to individually indicate you - have read and intend to apply the DCO to your changes, these commands are - equivalent: + If you don't like these configurations and want to individually indicate you + have read and intend to apply the DCO to your changes, these commands are + equivalent: - #+begin_src bash - git commit -s -S --message "I don't like using .gitconfig" + #+begin_src bash + git commit -s -S --message "I don't like using .gitconfig" - # To clean up a commit - git commit --amend -s -S --no-message + # To clean up a commit + git commit --amend -s -S --no-message - # Combine with rebase to sign / sign-off multiple existing commits - git rebase -i - #+end_src + # Combine with rebase to sign / sign-off multiple existing commits + git rebase -i + #+end_src * Package scope and relation to other work -This repository mainly captures the annoying work necessary to set up a new -repository with everyting working. By focusing on just one minimal task, -cloning itself and renaming, there is very little work a user will need to -identify and remove to reach the clean foundation. + This repository mainly captures the annoying work necessary to set up a new + repository with everyting working. By focusing on just one minimal task, + cloning itself and renaming, there is very little work a user will need to + identify and remove to reach the clean foundation. -Commands within this package will focus on cleaner integration of the tests and -lints with Emacs. There has been a lot of work in this area, but much of it is -tangled with dependency management and sandbox creation. + Commands within this package will focus on cleaner integration of the tests and + lints with Emacs. There has been a lot of work in this area, but much of it is + tangled with dependency management and sandbox creation. ** Dependency Management -Many tools for testing Emacs packages provide dependency management and loading -those dependencies into a fresh Emacs instance. This package will never attempt -to manage dependencies. Dependencies will always be expressed through the Nix -flake expressions and at most a lock file describing a frozen set of Emacs -dependencies. + Many tools for testing Emacs packages provide dependency management and loading + those dependencies into a fresh Emacs instance. This package will never attempt + to manage dependencies. Dependencies will always be expressed through the Nix + flake expressions and at most a lock file describing a frozen set of Emacs + dependencies. -Use of the [[https://github.com/nix-community/emacs-overlay][Emacs Nix Overlay]] is a simple way of stating and obtaining elisp -dependencies for now. Non-elisp dependencies are trivially provided form -nixpkgs. Nix is extremely reliable at dependency management, and it is no -surprise that much complexity is normalized away by just the basic behavior -model of Nix. In addition, *if your project needs or includes additional binary -dependencies or modules*, Nix is an excellent way to provide them to CI and -users. + Use of the [[https://github.com/nix-community/emacs-overlay][Emacs Nix Overlay]] is a simple way of stating and obtaining elisp + dependencies for now. Non-elisp dependencies are trivially provided form + nixpkgs. Nix is extremely reliable at dependency management, and it is no + surprise that much complexity is normalized away by just the basic behavior + model of Nix. In addition, *if your project needs or includes additional binary + dependencies or modules*, Nix is an excellent way to provide them to CI and + users. ** Discovering and Running Tests & Lints -This repository uses very bare elisp that can be run with just one Emacs switch -in most cases. The Makefile merely exposes this interface with the even more -familiar make style of user interaction. + This repository uses very bare elisp that can be run with just one Emacs switch + in most cases. The Makefile merely exposes this interface with the even more + familiar make style of user interaction. -The CI scripts are arranged to present a useful environment first. The commands -to invoke tests follow. If the commands need to be changed, it is -straightforward to change them /independently of how you provide dependencies/. -Just be sure to propagate changes to the Makefile and README of your project. + The CI scripts are arranged to present a useful environment first. The commands + to invoke tests follow. If the commands need to be changed, it is + straightforward to change them /independently of how you provide dependencies/. + Just be sure to propagate changes to the Makefile and README of your project. -Future versions of this project will continue to favor elisp scripts for test -discovery and integration with Emacs. Make and bash will be minimized. + Future versions of this project will continue to favor elisp scripts for test + discovery and integration with Emacs. Make and bash will be minimized. ** Comparisons -There are many comparisons available to understand the roles of similar tools -and how they relate to each other. + There are many comparisons available to understand the roles of similar tools + and how they relate to each other. -- [[https://github.com/alphapapa/makem.sh#comparisons][makem.sh]] -- [[https://github.com/doublep/eldev#see-also][Eldev]] -- [[https://github.com/emacs-twist/nomake][nomake]] Is another project with Nix work + - [[https://github.com/alphapapa/makem.sh#comparisons][makem.sh]] + - [[https://github.com/doublep/eldev#see-also][Eldev]] + - [[https://github.com/emacs-twist/nomake][nomake]] Is another project with Nix work -[[https://github.com/purcell/nix-emacs-ci][nix-emacs-ci]] capture the work needed to provide a running Emacs to CI. Tools -like [[https://github.com/doublep/eldev#continuous-integration][eldev]] and [[https://github.com/alphapapa/makem.sh/blob/master/test.yml][makem.sh]] have support for providing dependencies to that Emacs. -The Nix flake [[./flake.nix][in this project]] describes both of these tasks. Makem and Eldev -etc document Gihub workflows, but *the workflows in this repository are meant to -be used out-of-the-box after cloning*, although to be fair, there's more -decisions than actual work. + [[https://github.com/purcell/nix-emacs-ci][nix-emacs-ci]] capture the work needed to provide a running Emacs to CI. Tools + like [[https://github.com/doublep/eldev#continuous-integration][eldev]] and [[https://github.com/alphapapa/makem.sh/blob/master/test.yml][makem.sh]] have support for providing dependencies to that Emacs. + The Nix flake [[./flake.nix][in this project]] describes both of these tasks. Makem and Eldev + etc document Gihub workflows, but *the workflows in this repository are meant to + be used out-of-the-box after cloning*, although to be fair, there's more + decisions than actual work. -Nix-emacs-ci provides a lot of backwards-compatibility versions of Emacs. The -nix-overlay is more forward looking, providing =emacsGit= and sometimes other -upstream branches when a big feature like native compilation is in the pipeline. -Nix-emacs-ci is also still using legacy Nix, without flakes. Flakes are just -nicer and the way Nix is going. + Nix-emacs-ci provides a lot of backwards-compatibility versions of Emacs. The + nix-overlay is more forward looking, providing =emacsGit= and sometimes other + upstream branches when a big feature like native compilation is in the pipeline. + Nix-emacs-ci is also still using legacy Nix, without flakes. Flakes are just + nicer and the way Nix is going. * Contributing -First decide if you want to work on this repository or fork it to something -entirely different. Non-exhaustive list of changes that are very welcome: - -- To the maximum degree possible, this project should lean on elisp as a CLI - script backend -- Running additional kinds of tests -- Running additional lints -- Fix bugs -- Expose trivial options where a structural choice has limited them - unnecessarily -- Behave the same, but with a less complicated code -- Guix support - -Changes will likely be rejected if it is aimed at: - -- Managing dependencies outside of Nix expressions other than a package that is - supposed to manage dependencies or test obtaining dependencies in a - user-present use case -- Backwards compatibility for Emacs two versions behind next release. Master, - current stable release, and release - 1 are the only versions being supported -- pre-flake Nix support -- Guix support that interferes with Nix support + First decide if you want to work on this repository or fork it to something + entirely different. Non-exhaustive list of changes that are very welcome: + + - To the maximum degree possible, this project should lean on elisp as a CLI + script backend + - Running additional kinds of tests + - Running additional lints + - Fix bugs + - Expose trivial options where a structural choice has limited them + unnecessarily + - Behave the same, but with a less complicated code + - Guix support + + Changes will likely be rejected if it is aimed at: + + - Managing dependencies outside of Nix expressions other than a package that is + supposed to manage dependencies or test obtaining dependencies in a + user-present use case + - Backwards compatibility for Emacs two versions behind next release. Master, + current stable release, and release - 1 are the only versions being supported + - pre-flake Nix support + - Guix support that interferes with Nix support * Shout-outs -- [[https://github.com/alphapapa][alphapapa]] for being super prolific at everything, including package writing, - documentation, and activity on various social platforms -- [[https://github.com/adisbladis][adisbladis]] for the Nix overlay that makes the CI and local development so nice -- [[https://github.com/NobbZ][NobbZ]] for being all over the Nix & Emacs interwebs -- [[https://www.fsf.org/][FSF]] and all contributors to Emacs & packages for the Yak shaving club + - [[https://github.com/alphapapa][alphapapa]] for being super prolific at everything, including package writing, + documentation, and activity on various social platforms + - [[https://github.com/adisbladis][adisbladis]] for the Nix overlay that makes the CI and local development so nice + - [[https://github.com/NobbZ][NobbZ]] for being all over the Nix & Emacs interwebs + - [[https://www.fsf.org/][FSF]] and all contributors to Emacs & packages for the Yak shaving club * Footnote on FSF and Emacs Core Licensing From 7268daceb733cbd5244268a74a2bdcd13de515ec Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:10:31 -0600 Subject: [PATCH 14/55] - Readme updates to loading instruction & file structure Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 127 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 54 deletions(-) diff --git a/README.org b/README.org index 8555b73..fdc3977 100644 --- a/README.org +++ b/README.org @@ -107,71 +107,91 @@ answer all the questions. - [[#footnote-on-fsf-and-emacs-core-licensing][Footnote on FSF and Emacs Core Licensing]] :END: -* Local development instructions +* Use to develop your package + + Elisp repo kit contains some convenience functions to reload your package and + to discover and run ert tests. These shortcuts just make common cases faster. ** Run tests -You can /totally/ run the tests locally on whatever version of Emacs you have. -*You do not need Nix to run tests.* CI will use Nix. If you cannot reproduce a -success (or failure) on CI, then you may want to switch to using nix to get a -reprodicible toolchain so you can further develop with frozen versions from the -nix [[https://nixos.wiki/wiki/Flakes][flake's]] flake.lock. + Run =elisp-repo-kit-ert-project= within your project. The tests in =/test= + will be discovered, rebuilt & reloaded if necessary, and run. There are a + few other commands to augment the [[https://www.gnu.org/software/emacs/manual/html_node/ert/][ert]] package. + +*** Running tests CI style + + If you cannot reproduce a failure (or success) on CI, then you may want to + switch to using nix to get a reprodicible toolchain so you can further + develop with frozen versions from the nix [[https://nixos.wiki/wiki/Flakes][flake's]] flake.lock. -#+begin_src bash - nix develop # loads the devShells.default from flake.nix - direnv allow # same as above with file watching + #+begin_src bash - emacs --quick --load ./test/elisp-repo-kit-test-setup.el # graphical - emacs --script ./test/elisp-repo-kit-test-setup.el # terminal + nix develop # loads the devShells.default from flake.nix + direnv allow # same as above with file watching - make test # shortcut in Makefile -#+end_src + emacs --quick --load ./test/run-shim.el test # graphical + emacs --script ./test/run-test.el test # terminal + + #+end_src -You will want to run =make-clean= in between runs for now. + You can /totally/ run the tests locally on whatever version of Emacs you + have. *You do not need Nix to run tests.* CI will use Nix. ** Lint and byte-compile code -Use [[https://github.com/gonewest818/elisp-lint][elisp-lint]] to detect issues with byte compiling, package format, code -structure and others. The configuration is found inside -[[./test/elisp-repo-kit-test-lint.el][elisp-repo-kit-test-lint.el]] and the CI run is invoked inside of [[.github/workflows/ci.yml][ci.yml]] using -Emacs in script mode. Most of the configuration is in the lisp files. CI only -tests on on one platform, with native compilation enabled. The tests are also -linted, to a less restrictive standard, found in -[[./test/elisp-repo-kit-test-lint-tests.el][elisp-repo-kit-test-lint-tests.el]] + Use [[https://github.com/gonewest818/elisp-lint][elisp-lint]] to detect issues with byte compiling, package format, code + structure and others. -You can run the lints manually almost the same as running tests. -#+begin_src bash - nix develop - emacs --script test/elisp-repo-kit-lint.el - emacs --script test/elisp-repo-kit-lint-tests.el + The configuration is found inside [[./test/run-shim.el][test/run-shim.el]]. The CI run is invoked + inside of [[.github/workflows/ci.yml][ci.yml]] using Emacs in script mode. Most of the configuration is in + the run shim. - make lint # shortcut in Makefile -#+end_src + The tests are also linted, to a less restrictive standard, also found in + [[./test/run-shim.el][run-shim.el]] -Stale bytecode can result in stale test behavior. A Makefile is not yet -available, so just delete all =*.elc= files in /lisp and /test. + You can run the lints manually almost the same as running tests. + #+begin_src bash + + nix develop + # nix develop .#emacs28 + # nix develop .#emacsGit + emacs --script test/run-shim.el lint + emacs --script test/run-shim.el lint-tests + + #+end_src ** Loading and re-loading your package -*When you need to reload the package, call ~unload-feature~ and select your -package name.* If you do not unload, reloading has no effect and you will see -stale behavior. + Run =elisp-repo-kit-reload-project= in one of your project files. All features + in the /lisp directory will be re-compiled and loaded appropriately. + + *Note*, during reloading, unloading the current module is forced. If other + packages you use depend on the project feature, results may be unpredicatable. + This is one reason batch style testing can be preferred. -Whichever package installer you use probably supports local overrides. The -recommendation is [[https://github.com/radian-software/straight.el#overriding-recipes][straight]]. If you install using straight, you can call -=straight-rebuild-package= and it will rebuild and load (but not reload) the -package. +*** Manual Loading & Reloading -#+begin_src elisp - (straight-use-package - '(elisp-repo-kit :local-repo "~/my-packages/positron/elisp-repo-kit")) -#+end_src + Especially in bootstrap situations such as working on this package itself, + you cannot unload the package in the middle of a command. Some commands + have a =no-reload= variant just for this circumstance. -Because the load path is configured, you can call =(unload-feature -'elisp-repo-kit)= and then =(require 'elisp-repo-kit)= to pick up changes. -There should be a warning about stale byte code. + Call ~unload-feature~ and select your package name. If you do not unload, + reloading has no effect and you will see stale behavior. -# NOTE: Reload really needs to be implicit when rebuilding... + When using locally installed packages such as with straight, + =straight-rebuild-pacakge= will rebuild but *not* reload. + + Here's what such a local installation looks like: + + #+begin_src elisp :eval never + + (straight-use-package + '(elisp-repo-kit :local-repo "~/my-packages/positron/elisp-repo-kit")) + + #+end_src + + Because the load path is configured, you can call =(unload-feature + 'elisp-repo-kit)= and then =(require 'elisp-repo-kit)= to pick up changes. * Finish setting up your new Github repo @@ -304,30 +324,29 @@ There should be a warning about stale byte code. /After cloning and renaming,/ you will have a file tree like this: #+begin_src shell + ├── .gitignore # ignores for byte compiles, autoloads etc ├── flake.nix # dependencies for this project ├── flake.lock # version controlled lock of flake.nix input versions ├── .envrc # direnv integration with `nix develop` - ├── Makefile # shorcuts for shell operations │ ├── README.org # this file ├── COPYING # a GPL3 license ├── DCO # Developer Certificate of Origin │ ├── .github - │   ├── pull_request_template.md # reminders for PR contributors - │   └── workflows - │   ├── ci.yml # workflow for lints and tests - │   └── dco.yml # workflow to check DCO sign-offs + │ ├── pull_request_template.md # reminders for PR contributors + │ └── workflows + │ ├── ci.yml # workflow for lints and tests + │ └── dco.yml # workflow to check DCO sign-offs │ ├── lisp - │   └── elisp-repo-kit.el # the package + │ └── elisp-repo-kit.el # the package │ └── test - ├── elisp-repo-kit-lint.el # elisp-lint shim for /lisp - ├── elisp-repo-kit-lint-tests.el # elisp-lint shim for /test ├── elisp-repo-kit-test.el # ERT unit tests - └── elisp-repo-kit-test-setup.el # test loading shim + └── run-shim.el # elisp script with test & lint routines + #+end_src * Maintaining nixpkgs versions From 060cd2b4052849103c2a6a492ed0263f7d28726c Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:20:59 -0600 Subject: [PATCH 15/55] CI, nix version update, -- invocation for command The script consumes all arguments up to the first '--' so that script and quick behave the same Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/ci.yml | 16 +++++++--------- README.org | 8 ++++---- test/run-shim.el | 6 +++--- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b823b46..ce9130e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,8 +40,6 @@ jobs: emacsPkg: [ emacs28, emacsUnstable, # emacsGit - emacsNativeComp, - emacs ] runs-on: ${{ matrix.os }} @@ -72,7 +70,7 @@ jobs: if: matrix.emacsPkg == 'emacs' && matrix.os == 'ubuntu-latest' run: | eval "$(nix print-dev-env \ - --override-input nixpkgs github:nixos/nixpkgs/release-22.05 \ + --override-input nixpkgs github:nixos/nixpkgs/release-22.11 \ --update-input emacs-overlay \ .#${{ matrix.emacsPkg }})" @@ -80,10 +78,10 @@ jobs: ls # Lint the package - emacs --script test/elisp-repo-kit-lint.el + emacs --script test/run-shim.el -- lint # Lint the tests - emacs --script test/elisp-repo-kit-lint-tests.el + emacs --script test/run-shim.el -- lint-tests - name: run tests run: | @@ -99,20 +97,20 @@ jobs: # print-dev-env if [[ $RUNNER_OS == Linux ]]; then eval "$(nix print-dev-env \ - --override-input nixpkgs github:nixos/nixpkgs/release-22.05 \ + --override-input nixpkgs github:nixos/nixpkgs/release-22.11 \ --update-input emacs-overlay \ .#${{ matrix.emacsPkg }})" else eval "$(nix print-dev-env \ - --override-input nixpkgs github:nixos/nixpkgs/nixpkgs-22.05-darwin \ + --override-input nixpkgs github:nixos/nixpkgs/nixpkgs-22.11-darwin \ --update-input emacs-overlay \ .#${{ matrix.emacsPkg }})" fi # Runs the tests in a graphical window (can freeze) - # emacs --quick --load test/elisp-repo-kit-test-setup.el -- $GITHUB_SHA + # emacs --quick --load test/run-shim.el -- test $GITHUB_SHA # Run tests with terminal output and no graphical window ls test - emacs --script test/elisp-repo-kit-test-setup.el -- $GITHUB_SHA + emacs --script test/run-shim.el -- test $GITHUB_SHA diff --git a/README.org b/README.org index fdc3977..e98fd6a 100644 --- a/README.org +++ b/README.org @@ -129,8 +129,8 @@ answer all the questions. nix develop # loads the devShells.default from flake.nix direnv allow # same as above with file watching - emacs --quick --load ./test/run-shim.el test # graphical - emacs --script ./test/run-test.el test # terminal + emacs --quick --load ./test/run-shim.el -- test # graphical + emacs --script ./test/run-test.el -- test # terminal #+end_src @@ -155,8 +155,8 @@ answer all the questions. nix develop # nix develop .#emacs28 # nix develop .#emacsGit - emacs --script test/run-shim.el lint - emacs --script test/run-shim.el lint-tests + emacs --script test/run-shim.el -- lint + emacs --script test/run-shim.el -- lint-tests #+end_src diff --git a/test/run-shim.el b/test/run-shim.el index 56a406c..479b537 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -33,9 +33,9 @@ ;; contains the dependencies declared in the flake.nix. ;; ;; nix develop -;; "emacs" --quick --script test/run-shim.el test -;; "emacs" --quick --script test/run-shim.el lint -;; "emacs" --quick --script test/run-shim.el lint-tests +;; "emacs" --quick --script test/run-shim.el -- test +;; "emacs" --quick --script test/run-shim.el -- lint +;; "emacs" --quick --script test/run-shim.el -- lint-tests ;; ;; Note that this elisp script assumes that some packages are located in ;; specific locations. From f43fa687cd6ce2a340b0d5a81ccabdef10b76191 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:22:57 -0600 Subject: [PATCH 16/55] Introducing test and reloading commands, agnostic naming This commit will be followed on with several cleanup commits. The agnostic naming is so that people can clone the repo and the renaming conventions will telescope forward to the new repository. The reloading and test running convenience functions are for less finicky behavior when developing interactively. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 226 ++++++++++++++++++++++++++++++++++------- 1 file changed, 187 insertions(+), 39 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index bfaaab6..92b321f 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -1,11 +1,11 @@ -;;; elisp-repo-kit.el --- Write a freaking package! -*- lexical-binding: t; -*- +;;; elisp-repo-kit.el --- Github elisp repo kit with bells & whistles -*- lexical-binding: t; -*- ;; Copyright (C) 2022 Positron Solutions ;; Author: ;; Keywords: convenience ;; Version: 0.1.0 -;; Package-Requires: ((emacs "25.1") (dash "2.0")) +;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0")) ;; Homepage: http://github.com/positron-solutions/elisp-repo-kit ;; Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -27,17 +27,44 @@ ;;; Commentary: -;; This package is meant to be destroyed. Delete the Lisp. Delete the tests. -;; Create a new world for yourself. Publish. The commands contained here will -;; download the repo and perform renaming and relicensing. As you may have -;; downloaded this package from MELPA, and as you have witnessed the CI passing, -;; you should already unsterstand that you have walked across the bridge. The -;; license header checks will ensure that whatever Lisp you write or any -;; contributions it attracts may well end up in the Emacs core. +;; Set up Emacs package with Gihub repository configuration, complete with +;; Actions CI, tests, lints, and a licensing scheme all ready to go. Included +;; commands are focused on productivity, appropriate for professional +;; development in elisp. The goal of the package is streamline authoring & +;; distributing new Emacs packages. It provides a well-integrated but rigid +;; scheme, aka opinionated. +;; +;; The package also uses its own hosted source as a substrate for creating new +;; packages. It will clone its source respository and then perform renaming & +;; relicensing. Simply call `elisp-repo-kit-new' to start a new package. The +;; README documents remaining setup steps on Github and in preparation for +;; publishing on MELPA. +;; +;; As a development aid, the package is versatile enough to work on some elisp +;; packages that were not descended from its own source. The scope of +;; functionality is primarily to interface with linting and testing frameworks, +;; both in batch and live workflows. ;;; Code: -(require 'dash) ; see flake.nix for providing dependencies for CI and local development. +(require 'project) ; see flake.nix for providing dependencies for CI and local development. +(require 'auto-compile) + +(defgroup elisp-repo-kit nil "Elisp repository kit.") + +(defcustom elisp-repo-kit-github-package-name "elisp-repo-kit" + "Default Github for cloning templates. +If you rename this repository after forking, you need to set this +to clone from within the fork." + :group 'elisp-repo-kit + :type 'string) + +(defcustom elisp-repo-kit-github-userorg "positron-solutions" + "Default Github for cloning templates. +If you fork this repository, you need to set this to clone it +from within the fork." + :group 'elisp-repo-kit + :type 'string) (defconst elisp-repo-kit--gpl3-notice ";; This program is free software; \ you can redistribute it and/or modify @@ -66,8 +93,133 @@ you can redistribute it and/or modify "test/elisp-repo-kit-lint-tests.el" "test/elisp-repo-kit-test.el" "test/elisp-repo-kit-test-setup.el")) -(defconst elisp-repo-kit--package-name "elisp-repo-kit") -(defconst elisp-repo-kit--github-path "positron-solutions/elisp-repo-kit") + +(defun erk--project-root () + "Return project root or buffer directory." + (let ((project (project-current))) + (or (if (version<= emacs-version "28.0") + (car (with-suppressed-warnings + ((obsolete project-roots)) + (funcall 'project-roots project))) + (funcall 'project-root project)) + default-directory))) + +(defun erk--reload (features dir) + "Reload FEATURES, found in DIR." + (dolist (feature features) + (when (featurep feature) (unload-feature feature 'force))) + (let ((load-path (append elisp-dir load-path)) + (load-prefer-newer t) + (auto-compile-on-load-mode t) + (auto-compile-on-save-mode t) + ;; ask user to save buffers in the current project + (save-some-buffers-default-predicate 'save-some-buffers-root)) + (save-some-buffers) + (dolist (feature features) + (require feature)))) + +(defun erk--dir-features (dir) + "Return list of features provided by elisp files in DIR. +Except autoloads." + (let* ((package-files (directory-files dir nil (rx ".el" string-end))) + (package-files (--reject + (string-match-p (rx "autoloads.el" string-end) it) + package-files))) + (mapcar + (lambda (f) (intern (string-remove-suffix ".el" f))) + package-files))) + +;;;###autoload +(defun erk-reload-project-features () + "Reload the features this project provides. +The implementation assumes all packages pass package lint, +providing a feature that matches the file name. + +This function should attempt not to fail. It is infrastructure +for development, and being lenient for degenerate cases is fine." + (interactive) + (let* ((project-root (erk--project-root)) + (lisp-subdir (concat project-root "/lisp")) + (project-elisp-dir (if (file-exists-p lisp-subdir) lisp-subdir + project-root)) + (package-features (erk--dir-features project-elisp-dir))) + (erk--reload package-features project-elisp-dir))) + +;;;###autoload +(defun erk-reload-project-tests () + "Reload test features that this project provides. +The implementation assumes all packages pass package lint, +providing a feature that matches the file name. + +This function should attempt not to fail. It is infrastructure +for development, and being lenient for degenerate cases is fine." + (interactive) + (let* ((project-root (erk--project-root)) + (lisp-subdir (concat project-root "/test")) + (project-test-dir (if (file-exists-p lisp-subdir) lisp-subdir + project-root)) + (package-features (erk--dir-features project-test-dir))) + (erk--reload package-features project-elisp-dir))) + +;;;###autoload +(defun erk-ert-rerun-this-no-reload () + "Rerun the ert test at point, but don't reaload anything. +Use this when debugging something the tests are consuming or +debugging elisp repo kit itself, which would likely behave +unpredictably if reloaded in the middle of its own function +call." + (interactive) + (save-excursion + (beginning-of-defun) + (let* ((form (funcall load-read-function (current-buffer))) + (name (elt form 1))) + (ert `(member (,name)))))) + +;;;###autoload +(defun erk-ert-rerun-this () + "Rerun the ert test at point. +Will reload all features and test features." + (interactive) + ;; TODO detect if project is dirty and ask to reload + (erk-reload-project-features) + (erk-reload-project-tests) + (save-excursion + (beginning-of-defun) + (let* ((form (funcall load-read-function (current-buffer))) + (name (elt form 1))) + (ert `(member ,(list name)))))) + +(defun erk-ert-project-features () + "List the features defined by the project. +This assumes the convention of one elisp file per feature and +feature name derived file name") + +(defun erk-ert-project-results-buffer () + "Return an ERT buffer name based on project name.") + +(defun erk-ert-project-selector () + "Return a selector for just this project's ERT test. +This selector generates the symbols list before that selector +will run, so new features or new symbols only avaialble after +reload will not be picked up. Run this after any necessary +feature reloading." + (let ((project-test-symbols + (mapcan (erk-ert-project-features) #'feature-symbols))) + (list 'satisfies (lambda (test) (member test project-test-symbols))))) + +;;;###autoload +(defun erk-ert-project () + "Run all ert tests in this project." + (interactive) + (erk-reload-project-features) + (erk-reload-project-tests) + (ert (erk-ert-project-selector))) + +;;;###autoload +(defun erk-modified-command () + "Say some stuff, but don't save this." + (interactive) + (message "thisfis moaod fi lololol even more")) (defun elisp-repo-kit--rename-package (dir old-package new-package) "Rename FILES in DIR. @@ -88,18 +240,25 @@ are renaming. Existing files will be clobbered." (defun elisp-repo-kit--replace-strings (dir package-name author user-org email) "Replace values in files that need renaming or re-licensing. -DIR is where we are reaplacing. PACKAGE-NAME is the new package. +DIR is where we are replacing. PACKAGE-NAME is the new package. AUTHOR will be used in copyright notices. USER-ORG will be used -as the first part of the new github path. EMAIL is shown after AUTHOR in -package headers." +as the first part of the new github path. EMAIL is shown after +AUTHOR in package headers." (let ((default-directory dir) - (github-path (concat user-org "/" package-name))) + (elisp-repo-kit-github-path (concat elisp-repo-kit-github-userorg "/" + elisp-repo-kit-github-package-name)) + (github-path (concat user-org "/" package-name)) + (capitalized-package-title + (string-join + (mapcar #'capitalize + (split-string elisp-repo-kit-github-package-name "-")) + " "))) (mapc (lambda (file) (with-current-buffer (find-file-noselect (concat dir file) t t) ;; append new author to copyright (print (format "visiting: %s" (buffer-file-name))) - (when (re-search-forward ";; Copyright.*Positron Solutions" nil t) + (when (re-search-forward ";; Copyright" nil t) (end-of-line) (insert ", " author)) (goto-char (point-min)) @@ -111,34 +270,19 @@ package headers." (replace-match elisp-repo-kit--gpl3-notice)) (goto-char (point-min)) ;; update github paths for README links - (while (re-search-forward "positron-solutions/elisp-repo-kit" nil t) + (while (re-search-forward elisp-repo-kit-github-path nil t) (replace-match github-path)) (goto-char (point-min)) ;; update remaining package name strings - (while (re-search-forward "elisp-repo-kit" nil t) + (while (re-search-forward elisp-repo-kit-github-package-name nil t) (replace-match package-name)) (goto-char (point-min)) - (while (re-search-forward "Elisp Repo Kit" nil t) - (replace-match (string-join - (mapcar #'capitalize (split-string "-" package-name))) " ")) + (while (re-search-forward capitalized-package-title nil t) + (replace-match capitalized-package-title)) (save-buffer 0) (kill-buffer))) elisp-repo-kit--files-with-strings))) -(defun elisp-repo-kit--dash-dep () - "Use dash and verify our dependency is included with Emacs. -See the flake.nix for more information about providing your project dependencies -for CI & local development." - (--map (* it it) '(1 2 3 4))) - -;;;###autoload -(defun elisp-repo-kit-great-job () - "Tell package author they are doing a great job." - (interactive) - (let ((msg "You're doing a great job!")) - (message "%s" msg) - msg)) - ;;;###autoload (defun elisp-repo-kit-clone (clone-root package-name user-org &optional rev) "Clone elisp-repo-kit to CLONE-ROOT and apply rename. @@ -152,8 +296,11 @@ itself, as a quine and for forking as a new template repository." (if-let ((git-bin (executable-find "git"))) (progn (shell-command - (format "cd %s; %s clone https://github.com/positron-solutions/elisp-repo-kit.git %s" - clone-root git-bin package-name)) + (format "cd %s; %s clone https://github.com/%s/%s.git %s" + clone-root git-bin + elisp-repo-kit-github-userorg + elisp-repo-kit-github-package-name + package-name)) (shell-command (format "cd %s/%s" clone-root package-name)) (when rev @@ -163,6 +310,7 @@ itself, as a quine and for forking as a new template repository." (shell-command (format "%s remote add origin git@github.com:%s/%s.git" git-bin user-org package-name)) + ;; return value for renaming (concat clone-root "/" package-name "/")) (error "Could not find git executible"))) @@ -194,7 +342,7 @@ by the author of this repository." (elisp-repo-kit--replace-strings clone-dir package-name author user-org email) (elisp-repo-kit--rename-package - clone-dir elisp-repo-kit--package-name package-name)) + clone-dir elisp-repo-kit-github-package-name package-name)) ;;;###autoload (defun elisp-repo-kit-new (clone-root package-name author user-org email &optional rev) From 7cddf05ec5bf9f6110b5abfb3e272995d94bdc8c Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:27:27 -0600 Subject: [PATCH 17/55] consistency in ERT feature Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-test.el | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index bfcbd28..c8a3692 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -1,4 +1,4 @@ -;;; elisp-repo-kit.el --- write a freaking package! -*- lexical-binding: t; -*- +;;; elisp-repo-kit-test.el --- test your freaking package! -*- lexical-binding: t; -*- ;; Copyright (C) 2022 Positron Solutions @@ -22,21 +22,25 @@ ;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ;;; Commentary: -;; These tests are run by requiring elisp-repo-kit-test-setup. -;;; Code: +;; Run the batch tests from root directory: +;; nix shell .#emacsGit --quick --script test/run-shim.el -- test +;; Test dependencies can be provided to the Emacsen declared inside the root +;; flake.nix. + +;; For local development, dependencies should be installed by the user. Tests +;; can be run from one of the project files using the `elisp-repo-kit-project-ert' +;; command. -(require 'elisp-repo-kit) +;;; Code: -(ert-deftest erk-great-job-test () - "Tests if we are doing a great job." - (should (string-equal (elisp-repo-kit-great-job) "You're doing a great job!"))) +(require 'ert) +(require 'elisp-repo-kit)) -(ert-deftest erk-dash-dep-test () - "Tests that dependencies are included with the provided Emacs. -See the flake.nix for more information about providing your project dependencies -for CI & local development." - (should (equal (elisp-repo-kit--dash-dep) '(1 4 9 16)))) +;; (declare-function erk-ert-dummy "elisp-repo-kit" ()) +;; (ert-deftest erk-ert-dummy-test () +;; "Tests that tests are properly re-run with modified code." +;; (should (equal (erk-ert-dummy) 8))) (ert-deftest erk-clone-and-rename-test () "Clone the repo and rename it, single step." From 5c842272e0e243b9d2dd57929208cf68314126bb Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:28:34 -0600 Subject: [PATCH 18/55] personal habit Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1b95a3e..dd1f1f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .direnv/ **.elc **.el~ -**/*autoloads.el \ No newline at end of file +**/*autoloads.el +**trash From 95e875dbe71f61d9d49cfe9fec7a8b0086c8c618 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:28:53 -0600 Subject: [PATCH 19/55] Note about transitive renaming. Formatting Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.org b/README.org index e98fd6a..c3dba8a 100644 --- a/README.org +++ b/README.org @@ -71,6 +71,9 @@ answer all the questions. you're doing at that point. Call =elisp-repo-kit-rename= on its own to rename in these cases. + There are some customize options that cause the renaming to be transitively + consistent. + * Contents :noexport: :PROPERTIES: :TOC: :include siblings @@ -210,10 +213,12 @@ answer all the questions. list: #+begin_src + actions/checkout@v2.4.2, cachix/cachix-action@v10, cachix/install-nix-action@v15, tisonkun/actions-dco@v1.1 + #+end_src - [ ] Get your package working, pushed, actions run, and CI badges all green From 5d7982ae3dc3ae43b5c9f2d51b046c34e10068f1 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:29:12 -0600 Subject: [PATCH 20/55] Nobody needs a makefile. Come on. Use elisp Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- Makefile | 61 -------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index ca1a229..0000000 --- a/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2022 Positron Solutions - -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -EL_FILES = $(wildcard **/*.el) -ELC_FILES = $(EL_FILES:.el=.elc) - -.PHONY: clean help lint-tests lint-pkg lint flake-etadata flake-update flake-show test -.DEFAULT: help - -help: - $(info make test - run ERT tests) - $(info make lint - lint, bytecode-compile package and tests) - $(info make lint-tests - lint, bytecode-compile tests) - $(info make lint-pkg - lint, bytecode-compile package) - $(info make clean - remove most generated files) - $(info make flake-update - update all nix flake.lock versions) - $(info make flake-metadata - show nix flake inputs tree) - $(info make flake-show - show nix flake outputs set) - @printf "\n" - -clean: - @echo Deleting byte compiled files - @rm -f $(ELC_FILES) - @rm -rf test/clone-rename-test - @rm -f $(wildcard **/*autoloads.el*) - -lint-tests: - @emacs --script test/elisp-repo-kit-lint-tests.el - -lint-pkg: - @emacs --script test/elisp-repo-kit-lint.el - -lint: lint-tests lint-pkg - -test: - @emacs --script test/elisp-repo-kit-test-setup.el - -flake-update: - @nix flake update - -flake-metadata: - @nix flake metadata - -flake-show: - @nix flake show From 85f4df0478969a21fec7509b4ff9a8e36c9bceb0 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:01:36 -0600 Subject: [PATCH 21/55] remove nonexistent files from replace-rename map Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 92b321f..5bfa362 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -82,17 +82,13 @@ you can redistribute it and/or modify (defconst elisp-repo-kit--rename-maps ; directory file hard-replace '(( nil "gpl-3.0.txt" "COPYING") ("lisp/" "elisp-repo-kit.el" nil) - ("test/" "elisp-repo-kit-lint-tests.el" nil) - ("test/" "elisp-repo-kit-lint.el" nil) - ("test/" "elisp-repo-kit-test-setup.el" nil) - ("test/" "elisp-repo-kit-test.el" nil))) + ("test/" "elisp-repo-kit-test.el" nil) + ("test/" "run-shim.el" nil))) (defconst elisp-repo-kit--files-with-strings '("README.org" "lisp/elisp-repo-kit.el" - "test/elisp-repo-kit-lint.el" - "test/elisp-repo-kit-lint-tests.el" "test/elisp-repo-kit-test.el" - "test/elisp-repo-kit-test-setup.el")) + "test/run-shim.el")) (defun erk--project-root () "Return project root or buffer directory." From 1a7d16a2369de5b5b2f592a65ea6eb24e71f86f0 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:17:47 -0600 Subject: [PATCH 22/55] -better semantic symbol names Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 5bfa362..3117051 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -79,7 +79,7 @@ you can redistribute it and/or modify ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see .") -(defconst elisp-repo-kit--rename-maps ; directory file hard-replace +(defconst elisp-repo-kit--rename-maps ; directory file replacement-file '(( nil "gpl-3.0.txt" "COPYING") ("lisp/" "elisp-repo-kit.el" nil) ("test/" "elisp-repo-kit-test.el" nil) @@ -219,19 +219,19 @@ feature reloading." (defun elisp-repo-kit--rename-package (dir old-package new-package) "Rename FILES in DIR. -`elisp-repo-kit--rename-map' is a list of ( name -) triples. When is nil, it means use DIR. -If is nil means replace OLD-PACKAGE with NEW-PACKAGE, -using `replace-regexp-in-string'. DIR is the root of where we -are renaming. Existing files will be clobbered." +`elisp-repo-kit--rename-map' is a list of (subdir filename +replacement-filename) triples. When subdir is nil, it means use +DIR. If replacement-filename is nil means replace OLD-PACKAGE +with NEW-PACKAGE, using `replace-regexp-in-string'. DIR is the +root of where we are renaming. Existing files will be +clobbered." (mapc (lambda (rename-map) (let ((dir (concat dir (or (pop rename-map) ""))) - (name (pop rename-map)) - (hard-replace (pop rename-map))) - (let ((new-name (or hard-replace - (replace-regexp-in-string old-package new-package name)))) - (rename-file (concat dir name) (concat dir new-name) t)) - (print (format "Used lexical variables %s %s" hard-replace rename-map)))) + (filename (pop rename-map)) + (replacement-filename (pop rename-map))) + (let ((new-name (or replacement-filename + (replace-regexp-in-string old-package new-package filename)))) + (rename-file (concat dir filename) (concat dir new-name) t)))) elisp-repo-kit--rename-maps)) (defun elisp-repo-kit--replace-strings (dir package-name author user-org email) From e9b2a09097bc335c0e2f698de882cdf6df67a597 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:28:25 -0600 Subject: [PATCH 23/55] update generated Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- flake.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index adbb7aa..a033b73 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1670494225, - "narHash": "sha256-Pb4ZfjIxBznbfTsWEkYc2FVB41yyfqh20nhmLk67LuI=", + "lastModified": 1670637348, + "narHash": "sha256-4FLOEi02WS+St6i1MSUxGfA32FL1SFIpwWCDsABAZkk=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "269cf7633d51bd316e00ba35467e8a5f5136d28c", + "rev": "3a0b5dd7756173e63c2bbbe70dd5484a7463257d", "type": "github" }, "original": { @@ -40,16 +40,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1654913593, - "narHash": "sha256-EfqUQAFYaocy49twrlz6bsUGTuWoB9HdvDWE1yTNxjg=", + "lastModified": 1670482022, + "narHash": "sha256-xzzjWulnNMCSTEGosGaAg7sLsAtF7stA3sQljZ410/w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cc5a426ba3145a26874925b747e59031bbffbe01", + "rev": "c50e5b63e9d65ff0e70cc06b7042a72c6a6583bc", "type": "github" }, "original": { "owner": "nixos", - "ref": "release-22.05", + "ref": "release-22.11", "repo": "nixpkgs", "type": "github" } From 298f325c05125b482d1d0350a72e538ac9be9d96 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:28:51 -0600 Subject: [PATCH 24/55] load but don't run unless non-interactive or non-x Sorry for those running Emacs without X resources. Loading the file will still try to run the shim. This needed to be done so that errant feature loading wouldn't munge the user's Emacs variables. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/run-shim.el | 83 +++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/test/run-shim.el b/test/run-shim.el index 479b537..4ffc883 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -42,27 +42,7 @@ ;;; Code: -;; This expression normalizes the behavior of --quick --load and --script -;; behavior. If you don't do this, --script will see every argument -;; passed and the arguments from the Nix wrapper to set load paths. You can use -;; this to pass extra options to your scripts in the github actions. -(when (member (car argv) '("-l" "--")) - (print "Normalizing arguments") - (while (not (member (car argv) '("--" nil))) - (print (format "Normalizing arguments, stripped: %s" (pop argv)))) - (pop argv)) - -;; Configure load paths -(setq default-directory (or (file-name-directory load-file-name) default-directory)) -(let* ((tests-dir (expand-file-name (concat default-directory "../tests/"))) - (lisp-dir (expand-file-name (concat default-directory "../lisp/")))) - (push tests-dir load-path) - (push lisp-dir load-path)) - -;; running manually may encounter stale .elc -(setq load-prefer-newer t) - -(defun lint-package () +(defun erk--lint-package () "Lint the files in the package directory." (require 'elisp-lint) @@ -87,13 +67,13 @@ (message "ARGS: %s" command-line-args-left) ;; (setq elisp-lint-ignored-validators nil - ;; elisp-lint-file-validators nil - ;; elisp-lint-buffer-validators nil - ;; elisp-lint-batch-files nil) + ;; elisp-lint-file-validators nil + ;; elisp-lint-buffer-validators nil + ;; elisp-lint-batch-files nil) (elisp-lint-files-batch))) -(defun lint-tests () +(defun erk--lint-tests () "Lint the files in the test directory." (require 'elisp-lint) @@ -121,19 +101,48 @@ (file-expand-wildcards "../test/*.el"))))) ;; (setq elisp-lint-ignored-validators nil - ;; elisp-lint-file-validators nil - ;; elisp-lint-buffer-validators nil - ;; elisp-lint-batch-files nil) + ;; elisp-lint-file-validators nil + ;; elisp-lint-buffer-validators nil + ;; elisp-lint-batch-files nil) (elisp-lint-files-batch))) -;; Consume the command and run one of the routines -(setq command (pop argv)) ; nil-safe -(cond ((string= command "test") - (require 'elisp-repo-kit-test) - (ert t)) - ((string= command "lint") (lint-package)) - ((string= command "lint-tests") (lint-tests)) - t (print "Command not recognized. Use test, lint, lint-tests etc.")) - +(defun erk--run-shim () + "Execute a CI process based on CLI arguments." + ;; This expression normalizes the behavior of --quick --load and --script + ;; behavior. If you don't do this, --script will see every argument + ;; passed and the arguments from the Nix wrapper to set load paths. You can use + ;; this to pass extra options to your scripts in the github actions. + (when (member (car argv) '("-l" "--")) + (print "Normalizing arguments") + (while (not (member (car argv) '("--" nil))) + (print (format "Normalizing arguments, stripped: %s" (pop argv)))) + (pop argv)) + + ;; Configure load paths + (setq default-directory (if load-file-name (file-name-directory load-file-name) + default-directory)) + (let* ((tests-dir (expand-file-name (concat default-directory "../tests/"))) + (lisp-dir (expand-file-name (concat default-directory "../lisp/")))) + (push tests-dir load-path) + (push lisp-dir load-path)) + + ;; running manually may encounter stale .elc + (setq load-prefer-newer t) + + ;; Consume the command argument and run one of the routines + (setq command (pop argv)) ; nil-safe + (cond ((string= command "test") + (require 'elisp-repo-kit-test) + (ert t)) + ((string= command "lint") (erk--lint-package)) + ((string= command "lint-tests") (erk--lint-tests)) + t (print "Command not recognized. Use test, lint, lint-tests etc."))) + +;; Only attempt to run when Emacs is loading with or --batch --no-x-resources, +;; which is implied by -Q. +(when (or noninteractive inhibit-x-resources) + (erk--run-shim)) + +(provide 'run-shim) ;;; run-shim.el ends here From 5b53a210d3c478690c94a210730580d2a0619de0 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:30:52 -0600 Subject: [PATCH 25/55] - package header verbeage Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 3117051..2ddfe48 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -1,4 +1,4 @@ -;;; elisp-repo-kit.el --- Github elisp repo kit with bells & whistles -*- lexical-binding: t; -*- +;;; elisp-repo-kit.el --- Elisp Github repository kit -*- lexical-binding: t; -*- ;; Copyright (C) 2022 Positron Solutions From d0ffa24bd394e131dd46cb834652235428dd63dc Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:31:37 -0600 Subject: [PATCH 26/55] corrected load path append Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 2ddfe48..5bdd60b 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -104,7 +104,7 @@ you can redistribute it and/or modify "Reload FEATURES, found in DIR." (dolist (feature features) (when (featurep feature) (unload-feature feature 'force))) - (let ((load-path (append elisp-dir load-path)) + (let ((load-path (append (list dir) load-path)) (load-prefer-newer t) (auto-compile-on-load-mode t) (auto-compile-on-save-mode t) From e6008f754dc412abfe876bfe91b5ed27a34bb39f Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:53:19 -0600 Subject: [PATCH 27/55] functions to just approximate the features in a project Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 5bdd60b..146958f 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -125,6 +125,18 @@ Except autoloads." (lambda (f) (intern (string-remove-suffix ".el" f))) package-files))) +(defun erk--package-features () + "List the features defined by the project's package. +This assumes the convention of one elisp file per feature and +feature name derived file name" + (erk--dir-features (concat (erk--project-root) "lisp" ))) + +(defun erk--test-features () + "List the features defined in project's test packages. +This assumes the convention of one elisp file per feature and +feature name derived file name" + (erk--dir-features (concat (erk--project-root) "test" ))) + ;;;###autoload (defun erk-reload-project-features () "Reload the features this project provides. From dc47205b16791fe20b460c11bd84febad05d9a69 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:54:06 -0600 Subject: [PATCH 28/55] symbol-features was dropped in 29 recording the state of code before upgrade Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 146958f..33449ce 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -212,8 +212,10 @@ will run, so new features or new symbols only avaialble after reload will not be picked up. Run this after any necessary feature reloading." (let ((project-test-symbols - (mapcan (erk-ert-project-features) #'feature-symbols))) - (list 'satisfies (lambda (test) (member test project-test-symbols))))) + (mapcan #'feature-symbols (erk--test-features)))) + `(satisfies ,(lambda (test) (member + (ert-test-name test) + project-test-symbols))))) ;;;###autoload (defun erk-ert-project () From 00c0fea0b9631ddd219415fc9d14f438f61154d3 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 07:11:12 -0600 Subject: [PATCH 29/55] add dash dependency Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 33449ce..7dce0d5 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -5,7 +5,7 @@ ;; Author: ;; Keywords: convenience ;; Version: 0.1.0 -;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0")) +;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0") (dash "2.18.0") ;; Homepage: http://github.com/positron-solutions/elisp-repo-kit ;; Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -49,6 +49,7 @@ (require 'project) ; see flake.nix for providing dependencies for CI and local development. (require 'auto-compile) +(require 'dash) (defgroup elisp-repo-kit nil "Elisp repository kit.") From 56930c27e043449682e7d2293bb9c5a81cc2f0c6 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 07:11:44 -0600 Subject: [PATCH 30/55] switch to using load-history to find ert tests This had to be done because feature symbols no longer exists. So far all tests created from ERT macros appear to be caught by this selector. The other option was to use the project symbol prefix, but this could fail if the prefix is an initialism or the test is named incorrectly. Using load history should be more robust. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 7dce0d5..9ff2c22 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -212,11 +212,17 @@ This selector generates the symbols list before that selector will run, so new features or new symbols only avaialble after reload will not be picked up. Run this after any necessary feature reloading." - (let ((project-test-symbols - (mapcan #'feature-symbols (erk--test-features)))) - `(satisfies ,(lambda (test) (member - (ert-test-name test) - project-test-symbols))))) + (let* ((test-features (erk--test-features)) + (test-symbols (->> test-features + (-map #'symbol-file) + (--map (cdr (assoc it load-history))) + (-flatten-n 1) + (--filter (eq 'define-symbol-props (car it))) + (-map #'cdr) + (-flatten-n 2)))) + (message "test-symbols: %s" test-symbols) + `(satisfies ,(lambda (test) + (member (ert-test-name test) test-symbols))))) ;;;###autoload (defun erk-ert-project () From 6b8061313dbebfe72d4763cbb1fdda97a4ade062 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 07:15:38 -0600 Subject: [PATCH 31/55] formatting Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 9ff2c22..97df116 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -80,11 +80,13 @@ you can redistribute it and/or modify ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see .") + (defconst elisp-repo-kit--rename-maps ; directory file replacement-file '(( nil "gpl-3.0.txt" "COPYING") ("lisp/" "elisp-repo-kit.el" nil) ("test/" "elisp-repo-kit-test.el" nil) ("test/" "run-shim.el" nil))) + (defconst elisp-repo-kit--files-with-strings '("README.org" "lisp/elisp-repo-kit.el" @@ -119,9 +121,8 @@ you can redistribute it and/or modify "Return list of features provided by elisp files in DIR. Except autoloads." (let* ((package-files (directory-files dir nil (rx ".el" string-end))) - (package-files (--reject - (string-match-p (rx "autoloads.el" string-end) it) - package-files))) + (package-files (->> package-files + (--reject (string-match-p (rx "autoloads.el" string-end) it))))) (mapcar (lambda (f) (intern (string-remove-suffix ".el" f))) package-files))) From 334696540cd7189fb49982c95dd6c33aec68b624 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 07:17:28 -0600 Subject: [PATCH 32/55] small form fixups, verbeage, renaming Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 97df116..eda303b 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -140,7 +140,7 @@ feature name derived file name" (erk--dir-features (concat (erk--project-root) "test" ))) ;;;###autoload -(defun erk-reload-project-features () +(defun erk-reload-project-package () "Reload the features this project provides. The implementation assumes all packages pass package lint, providing a feature that matches the file name. @@ -149,7 +149,7 @@ This function should attempt not to fail. It is infrastructure for development, and being lenient for degenerate cases is fine." (interactive) (let* ((project-root (erk--project-root)) - (lisp-subdir (concat project-root "/lisp")) + (lisp-subdir (concat project-root "lisp")) (project-elisp-dir (if (file-exists-p lisp-subdir) lisp-subdir project-root)) (package-features (erk--dir-features project-elisp-dir))) @@ -165,44 +165,37 @@ This function should attempt not to fail. It is infrastructure for development, and being lenient for degenerate cases is fine." (interactive) (let* ((project-root (erk--project-root)) - (lisp-subdir (concat project-root "/test")) + (lisp-subdir (concat project-root "test")) (project-test-dir (if (file-exists-p lisp-subdir) lisp-subdir - project-root)) + project-root)) (package-features (erk--dir-features project-test-dir))) - (erk--reload package-features project-elisp-dir))) + (erk--reload package-features project-test-dir))) ;;;###autoload (defun erk-ert-rerun-this-no-reload () "Rerun the ert test at point, but don't reaload anything. -Use this when debugging something the tests are consuming or -debugging elisp repo kit itself, which would likely behave -unpredictably if reloaded in the middle of its own function -call." +Use this when debugging with external state or debugging elisp +repo kit itself, which may behave strangely if reloaded in the +middle of a command." (interactive) (save-excursion (beginning-of-defun) (let* ((form (funcall load-read-function (current-buffer))) (name (elt form 1))) - (ert `(member (,name)))))) + (ert `(member ,name))))) ;;;###autoload (defun erk-ert-rerun-this () "Rerun the ert test at point. Will reload all features and test features." (interactive) - ;; TODO detect if project is dirty and ask to reload - (erk-reload-project-features) + (erk-reload-project-package) (erk-reload-project-tests) (save-excursion (beginning-of-defun) (let* ((form (funcall load-read-function (current-buffer))) (name (elt form 1))) - (ert `(member ,(list name)))))) - -(defun erk-ert-project-features () - "List the features defined by the project. -This assumes the convention of one elisp file per feature and -feature name derived file name") + (ert `(member ,name))))) (defun erk-ert-project-results-buffer () "Return an ERT buffer name based on project name.") @@ -229,7 +222,7 @@ feature reloading." (defun erk-ert-project () "Run all ert tests in this project." (interactive) - (erk-reload-project-features) + (erk-reload-project-package) (erk-reload-project-tests) (ert (erk-ert-project-selector))) From b09864a44c6c54e17755aeed28ea6754074878de Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 07:21:41 -0600 Subject: [PATCH 33/55] -lol vestage of testing reloading manually Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index eda303b..50ac3b0 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -226,12 +226,6 @@ feature reloading." (erk-reload-project-tests) (ert (erk-ert-project-selector))) -;;;###autoload -(defun erk-modified-command () - "Say some stuff, but don't save this." - (interactive) - (message "thisfis moaod fi lololol even more")) - (defun elisp-repo-kit--rename-package (dir old-package new-package) "Rename FILES in DIR. `elisp-repo-kit--rename-map' is a list of (subdir filename From c719591dec0b1c2e34dbba2b56d3ec4a3ceec7a7 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 08:29:42 -0600 Subject: [PATCH 34/55] - require typo Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-test.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index c8a3692..1edb211 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -35,7 +35,7 @@ ;;; Code: (require 'ert) -(require 'elisp-repo-kit)) +(require 'elisp-repo-kit) ;; (declare-function erk-ert-dummy "elisp-repo-kit" ()) ;; (ert-deftest erk-ert-dummy-test () From 7fb11a90095327bc03162742d3afa539a9806479 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 08:30:11 -0600 Subject: [PATCH 35/55] add / update some tests this isn't 100% coverage. in order to do better, we can load the current repo and then try to run the tests on a renamed repo to avoid feature bootstrapping problems, when commands unload themselves in the middle of calling them. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-test.el | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index 1edb211..54e1dc9 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -37,23 +37,32 @@ (require 'ert) (require 'elisp-repo-kit) -;; (declare-function erk-ert-dummy "elisp-repo-kit" ()) -;; (ert-deftest erk-ert-dummy-test () -;; "Tests that tests are properly re-run with modified code." -;; (should (equal (erk-ert-dummy) 8))) +(ert-deftest erk--project-root-test () + (should (string-match-p (rx "elisp-repo-kit/" eol) + (erk--project-root)))) + +(ert-deftest erk--dir-features-test () + (should (equal + '(elisp-repo-kit) + (erk--dir-features (concat (erk--project-root) "lisp"))))) + +(ert-deftest erk--package-features-test () + (should (member 'elisp-repo-kit (erk--package-features)))) + +(ert-deftest erk--test-features-test () + (should (member 'elisp-repo-kit-test (erk--test-features)))) (ert-deftest erk-clone-and-rename-test () "Clone the repo and rename it, single step." - (let ((rev (pop argv)) - (clone-root (make-temp-file "elisp-repo-kit" t))) + (let ((rev (getenv "GITHUB_SHA")) + (clone-root (make-temp-file "elisp-repo-kit-clone-test-" t))) (elisp-repo-kit-new clone-root - "clone-rename-test" ; project-name + "clone-rename" ; project-name "Selindis Raszagal" ; Author "new-shakuras" ; user-org "selindis.r@new-shakuras.planet" ; email rev))) ; possibly nil (provide 'elisp-repo-kit-test) - ;;; elisp-repo-kit-test.el ends here. From f8df911c6b21ed38698a4dac8b16415c72589fbe Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:39:05 -0600 Subject: [PATCH 36/55] add ert dependency Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 50ac3b0..e87f4b1 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -4,8 +4,8 @@ ;; Author: ;; Keywords: convenience -;; Version: 0.1.0 -;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0") (dash "2.18.0") +;; Version: 0.2.0 +;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0") (dash "2.18.0") (ert "0")) ;; Homepage: http://github.com/positron-solutions/elisp-repo-kit ;; Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -50,6 +50,7 @@ (require 'project) ; see flake.nix for providing dependencies for CI and local development. (require 'auto-compile) (require 'dash) +(require 'ert) (defgroup elisp-repo-kit nil "Elisp repository kit.") From 61a07f829532bc6068bf6fb95aef4ace68f593e4 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:39:27 -0600 Subject: [PATCH 37/55] interactivity of elisp-repo-kit-new can use git config better prompts, defaults Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index e87f4b1..918ab5e 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -351,21 +351,37 @@ by the author of this repository." clone-dir elisp-repo-kit-github-package-name package-name)) ;;;###autoload -(defun elisp-repo-kit-new (clone-root package-name author user-org email &optional rev) +(defun elisp-repo-kit-new (package-name clone-root author user-org email &optional rev) "Clone elisp-repo-kit, rename, and relicense in one step. -CLONE-ROOT is where you want to clone your package to. -PACKAGE-NAME should be the long name of the package, what will -show up in melpa etc. AUTHOR will be used in copyright notices. -USER-ORG is either your user or organization, which forms the -first part of a github repo path. EMAIL is shown after AUTHOR in -package headers. Optional REV is either a tag, branch or -revision used in git checkout. +CLONE-ROOT is where you want to clone your package to (including +the clone dir). PACKAGE-NAME should be the long name of the +package, what will show up in melpa etc. AUTHOR will be used in +copyright notices. USER-ORG is either your user or organization, +which forms the first part of a github repo path. EMAIL is shown +after AUTHOR in package headers. Optional REV is either a tag, +branch or revision used in git checkout. See comments in `elisp-repo-kit-clone' and `elisp-repo-kit-rename-relicense' for implementation information -and more details about argument usage.." - (interactive "sPackage name: \nsAuthor: \nsGithub organization or username: \ -\nsEmail: \nsRev tag, or branch: ") +and more details about argument usage." + (interactive + (let* ((package-name + (read-string + (format "Package name, such as %s: " elisp-repo-kit-github-package-name) + "foo")) + (clone-root + (read-directory-name "Clone root: " default-directory)) + (author + (let ((default (when (executable-find "git") + (shell-command-to-string "git config user.name")))) + (read-string "Author: " default))) + (user-org (read-string "User or organization name: ")) + (email + (let ((default (when (executable-find "git") + (shell-command-to-string "git config user.email")))) + (read-string "Email: " default))) + (rev (read-string "Rev, tag, or branch (empty implies default branch): "))) + (list package-name clone-root author user-org email rev))) (elisp-repo-kit-rename-relicense (elisp-repo-kit-clone clone-root package-name user-org rev) package-name author user-org email)) From b43d3dbccc8009aae28f76ae34d5a7f9051d6352 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:55:36 -0600 Subject: [PATCH 38/55] fixups for tests Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-test.el | 5 +++-- test/run-shim.el | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index 54e1dc9..cea3bf2 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -58,11 +58,12 @@ (clone-root (make-temp-file "elisp-repo-kit-clone-test-" t))) (elisp-repo-kit-new clone-root - "clone-rename" ; project-name + "new-project" ; project-name "Selindis Raszagal" ; Author "new-shakuras" ; user-org "selindis.r@new-shakuras.planet" ; email - rev))) ; possibly nil + rev) ; possibly nil + (delete-directory clone-root))) (provide 'elisp-repo-kit-test) ;;; elisp-repo-kit-test.el ends here. diff --git a/test/run-shim.el b/test/run-shim.el index 4ffc883..6f0cef1 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -119,11 +119,14 @@ (print (format "Normalizing arguments, stripped: %s" (pop argv)))) (pop argv)) + (message "original default directory: %s" default-directory) ;; Configure load paths (setq default-directory (if load-file-name (file-name-directory load-file-name) default-directory)) - (let* ((tests-dir (expand-file-name (concat default-directory "../tests/"))) - (lisp-dir (expand-file-name (concat default-directory "../lisp/")))) + (let* ((tests-dir (expand-file-name (concat default-directory "../test"))) + (lisp-dir (expand-file-name (concat default-directory "../lisp")))) + (print (format "test load path: %s" tests-dir)) + (print (format "package load path: %s" lisp-dir)) (push tests-dir load-path) (push lisp-dir load-path)) From 8b1edbd1ef0465b008c4874b6746e5440e6a1d76 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:18:49 -0600 Subject: [PATCH 39/55] switch DCO check action The script was throwing some deprecation warnings. Let's get a little more lead time baked in. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/dco.yml | 16 ++++++++++++++-- README.org | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml index 18dcae0..a4519e4 100644 --- a/.github/workflows/dco.yml +++ b/.github/workflows/dco.yml @@ -31,9 +31,21 @@ on: # any pull-request workflow_dispatch: # Allows you to run this workflow manually from the Actions tab - + push: + branches: + - master jobs: check: runs-on: ubuntu-latest steps: - - uses: tisonkun/actions-dco@v1.1 + - uses: actions/checkout@v2.4.2 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Check DCO + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip3 install -U dco-check==0.3.1 + dco-check diff --git a/README.org b/README.org index c3dba8a..a5f9410 100644 --- a/README.org +++ b/README.org @@ -217,10 +217,12 @@ answer all the questions. actions/checkout@v2.4.2, cachix/cachix-action@v10, cachix/install-nix-action@v15, - tisonkun/actions-dco@v1.1 + actions/setup-python@v4, #+end_src + *Note*, Python is used to run a DCO check script, nothing more. + - [ ] Get your package working, pushed, actions run, and CI badges all green - [ ] [[#Publishing-to-melpa][Publish]] to MELPA - [ ] Make a post on the [[https://old.reddit.com/r/emacs/][subreddit]] about your new package From b21b12913c711bc0c361da19fac264ee52171816 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:25:06 -0600 Subject: [PATCH 40/55] switch to testing with EmacsGit and emacs vanilla packages Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce9130e..7ee2349 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,9 +37,8 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - emacsPkg: [ emacs28, - emacsUnstable, - # emacsGit + emacsPkg: [ emacs, + emacsGit, ] runs-on: ${{ matrix.os }} From 437177b49b87e2349be45b9ab9e8bb8c11a83f9f Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:29:20 -0600 Subject: [PATCH 41/55] you know what, these lints are useless Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ee2349..1822765 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,10 +77,10 @@ jobs: ls # Lint the package - emacs --script test/run-shim.el -- lint + # emacs --script test/run-shim.el -- lint # Lint the tests - emacs --script test/run-shim.el -- lint-tests + # emacs --script test/run-shim.el -- lint-tests - name: run tests run: | From b4a7e10b6bf8cc740c0cbd24348bb80ff306ac52 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:48:17 -0600 Subject: [PATCH 42/55] switch to initialism erk for package prefix because elisp-repo-kit is a very annoying prefix Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 20 ++++++------ lisp/elisp-repo-kit.el | 63 +++++++++++++++++++------------------ test/elisp-repo-kit-test.el | 8 ++--- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/README.org b/README.org index a5f9410..7566017 100644 --- a/README.org +++ b/README.org @@ -21,7 +21,7 @@ *To get started:* -Install the package and run =elisp-repo-kit-new=, provide a directory, and +Install the package and run =erk-new=, provide a directory, and answer all the questions. ** Install elisp-repo-kit @@ -48,7 +48,7 @@ answer all the questions. #+end_src -=elisp-repo-kit-new= will ask for: +=erk-new= will ask for: - Root directory you want to clone to - Package name @@ -56,19 +56,19 @@ answer all the questions. - Github user or organization - Email address - The =elisp-clone-repo-kit-new= calls =elisp-repo-kit-rename-relicense= to - rename all of the files, string replace names, and re-license to GPL3. Now - just follow the steps in [[#finish-setting-up-your-new-github-repo][finish setting up]] Have fun! + The =erk-new= calls =erk-rename-relicense= to rename all of the files, string + replace names, and re-license to GPL3. Now just follow the steps in [[#finish-setting-up-your-new-github-repo][finish + setting up]] Have fun! *** Manual cloning - The standalone command, =elisp-repo-kit-clone= will clone without renaming. + The standalone command, =erk-clone= will clone without renaming. This repo is also a [[https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template][template repository]], so you can fork without forking (Bruce Lee). If you create via template or clone manually, it's presumed you know what - you're doing at that point. Call =elisp-repo-kit-rename= on its own to rename + you're doing at that point. Call =erk-rename= on its own to rename in these cases. There are some customize options that cause the renaming to be transitively @@ -117,7 +117,7 @@ answer all the questions. ** Run tests - Run =elisp-repo-kit-ert-project= within your project. The tests in =/test= + Run =erk-ert-project= within your project. The tests in =/test= will be discovered, rebuilt & reloaded if necessary, and run. There are a few other commands to augment the [[https://www.gnu.org/software/emacs/manual/html_node/ert/][ert]] package. @@ -165,7 +165,7 @@ answer all the questions. ** Loading and re-loading your package - Run =elisp-repo-kit-reload-project= in one of your project files. All features + Run =erk-reload-package= in one of your project files. All features in the /lisp directory will be re-compiled and loaded appropriately. *Note*, during reloading, unloading the current module is forced. If other @@ -193,7 +193,7 @@ answer all the questions. #+end_src - Because the load path is configured, you can call =(unload-feature + Because the load path is configured above, you can call =(unload-feature 'elisp-repo-kit)= and then =(require 'elisp-repo-kit)= to pick up changes. * Finish setting up your new Github repo diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 918ab5e..c8e9e86 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -36,7 +36,7 @@ ;; ;; The package also uses its own hosted source as a substrate for creating new ;; packages. It will clone its source respository and then perform renaming & -;; relicensing. Simply call `elisp-repo-kit-new' to start a new package. The +;; relicensing. Simply call `erk-new' to start a new package. The ;; README documents remaining setup steps on Github and in preparation for ;; publishing on MELPA. ;; @@ -52,23 +52,23 @@ (require 'dash) (require 'ert) -(defgroup elisp-repo-kit nil "Elisp repository kit.") +(defgroup elisp-repo-kit nil "Elisp repository kit." :prefix 'erk) -(defcustom elisp-repo-kit-github-package-name "elisp-repo-kit" +(defcustom erk-github-package-name "elisp-repo-kit" "Default Github for cloning templates. If you rename this repository after forking, you need to set this to clone from within the fork." :group 'elisp-repo-kit :type 'string) -(defcustom elisp-repo-kit-github-userorg "positron-solutions" +(defcustom erk-github-userorg "positron-solutions" "Default Github for cloning templates. If you fork this repository, you need to set this to clone it from within the fork." :group 'elisp-repo-kit :type 'string) -(defconst elisp-repo-kit--gpl3-notice ";; This program is free software; \ +(defconst erk--gpl3-notice ";; 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 @@ -82,13 +82,13 @@ you can redistribute it and/or modify ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see .") -(defconst elisp-repo-kit--rename-maps ; directory file replacement-file +(defconst erk--rename-maps ; directory file replacement-file '(( nil "gpl-3.0.txt" "COPYING") ("lisp/" "elisp-repo-kit.el" nil) ("test/" "elisp-repo-kit-test.el" nil) ("test/" "run-shim.el" nil))) -(defconst elisp-repo-kit--files-with-strings +(defconst erk--files-with-strings '("README.org" "lisp/elisp-repo-kit.el" "test/elisp-repo-kit-test.el" @@ -97,6 +97,7 @@ you can redistribute it and/or modify (defun erk--project-root () "Return project root or buffer directory." (let ((project (project-current))) + ;; TODO remove pre-28 support (or (if (version<= emacs-version "28.0") (car (with-suppressed-warnings ((obsolete project-roots)) @@ -227,9 +228,9 @@ feature reloading." (erk-reload-project-tests) (ert (erk-ert-project-selector))) -(defun elisp-repo-kit--rename-package (dir old-package new-package) +(defun erk--rename-package (dir old-package new-package) "Rename FILES in DIR. -`elisp-repo-kit--rename-map' is a list of (subdir filename +`erk--rename-map' is a list of (subdir filename replacement-filename) triples. When subdir is nil, it means use DIR. If replacement-filename is nil means replace OLD-PACKAGE with NEW-PACKAGE, using `replace-regexp-in-string'. DIR is the @@ -242,22 +243,22 @@ clobbered." (let ((new-name (or replacement-filename (replace-regexp-in-string old-package new-package filename)))) (rename-file (concat dir filename) (concat dir new-name) t)))) - elisp-repo-kit--rename-maps)) + erk--rename-maps)) -(defun elisp-repo-kit--replace-strings (dir package-name author user-org email) +(defun erk--replace-strings (dir package-name author user-org email) "Replace values in files that need renaming or re-licensing. DIR is where we are replacing. PACKAGE-NAME is the new package. AUTHOR will be used in copyright notices. USER-ORG will be used as the first part of the new github path. EMAIL is shown after AUTHOR in package headers." (let ((default-directory dir) - (elisp-repo-kit-github-path (concat elisp-repo-kit-github-userorg "/" - elisp-repo-kit-github-package-name)) + (erk-github-path (concat erk-github-userorg "/" + erk-github-package-name)) (github-path (concat user-org "/" package-name)) (capitalized-package-title (string-join (mapcar #'capitalize - (split-string elisp-repo-kit-github-package-name "-")) + (split-string erk-github-package-name "-")) " "))) (mapc (lambda (file) @@ -273,24 +274,24 @@ AUTHOR in package headers." (goto-char (point-min)) ;; replace license with GPL3 notice (when (re-search-forward ";; Permission \\(.\\|\n\\)*SOFTWARE.$" nil t) - (replace-match elisp-repo-kit--gpl3-notice)) + (replace-match erk--gpl3-notice)) (goto-char (point-min)) ;; update github paths for README links - (while (re-search-forward elisp-repo-kit-github-path nil t) + (while (re-search-forward erk-github-path nil t) (replace-match github-path)) (goto-char (point-min)) ;; update remaining package name strings - (while (re-search-forward elisp-repo-kit-github-package-name nil t) + (while (re-search-forward erk-github-package-name nil t) (replace-match package-name)) (goto-char (point-min)) (while (re-search-forward capitalized-package-title nil t) (replace-match capitalized-package-title)) (save-buffer 0) (kill-buffer))) - elisp-repo-kit--files-with-strings))) + erk--files-with-strings))) ;;;###autoload -(defun elisp-repo-kit-clone (clone-root package-name user-org &optional rev) +(defun erk-clone (clone-root package-name user-org &optional rev) "Clone elisp-repo-kit to CLONE-ROOT and apply rename. PACKAGE-NAME will instruct git how to name the clone. USER-ORG is the user or organization you will use for your Github @@ -304,8 +305,8 @@ itself, as a quine and for forking as a new template repository." (shell-command (format "cd %s; %s clone https://github.com/%s/%s.git %s" clone-root git-bin - elisp-repo-kit-github-userorg - elisp-repo-kit-github-package-name + erk-github-userorg + erk-github-package-name package-name)) (shell-command (format "cd %s/%s" clone-root package-name)) @@ -321,7 +322,7 @@ itself, as a quine and for forking as a new template repository." (error "Could not find git executible"))) ;;;###autoload -(defun elisp-repo-kit-rename-relicense (clone-dir package-name author user-org email) +(defun erk-rename-relicense (clone-dir package-name author user-org email) "Rename and relicense your clone of elisp-repo-kit. CLONE-DIR is your elisp-repo-clone root. PACKAGE-NAME should be the long name of the package, what will show up in melpa etc. @@ -345,13 +346,13 @@ Re-licensing is fully permitted by the MIT license and intended by the author of this repository." (interactive "DCloned directory: \nsPackage name: \nsAuthor: \ \nsGithub organization or username: \nsEmail: ") - (elisp-repo-kit--replace-strings + (erk--replace-strings clone-dir package-name author user-org email) - (elisp-repo-kit--rename-package - clone-dir elisp-repo-kit-github-package-name package-name)) + (erk--rename-package + clone-dir erk-github-package-name package-name)) ;;;###autoload -(defun elisp-repo-kit-new (package-name clone-root author user-org email &optional rev) +(defun erk-new (package-name clone-root author user-org email &optional rev) "Clone elisp-repo-kit, rename, and relicense in one step. CLONE-ROOT is where you want to clone your package to (including the clone dir). PACKAGE-NAME should be the long name of the @@ -361,13 +362,13 @@ which forms the first part of a github repo path. EMAIL is shown after AUTHOR in package headers. Optional REV is either a tag, branch or revision used in git checkout. -See comments in `elisp-repo-kit-clone' and -`elisp-repo-kit-rename-relicense' for implementation information +See comments in `erk-clone' and +`erk-rename-relicense' for implementation information and more details about argument usage." (interactive (let* ((package-name (read-string - (format "Package name, such as %s: " elisp-repo-kit-github-package-name) + (format "Package name, such as %s: " erk-github-package-name) "foo")) (clone-root (read-directory-name "Clone root: " default-directory)) @@ -382,8 +383,8 @@ and more details about argument usage." (read-string "Email: " default))) (rev (read-string "Rev, tag, or branch (empty implies default branch): "))) (list package-name clone-root author user-org email rev))) - (elisp-repo-kit-rename-relicense - (elisp-repo-kit-clone clone-root package-name user-org rev) + (erk-rename-relicense + (erk-clone clone-root package-name user-org rev) package-name author user-org email)) (provide 'elisp-repo-kit) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index cea3bf2..5b38603 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -29,7 +29,7 @@ ;; flake.nix. ;; For local development, dependencies should be installed by the user. Tests -;; can be run from one of the project files using the `elisp-repo-kit-project-ert' +;; can be run from one of the project files using the `erk-ert-project' ;; command. ;;; Code: @@ -50,13 +50,13 @@ (should (member 'elisp-repo-kit (erk--package-features)))) (ert-deftest erk--test-features-test () - (should (member 'elisp-repo-kit-test (erk--test-features)))) + (should (member 'erk-test (erk--test-features)))) (ert-deftest erk-clone-and-rename-test () "Clone the repo and rename it, single step." (let ((rev (getenv "GITHUB_SHA")) - (clone-root (make-temp-file "elisp-repo-kit-clone-test-" t))) - (elisp-repo-kit-new + (clone-root (make-temp-file "erk-clone-test-" t))) + (erk-new clone-root "new-project" ; project-name "Selindis Raszagal" ; Author From 2d66ebb653c1a8cfdaef9c0a6540e72c1d3ab4c3 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 12:39:33 -0600 Subject: [PATCH 43/55] relint Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/run-shim.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/run-shim.el b/test/run-shim.el index 6f0cef1..d750a45 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -61,7 +61,7 @@ ;; "--no-check-declare" ) (seq-filter - (lambda (s) (not (string-match-p ".*autoloads.*\.el$" s))) + (lambda (s) (not (string-match-p ".*autoloads.*.el$" s))) (file-expand-wildcards "../lisp/*.el"))))) (message "ARGS: %s" command-line-args-left) @@ -97,7 +97,7 @@ ;; "--no-check-declare" ) (seq-filter - (lambda (s) (not (string-match-p ".*autoloads.*\.el$" s))) + (lambda (s) (not (string-match-p ".*autoloads.*.el$" s))) (file-expand-wildcards "../test/*.el"))))) ;; (setq elisp-lint-ignored-validators nil From 3e1cab119a0a1b4babb035a40f52415d7845fcea Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 12:43:23 -0600 Subject: [PATCH 44/55] elisp-lint was running the byte compile check in CI It will survive. For now. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- test/run-shim.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1822765..7ee2349 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,10 +77,10 @@ jobs: ls # Lint the package - # emacs --script test/run-shim.el -- lint + emacs --script test/run-shim.el -- lint # Lint the tests - # emacs --script test/run-shim.el -- lint-tests + emacs --script test/run-shim.el -- lint-tests - name: run tests run: | diff --git a/test/run-shim.el b/test/run-shim.el index d750a45..d5346d5 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -57,7 +57,7 @@ (append '(;; "--no- ;; "--no-byte-compile" - ;; "--no-checkdoc" + "--no-checkdoc" ;; "--no-check-declare" ) (seq-filter @@ -93,7 +93,7 @@ '("--no-package-lint" ;; "--no- ;; "--no-byte-compile" - ;; "--no-checkdoc" + "--no-checkdoc" ;; "--no-check-declare" ) (seq-filter From 5a52f0930589467ec1b60e3ec603fa692d35a1d6 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 13:01:54 -0600 Subject: [PATCH 45/55] getting lints to a sane state Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 6 +++--- test/elisp-repo-kit-test.el | 2 +- test/run-shim.el | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index c8e9e86..cd46508 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -5,7 +5,7 @@ ;; Author: ;; Keywords: convenience ;; Version: 0.2.0 -;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0") (dash "2.18.0") (ert "0")) +;; Package-Requires: ((emacs "25.1") (project "0.7.1") (auto-compile "1.2.0") (dash "2.18.0") (ert "0.0.1")) ;; Homepage: http://github.com/positron-solutions/elisp-repo-kit ;; Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -52,7 +52,7 @@ (require 'dash) (require 'ert) -(defgroup elisp-repo-kit nil "Elisp repository kit." :prefix 'erk) +(defgroup elisp-repo-kit nil "Elisp repository kit." :prefix 'erk :group 'elisp-repo-kit) (defcustom erk-github-package-name "elisp-repo-kit" "Default Github for cloning templates. @@ -253,7 +253,7 @@ as the first part of the new github path. EMAIL is shown after AUTHOR in package headers." (let ((default-directory dir) (erk-github-path (concat erk-github-userorg "/" - erk-github-package-name)) + erk-github-package-name)) (github-path (concat user-org "/" package-name)) (capitalized-package-title (string-join diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index 5b38603..7042cad 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -39,7 +39,7 @@ (ert-deftest erk--project-root-test () (should (string-match-p (rx "elisp-repo-kit/" eol) - (erk--project-root)))) + (erk--project-root)))) (ert-deftest erk--dir-features-test () (should (equal diff --git a/test/run-shim.el b/test/run-shim.el index d5346d5..0446fc3 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -58,6 +58,7 @@ '(;; "--no- ;; "--no-byte-compile" "--no-checkdoc" + "--no-package-lint" ;; "--no-check-declare" ) (seq-filter @@ -90,10 +91,10 @@ ;; `command-line-args-left has the same effect as passing command line arguments. (let ((command-line-args-left (append - '("--no-package-lint" - ;; "--no- + '(;; "--no- ;; "--no-byte-compile" "--no-checkdoc" + "--no-package-lint" ;; "--no-check-declare" ) (seq-filter From 67034319d5792e55543540cce6e82c972aef41c7 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 13:20:18 -0600 Subject: [PATCH 46/55] test fixups lol, how did that pass on the other os Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-test.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index 7042cad..79f61df 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -50,7 +50,7 @@ (should (member 'elisp-repo-kit (erk--package-features)))) (ert-deftest erk--test-features-test () - (should (member 'erk-test (erk--test-features)))) + (should (member 'elisp-repo-kit-test (erk--test-features)))) (ert-deftest erk-clone-and-rename-test () "Clone the repo and rename it, single step." @@ -63,7 +63,7 @@ "new-shakuras" ; user-org "selindis.r@new-shakuras.planet" ; email rev) ; possibly nil - (delete-directory clone-root))) + (delete-directory clone-root t))) (provide 'elisp-repo-kit-test) ;;; elisp-repo-kit-test.el ends here. From 1d92aecd333298e7858fb9bfeee611c98cc6c03a Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 14:10:55 -0600 Subject: [PATCH 47/55] let ert do output and exit codes and all that Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/run-shim.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/run-shim.el b/test/run-shim.el index 0446fc3..4830e01 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -138,7 +138,8 @@ (setq command (pop argv)) ; nil-safe (cond ((string= command "test") (require 'elisp-repo-kit-test) - (ert t)) + (ert-run-tests-batch-and-exit) + ) ((string= command "lint") (erk--lint-package)) ((string= command "lint-tests") (erk--lint-tests)) t (print "Command not recognized. Use test, lint, lint-tests etc."))) From 3258b13f653d1c1005bce82183ef28c87e922bca Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 14:12:18 -0600 Subject: [PATCH 48/55] switched arg order in test Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/elisp-repo-kit-test.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index 79f61df..c7ac540 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -57,8 +57,8 @@ (let ((rev (getenv "GITHUB_SHA")) (clone-root (make-temp-file "erk-clone-test-" t))) (erk-new + "new-project" ; package-name clone-root - "new-project" ; project-name "Selindis Raszagal" ; Author "new-shakuras" ; user-org "selindis.r@new-shakuras.planet" ; email From dd7d3c2bd1627d9249d04ad5ae156898e0833caf Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 14:12:39 -0600 Subject: [PATCH 49/55] let's not encourage writing tests again Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- test/run-shim.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/run-shim.el b/test/run-shim.el index 4830e01..1287ab5 100644 --- a/test/run-shim.el +++ b/test/run-shim.el @@ -124,11 +124,11 @@ ;; Configure load paths (setq default-directory (if load-file-name (file-name-directory load-file-name) default-directory)) - (let* ((tests-dir (expand-file-name (concat default-directory "../test"))) + (let* ((test-dir (expand-file-name (concat default-directory "../test"))) (lisp-dir (expand-file-name (concat default-directory "../lisp")))) - (print (format "test load path: %s" tests-dir)) + (print (format "test load path: %s" test-dir)) (print (format "package load path: %s" lisp-dir)) - (push tests-dir load-path) + (push test-dir load-path) (push lisp-dir load-path)) ;; running manually may encounter stale .elc From e4cec74f971297ff83878c7ab6211f6c568d302b Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Thu, 15 Dec 2022 15:00:59 -0600 Subject: [PATCH 50/55] update actions versions, use nix community binary cache Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/ci.yml | 5 +++-- README.org | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ee2349..b5c0776 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,16 +44,17 @@ jobs: steps: - uses: actions/checkout@v2.4.2 - - uses: cachix/install-nix-action@v15 + - uses: cachix/install-nix-action@v18 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v10 + - uses: cachix/cachix-action@v12 with: # This CACHIX_AUTH_TOKEN & CACHIX_CACHE_NAME are secrets you must set # in your repository settings name: ${{ secrets.CACHIX_CACHE_NAME }} authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: nix-community # look for pre-built binaries from upstream # Some paths may confuse cachix. Add them with a pipe to the pushFilter pushFilter: "(.drv.chroot$)" diff --git a/README.org b/README.org index 7566017..80554b6 100644 --- a/README.org +++ b/README.org @@ -215,8 +215,8 @@ answer all the questions. #+begin_src actions/checkout@v2.4.2, - cachix/cachix-action@v10, - cachix/install-nix-action@v15, + cachix/cachix-action@v12, + cachix/install-nix-action@v18, actions/setup-python@v4, #+end_src From a83181531239e439839f9e3e2a79d16102d2048c Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Fri, 16 Dec 2022 05:06:29 -0600 Subject: [PATCH 51/55] introducing package prefix Because the symbol prefix used for namespacing might not match the package name for features, custom, elisp filenames etc. Especially helpful with our long initialism used here. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 67 +++++++++++++++++++++++-------------- test/elisp-repo-kit-test.el | 1 + 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index cd46508..db2b32e 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -61,6 +61,11 @@ to clone from within the fork." :group 'elisp-repo-kit :type 'string) +(defcustom erk-package-prefix "erk-" + "Function names etc may use an initialism that requires renaming." + :group 'elisp-repo-kit + :type 'string) + (defcustom erk-github-userorg "positron-solutions" "Default Github for cloning templates. If you fork this repository, you need to set this to clone it @@ -245,16 +250,20 @@ clobbered." (rename-file (concat dir filename) (concat dir new-name) t)))) erk--rename-maps)) -(defun erk--replace-strings (dir package-name author user-org email) +(defun erk--replace-strings (dir package-name package-prefix author user-org email) "Replace values in files that need renaming or re-licensing. -DIR is where we are replacing. PACKAGE-NAME is the new package. -AUTHOR will be used in copyright notices. USER-ORG will be used -as the first part of the new github path. EMAIL is shown after -AUTHOR in package headers." +DIR is where we are replacing. PACKAGE-NAME is the new +package. PACKAGE-PREFIX is the elisp prefix. AUTHOR will be +used in copyright notices. USER-ORG will be used as the first +part of the new github path. EMAIL is shown after AUTHOR in +package headers." (let ((default-directory dir) (erk-github-path (concat erk-github-userorg "/" erk-github-package-name)) (github-path (concat user-org "/" package-name)) + (package-prefix (if (string-match-p (rx "-" eol) package-prefix) + package-prefix + (concat package-prefix "-"))) (capitalized-package-title (string-join (mapcar #'capitalize @@ -284,6 +293,9 @@ AUTHOR in package headers." (while (re-search-forward erk-github-package-name nil t) (replace-match package-name)) (goto-char (point-min)) + (while (re-search-forward erk-package-prefix nil t) + (replace-match package-prefix)) + (goto-char (point-min)) (while (re-search-forward capitalized-package-title nil t) (replace-match capitalized-package-title)) (save-buffer 0) @@ -322,14 +334,14 @@ itself, as a quine and for forking as a new template repository." (error "Could not find git executible"))) ;;;###autoload -(defun erk-rename-relicense (clone-dir package-name author user-org email) +(defun erk-rename-relicense (clone-dir package-name package-prefix author user-org email) "Rename and relicense your clone of elisp-repo-kit. CLONE-DIR is your elisp-repo-clone root. PACKAGE-NAME should be -the long name of the package, what will show up in melpa etc. -AUTHOR will be used in copyright notices. USER-ORG is either -your user or organization, which forms the first part of a github -repo path. EMAIL is shown after AUTHOR in -package headers. +the long name of the package, what will show up in melpa +etc. PACKAGE-PREFIX is the elisp symbol prefix. AUTHOR will be used +in copyright notices. USER-ORG is either your user or +organization, which forms the first part of a github repo path. +EMAIL is shown after AUTHOR in package headers. This command replaces all instances of: @@ -347,29 +359,32 @@ by the author of this repository." (interactive "DCloned directory: \nsPackage name: \nsAuthor: \ \nsGithub organization or username: \nsEmail: ") (erk--replace-strings - clone-dir package-name author user-org email) - (erk--rename-package - clone-dir erk-github-package-name package-name)) + clone-dir package-name package-prefix author user-org email) + (erk--rename-package clone-dir erk-github-package-name package-name)) ;;;###autoload -(defun erk-new (package-name clone-root author user-org email &optional rev) +(defun erk-new (package-name package-prefix clone-root author user-org email &optional rev) "Clone elisp-repo-kit, rename, and relicense in one step. CLONE-ROOT is where you want to clone your package to (including the clone dir). PACKAGE-NAME should be the long name of the -package, what will show up in melpa etc. AUTHOR will be used in -copyright notices. USER-ORG is either your user or organization, -which forms the first part of a github repo path. EMAIL is shown -after AUTHOR in package headers. Optional REV is either a tag, -branch or revision used in git checkout. - -See comments in `erk-clone' and -`erk-rename-relicense' for implementation information -and more details about argument usage." +package, what will show up in melpa etc. PACKAGE-PREFIX can be +either the same as the package or a contracted form, such as an +initialism. AUTHOR will be used in copyright notices. USER-ORG +is either your user or organization, which forms the first part +of a github repo path. EMAIL is shown after AUTHOR in package +headers. Optional REV is either a tag, branch or revision used +in git checkout. + +See comments in `erk-clone' and `erk-rename-relicense' for +implementation information and more details about argument usage." (interactive (let* ((package-name (read-string (format "Package name, such as %s: " erk-github-package-name) "foo")) + (package-prefix + (read-string + (format "Package prefix, such as %s: " erk-package-prefix))) (clone-root (read-directory-name "Clone root: " default-directory)) (author @@ -382,10 +397,10 @@ and more details about argument usage." (shell-command-to-string "git config user.email")))) (read-string "Email: " default))) (rev (read-string "Rev, tag, or branch (empty implies default branch): "))) - (list package-name clone-root author user-org email rev))) + (list package-name package-prefix clone-root author user-org email rev))) (erk-rename-relicense (erk-clone clone-root package-name user-org rev) - package-name author user-org email)) + package-name package-prefix author user-org email)) (provide 'elisp-repo-kit) ;;; elisp-repo-kit.el ends here diff --git a/test/elisp-repo-kit-test.el b/test/elisp-repo-kit-test.el index c7ac540..ec4a90b 100644 --- a/test/elisp-repo-kit-test.el +++ b/test/elisp-repo-kit-test.el @@ -58,6 +58,7 @@ (clone-root (make-temp-file "erk-clone-test-" t))) (erk-new "new-project" ; package-name + "np-" ; package prefix (usually package-name) clone-root "Selindis Raszagal" ; Author "new-shakuras" ; user-org From 88470c796534a1a33e73265bc13ee46d638e9f0f Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Fri, 16 Dec 2022 05:08:32 -0600 Subject: [PATCH 52/55] chop off newlines when suggesting author / email Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index db2b32e..9cdc9c9 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -389,12 +389,14 @@ implementation information and more details about argument usage." (read-directory-name "Clone root: " default-directory)) (author (let ((default (when (executable-find "git") - (shell-command-to-string "git config user.name")))) + (string-chop-newline + (shell-command-to-string "git config user.name"))))) (read-string "Author: " default))) (user-org (read-string "User or organization name: ")) (email (let ((default (when (executable-find "git") - (shell-command-to-string "git config user.email")))) + (string-chop-newline + (shell-command-to-string "git config user.email"))))) (read-string "Email: " default))) (rev (read-string "Rev, tag, or branch (empty implies default branch): "))) (list package-name package-prefix clone-root author user-org email rev))) From c48072eafd07cd9ad38a2ab9a80953a9ec9cbffc Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Fri, 16 Dec 2022 05:08:46 -0600 Subject: [PATCH 53/55] - Tired of package lint warning, so tweaked verbeage Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/elisp-repo-kit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/elisp-repo-kit.el b/lisp/elisp-repo-kit.el index 9cdc9c9..65c5cc4 100644 --- a/lisp/elisp-repo-kit.el +++ b/lisp/elisp-repo-kit.el @@ -227,7 +227,7 @@ feature reloading." ;;;###autoload (defun erk-ert-project () - "Run all ert tests in this project." + "Run Ert interactively, with selector for this project." (interactive) (erk-reload-project-package) (erk-reload-project-tests) From b113476068b7336ec5df5be742ffb22ef74d7f0b Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Fri, 16 Dec 2022 05:33:13 -0600 Subject: [PATCH 54/55] newer checkout action deprecation warnings Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- .github/workflows/dco.yml | 2 +- README.org | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5c0776..f6fd28a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2.4.2 + - uses: actions/checkout@v3.2.0 - uses: cachix/install-nix-action@v18 with: extra_nix_config: | diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml index a4519e4..f717b92 100644 --- a/.github/workflows/dco.yml +++ b/.github/workflows/dco.yml @@ -38,7 +38,7 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.4.2 + - uses: actions/checkout@v3.2.0 - name: Set up Python 3.10 uses: actions/setup-python@v4 with: diff --git a/README.org b/README.org index 80554b6..711894c 100644 --- a/README.org +++ b/README.org @@ -214,7 +214,7 @@ answer all the questions. #+begin_src - actions/checkout@v2.4.2, + actions/checkout@v3.2.0, cachix/cachix-action@v12, cachix/install-nix-action@v18, actions/setup-python@v4, From 05d38453457df03db8f2a7d3ac2bfd955ff3fba9 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Fri, 16 Dec 2022 06:45:43 -0600 Subject: [PATCH 55/55] readme proofread & verbeage Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- README.org | 109 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 42 deletions(-) diff --git a/README.org b/README.org index 711894c..ed97fe6 100644 --- a/README.org +++ b/README.org @@ -8,14 +8,17 @@ #+HTML: CI workflow status #+HTML: DCO Check +This repository is a kit to start a new elisp package repository. The package +contained has commands to streamline elisp development. + * Quickly set up an Emacs Lisp repository on Github with: - An [[https://www.youtube.com/watch?v=RQK_DaaX34Q&list=PLEoMzSkcN8oPQtn7FQEF3D7sroZbXuPZ7][elisp]] package - Bytecode compiling, linting, and test running - Commands to handle common elisp development gotchas - CI with [[https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs][Github Actions]], configured for Darwin (MacOS) and Linux -- [[https://nixos.org/#examples][Nix]] environment for obtaining dependencies or - reproducibly developing CI locally +- [[https://nixos.org/#examples][Nix]] environment for obtaining dependencies or reproducibly developing CI + locally - Licensing, [[https://developercertificate.org/][DCO]], and DCO sign-off checks for PR's - [[https://github.com/melpa/melpa][MELPA]] publishing compatible @@ -52,6 +55,7 @@ answer all the questions. - Root directory you want to clone to - Package name + - Package prefix - Author name - Github user or organization - Email address @@ -174,13 +178,18 @@ answer all the questions. *** Manual Loading & Reloading + To manually unload, run built-in command ~unload-feature~ and select your + package name. If you do not unload, reloading has no effect and you will see + stale behavior. + + Next, add the package to your load-path and then require it or, more + directly, call =emacs-lisp-byte-compile-and-load= or + =emacs-lisp-native-compile-and-load=. + Especially in bootstrap situations such as working on this package itself, you cannot unload the package in the middle of a command. Some commands have a =no-reload= variant just for this circumstance. - Call ~unload-feature~ and select your package name. If you do not unload, - reloading has no effect and you will see stale behavior. - When using locally installed packages such as with straight, =straight-rebuild-pacakge= will rebuild but *not* reload. @@ -429,7 +438,7 @@ answer all the questions. can also set the signature flag this way. **** Automatic GPG signing with per-project keys - + In order to specify which projects you intend to sign with which keys, you will want to configure your git client using path-specific configurations. @@ -492,44 +501,57 @@ answer all the questions. * Package scope and relation to other work - This repository mainly captures the annoying work necessary to set up a new - repository with everyting working. By focusing on just one minimal task, - cloning itself and renaming, there is very little work a user will need to - identify and remove to reach the clean foundation. + There are two functional goals of this repository: + + - Automate the annoying work necessary to set up a new repository + - Streamline common elisp development workflows Commands within this package will focus on cleaner integration of the tests and lints with Emacs. There has been a lot of work in this area, but much of it is - tangled with dependency management and sandbox creation. + tangled with dependency management and sandbox creation. Much of the work is + done in languages other than elisp and focused on non-interactive workflows + with no interactive integration on top. -** Dependency Management + Providing close to out-of-box CI is a big focus. By making it easier to + qualify changes from other users, it becomes less burdonsome to maintain + software, and by extension, less burdensom to publish and create software. The + effect is to drive creation of elisp in a way that can accelerate the flow of + elisp into Emacs itself. - Many tools for testing Emacs packages provide dependency management and loading - those dependencies into a fresh Emacs instance. This package will never attempt - to manage dependencies. Dependencies will always be expressed through the Nix - flake expressions and at most a lock file describing a frozen set of Emacs - dependencies. +** Dependency Management - Use of the [[https://github.com/nix-community/emacs-overlay][Emacs Nix Overlay]] is a simple way of stating and obtaining elisp - dependencies for now. Non-elisp dependencies are trivially provided form - nixpkgs. Nix is extremely reliable at dependency management, and it is no - surprise that much complexity is normalized away by just the basic behavior - model of Nix. In addition, *if your project needs or includes additional binary - dependencies or modules*, Nix is an excellent way to provide them to CI and - users. + This repository uses pure dependency management and then levarages it to + provide dependencies for development and CI environments. The resulting user + experience is built around CI for reproducibility and interactive testing for + development speed. + + Because most elisp dependencies can be obtained without extensive system + dependency management, many tools for testing Emacs packages provide + dependency management and loading those dependencies into a fresh Emacs + instance. This aligns well with ad-hoc sandboxed local testing. This was + fine in the old days of impure dependency management and dirty environments. + + The [[https://github.com/nix-community/emacs-overlay][Emacs Nix Overlay]] and Emacs support within nixpkgs make it possible to + stating and obtaining elisp dependencies in a completely pure way. Non-elisp + dependencies are trivially provided form nixpkgs. Nix is extremely reliable + at dependency management, and it is no surprise that much complexity is + normalized away by just the basic behavior model of Nix. In addition, *if + your project needs or includes additional binary dependencies or modules*, + Nix is an excellent way to provide them to CI and users. ** Discovering and Running Tests & Lints - This repository uses very bare elisp that can be run with just one Emacs switch - in most cases. The Makefile merely exposes this interface with the even more - familiar make style of user interaction. + During development, the commands provided under the =erk-= prefix make it + more convenient to reload your package and test features. You can run the + ert tests for a project while working on multiple packages. - The CI scripts are arranged to present a useful environment first. The commands - to invoke tests follow. If the commands need to be changed, it is - straightforward to change them /independently of how you provide dependencies/. - Just be sure to propagate changes to the Makefile and README of your project. + During CI, this repository uses an elisp shim for discovering and running + tests. The commands within the package for convenience during development + are not depeneded upon during CI. - Future versions of this project will continue to favor elisp scripts for test - discovery and integration with Emacs. Make and bash will be minimized. + The CI actions obtain an environment with dependencies using Nix, so this can + also be done locally using Nix, meaning re-creating environments is available + to the user without leaning on CI. ** Comparisons @@ -556,23 +578,26 @@ answer all the questions. * Contributing First decide if you want to work on this repository or fork it to something - entirely different. Non-exhaustive list of changes that are very welcome: + entirely different. + + Non-exhaustive list of changes that are very welcome: - - To the maximum degree possible, this project should lean on elisp as a CLI - script backend - - Running additional kinds of tests - - Running additional lints + - More interactive integrations with high-value elisp development workflows + - Running additional or better kinds of tests & lints - Fix bugs - Expose trivial options where a structural choice has limited them unnecessarily - Behave the same, but with a less complicated code - - Guix support + - Guix or other pure dependency management support Changes will likely be rejected if it is aimed at: - - Managing dependencies outside of Nix expressions other than a package that is - supposed to manage dependencies or test obtaining dependencies in a - user-present use case + - Non-elisp interfaces meant for invocation outside of Emacs or with scripting + implemented in a language besides elisp. + - Managing dependencies outside of Nix (or other pure dependency management) + expressions + - CI infrastructure support for non-Actions infrastructure (which cannot be + tested in this repo) - Backwards compatibility for Emacs two versions behind next release. Master, current stable release, and release - 1 are the only versions being supported - pre-flake Nix support