diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dfaf65f..b86c196 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -# Simple workflow to build the package & execute unit tests. Runs: +# Simple workflow to build the package, execute unit tests & test the tarball. Runs: # # - on demand # - on push @@ -19,37 +19,98 @@ on: - cron: '35 01 * * *' jobs: + # These all seem to run in `/home/runner/work/elfeed-score/elfeed-score` lint_and_test: name: Lint & Test - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + runs-on: ${{ matrix.os }} steps: + - name: Checkout repo uses: actions/checkout@v2 + - name: Install tooling shell: bash run: | set -ex + pwd sudo apt-get update - sudo apt-get install -y autoconf automake emacs texlive + sudo apt-get upgrade + sudo apt-get install -y autoconf automake texlive emacs + echo "EMACSLOADPATH=$(pwd):$(pwd)/elfeed:$(pwd)/elfeed/tests:$(ls -d /usr/share/emacs/2*)/lisp" >> $GITHUB_ENV + echo "Will now use the emacs at $(type -p emacs): $(emacs --version|head -n1)" git clone https://github.com/skeeto/elfeed.git + + - name: Install least version of Emacs supported by elfeed-score + if: matrix.os == 'ubuntu-20.04' + shell: bash + run: | + set -ex + pwd + pushd /tmp + curl -LO http://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-26.1.tar.gz + tar xf emacs-26.1.tar.gz && cd emacs-26.1 + ./configure --prefix=/usr/local --with-x-toolkit=no --with-xpm=no --with-gif=no -with-gnutls=no + make + sudo make install + popd + hash -r + ls /usr/local/share + echo "EMACSLOADPATH=$(pwd):$(pwd)/elfeed:$(pwd)/elfeed/tests:$(ls -d /usr/local/share/emacs/26.1)/lisp" >> $GITHUB_ENV + echo "Will now use the emacs at $(type -p emacs): $(emacs --version|head -n1)" + - name: Install a modern version of automake shell: bash run: | - set -x + set -ex cd /tmp curl -L -O https://ftp.gnu.org/gnu/automake/automake-1.16.4.tar.xz tar -xf automake-1.16.4.tar.xz cd automake-1.16.4 ./configure && make sudo make install - - name: Run unit tests + hash -r + echo "Will now use the automake at $(type -p automake): $(automake --version|head -n1)" + + - name: Get the current version number from configure.ac + run: | + set -ex + export version=`awk '/^AC_INIT/ {print substr($2, 2, length($2)-3)}' configure.ac` + echo "ELFEED_SCORE_VERSION=${version}" >> $GITHUB_ENV + echo "version is ${{ env.ELFEED_SCORE_VERSION }}" + + - name: Configure & make shell: bash run: | - set -x - export EMACSLOADPATH=$(pwd):$(pwd)/elfeed:$(pwd)/elfeed/tests:$(ls -d /usr/share/emacs/2*)/lisp + set -ex + export EMACSLOADPATH=${{ env.EMACSLOADPATH }} ./bootstrap ./configure make - make check - make distcheck + + - name: Run the unit tests + shell: bash + run: | + set -x + export EMACSLOADPATH=${{ env.EMACSLOADPATH }} + make check || cat test/test-suite.log + + - name: Check the Autotools distribution + shell: bash + run: | + set -x + pwd + export EMACSLOADPATH=${{ env.EMACSLOADPATH }} + if ! make distcheck; then + cand_build="elfeed-score-${{ env.ELFEED_SCORE_VERSION }}/_build/sub/test/test-suite.log" + cand_inst="elfeed-score-${{ env.ELFEED_SCORE_VERSION }}/_inst/sub/test/test-suite.log" + if -f ${cand_build}; then + cat ${cand_build} + elif -f ${cand_inst}; then + cat {$cand_inst} + fi + fi + diff --git a/.github/workflows/melpazoid.yml b/.github/workflows/melpazoid.yml index 1dfda73..98d8c7a 100644 --- a/.github/workflows/melpazoid.yml +++ b/.github/workflows/melpazoid.yml @@ -1,5 +1,5 @@ # melpazoid build checks. -name: melpazoid +name: Run melpazoid on: workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3346528..d1a8a36 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ # Setting up a release workflow for `elfeed-score'. Much thanks to # BurntShushi from whom I shamelessly copied a lot of this # -name: release +name: Cut a release on: # allow this workflow to be triggered manually, which is what this # event allegedly does diff --git a/ChangeLog b/ChangeLog index 2147cf8..a0ea7d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,62 @@ +2023-07-28 Michael Herstine + + Fix issue #32 Parent dirs in elfeed-score-rule-stats-file are not + Setting `elfeed-score-rule-stats-file` to a path with intermediate + directories that don't exist will error-out. This fix will at + least attempt to create them. + + Also, update the CI workflow & generally prep for the merge + (new versions in docs &c) + + As an aside, the regression test was originally written using + `file-name-concat' which was only introduced in Emacs 28.1 + (we support 26.1). It now uses a purpose-build Emacs Lisp + replacement. + +2023-07-27 Michael Herstine + + Fix the Continuous Integration job. + I neglected to do `sudo apt-get update` before doing an `apt-get + install`. This commit remedies that. + +2023-07-12 Michael Herstine + + Fix the Continuous Integration job. + I neglected to do `sudo apt-get update` before doing an `apt-get + install`. This commit remedies that. + +2023-06-17 Michael Herstine + + Allow the melpazoid check to run on-demand as well as nightly + +2023-06-14 Michael Herstine + + Fix make distcheck + +2023-06-13 Michael Herstine + + Fix CI + 2023-05-06 Michael Herstine - - Updated the elfeed-score manual to reflect this - - Fixed a unit test that was broken by the previous merge - - Added swflint to AUTHORS + Updating project workflows. + + Make release 1.2.6. + + Merge branch 'elfeed-enable-configurably' + + - Updated the elfeed-score manual to reflect this - Fixed a unit test that was broken by the previous merge - Added swflint to AUTHORS 2023-05-02 Samuel W. Flint Add configurability to elfeed-score-scoring-score-entry depth -2023-04-18 Michael Herstine +2023-04-19 Michael + + Merge pull request #29 from sp1ff/pr-process + Maintenance commit. This commit: + +2023-04-19 Michael Herstine Maintenance commit. This commit: - fixes the unit tests @@ -16,6 +64,8 @@ - adds a new workflow for PRs - changes the logic for the "melpazoid" workflow +2023-04-18 Michael Herstine + Merge branch 'master' of github.com:sp1ff/elfeed-score Updating the Python version in the Melpazoid checks. @@ -25,7 +75,6 @@ Merge pull request #28 from swflint/master Use with-help-window to make the explanation buffer easily quittable - 2023-03-09 Samuel W. Flint Use with-help-window to make the explanation buffer easily quittable diff --git a/NEWS b/NEWS index 03f94cf..899fe31 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ elfeed-score News -- history of user-visible changes -*- outline -*- * elfeed-score 1.2 +** changes in elfeed-score 1.2.7 + +*** address issue #32 Parent dirs in elfeed-score-rule-stats-file are not created automatically + +If you set `elfeed-score-rule-stats-file` to a path in which some intermediate directories don't exist, elfeed-score will error on saving stats. ** changes in elfeed-score 1.2.6 *** make the depth at which the scoring function runs configurable in the new entry hook diff --git a/README.org b/README.org index 0d0bee6..e64338e 100644 --- a/README.org +++ b/README.org @@ -2,7 +2,7 @@ #+DESCRIPTION: Gnus-style scoring for Elfeed #+AUTHOR: Michael Herstine #+EMAIL: sp1ff@pobox.com -#+DATE: <2023-05-06 Sat 08:17> +#+DATE: <2023-07-26 Wed 07:28> #+AUTODATE: t #+OPTIONS: toc:nil org-md-headline-style:setext *:t ^:nil #+STARTUP: overview @@ -73,7 +73,7 @@ The easiest way to install elfeed-score is [[https://github.com/melpa/melpa][MEL If you would prefer to install the package manually, you can also download the Emacs package file on the GitHub releases [[https://github.com/sp1ff/elfeed-score/releases][page]] or from my personal [[https://www.unwoundstack/distros.html][page]]. Then say: #+BEGIN_SRC elisp -(package-install-file "elfeed-score-1.2.6.tar") +(package-install-file "elfeed-score-1.2.7.tar") #+END_SRC ** Autotools Source Distributions @@ -82,8 +82,8 @@ You can also download Autotools source tarballs (again available either on the G #+BEGIN_SRC bash cd /tmp -curl -L --output elfeed-score-1.2.6.tar.gz https://github.com/sp1ff/elfeed-score/releases/download/1.2.6/elfeed-score-1.2.6.tar.gz -tar xvf elfeed-score-1.2.6.tar.gz && cd elfeed-score-1.2.6 +curl -L --output elfeed-score-1.2.7.tar.gz https://github.com/sp1ff/elfeed-score/releases/download/1.2.7/elfeed-score-1.2.7.tar.gz +tar xvf elfeed-score-1.2.7.tar.gz && cd elfeed-score-1.2.7 export EMACSLOADPATH=$HOME/.emacs.d/elpa/elfeed-20200209.1942:$EMACSLOADPATH ./configure make @@ -98,16 +98,16 @@ The unit tests require some macros defined by the [[https://github.com/skeeto/el #+BEGIN_SRC bash cd /tmp git clone https://github.com/skeeto/elfeed.git -curl -L --output=elfeed-score-1.2.6.tar.gz https://github.com/sp1ff/elfeed-score/releases/download/1.2.6/elfeed-score-1.2.6.tar.gz -tar xvf elfeed-score-1.2.6.tar.gz && cd elfeed-score-1.2.6 -export EMACSLOADPATH=/tmp/elfeed-score-1.2.6:/tmp/elfeed:/tmp/elfeed/tests:$EMACSLOADPATH +curl -L --output=elfeed-score-1.2.7.tar.gz https://github.com/sp1ff/elfeed-score/releases/download/1.2.7/elfeed-score-1.2.7.tar.gz +tar xvf elfeed-score-1.2.7.tar.gz && cd elfeed-score-1.2.7 +export EMACSLOADPATH=/tmp/elfeed-score-1.2.7:/tmp/elfeed:/tmp/elfeed/tests:$EMACSLOADPATH ./configure make make check sudo make install #+END_SRC -Again, unless you already use =EMACSLOADPATH=, you'll need to set =EMACSLOADPATH= appropriately to your system, something like =EMACSLOADPATH=/tmp/elfeed-score-1.2.6:/tmp/elfeed:/tmp/elfeed/tests:/usr/share/emacs/25.2/lisp=. +Again, unless you already use =EMACSLOADPATH=, you'll need to set =EMACSLOADPATH= appropriately to your system, something like =EMACSLOADPATH=/tmp/elfeed-score-1.2.7:/tmp/elfeed:/tmp/elfeed/tests:/usr/share/emacs/25.2/lisp=. ** Building From Source Finally, you can of course just clone this repo & build there. I've started a [[https://github.com/sp1ff/elfeed-score/wiki][wiki]], whose intended audience are people looking to hack on elfeed-score, that includes build instructions. diff --git a/configure.ac b/configure.ac index 594133a..c77323a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([elfeed-score], [1.2.6], [sp1ff@pobox.com], [elfeed-score], [https://github.com/sp1ff/elfeed-score]) +AC_INIT([elfeed-score], [1.2.7], [sp1ff@pobox.com], [elfeed-score], [https://github.com/sp1ff/elfeed-score]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([./elfeed-score.el]) AC_PROG_MAKE_SET diff --git a/doc/version.texi b/doc/version.texi index ccf7815..097ccb8 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ @set UPDATED 6 May 2023 @set UPDATED-MONTH May 2023 -@set EDITION 1.2.6 -@set VERSION 1.2.6 +@set EDITION 1.2.7 +@set VERSION 1.2.7 diff --git a/elfeed-score-pkg.el b/elfeed-score-pkg.el index 47aca3f..ec85779 100644 --- a/elfeed-score-pkg.el +++ b/elfeed-score-pkg.el @@ -1,5 +1,5 @@ (define-package "elfeed-score" - "1.2.6" + "1.2.7" "Gnus-style scoring for Elfeed" '((emacs "26.1") (elfeed "3.3.0"))) diff --git a/elfeed-score-rule-stats.el b/elfeed-score-rule-stats.el index bb4571b..ff78e28 100644 --- a/elfeed-score-rule-stats.el +++ b/elfeed-score-rule-stats.el @@ -124,9 +124,9 @@ This is a utility function for persisting LISP S-expressions to file. If possible, it will write SEXP to a temporary file in the same directory as FILE-NAME and then rename the temporary file to replace the original. Since the move operation is usually atomic -\(so long as both the source & the target are on the same volume) -any error leaves the original untouched, and there is never any -instant where the file is nonexistent. +\(so long as both the source & the target are on the same +filesystem) any error leaves the original untouched, and there is +never any instant where the file is nonexistent. This implementation will first check that the target file is writable and signal an error if it is not. Note that it will not @@ -145,7 +145,7 @@ heavily derivative of `basic-save-buffer-2'." (if (not (file-directory-p dir)) (if (file-exists-p dir) (error "%s is not a directory" dir) - (error "%s: no such directory" dir)) + (make-directory dir t)) (if (not (file-exists-p file-name)) (error "Directory %s write-protected" dir) (error "Attempt to save to a file that you aren't allowed to write"))))) @@ -181,7 +181,11 @@ heavily derivative of `basic-save-buffer-2'." "Current count of in-memory stats changes.") (defun elfeed-score-rule-stats-write (stats-file) - "Write the in-memory stats to STATS-FILE." + "Write the in-memory stats to STATS-FILE. + +If STATS-FILE doesn't exist, it will be created. If any parent +directories in its path don't exist, and the caller has +permission to create them, they will be created." (interactive (list (read-file-name "stats file: " nil elfeed-score-rule-stats-file t @@ -254,6 +258,7 @@ Returns a default-constructed stats object if RULE isn't in the table." ;; `elfeed-update-init-hooks' & restore it here, but I'm uncomfortable ;; with the risk that the update may be interrupted somehow, leaving ;; `elfeed-score-rule-stats-dirty-threshold' "stuck" from then on. + (defun elfeed-score-rule-stats-update-hook (_url) "Write stats when an elfeed update is complete." (when (and (eq (elfeed-queue-count-total) 0) diff --git a/elfeed-score.el b/elfeed-score.el index 9c570e2..bcc8dc7 100644 --- a/elfeed-score.el +++ b/elfeed-score.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2019-2023 Michael Herstine ;; Author: Michael Herstine -;; Version: 1.2.6 +;; Version: 1.2.7 ;; Package-Requires: ((emacs "26.1") (elfeed "3.3.0")) ;; Keywords: news ;; URL: https://github.com/sp1ff/elfeed-score @@ -44,7 +44,7 @@ (require 'elfeed-score-scoring) (require 'elfeed-score-maint) -(defconst elfeed-score-version "1.2.6") +(defconst elfeed-score-version "1.2.7") (defgroup elfeed-score nil "Gnus-style scoring for Elfeed entries." diff --git a/test/test-stats.el b/test/test-stats.el index 8b4932d..ea52fb8 100644 --- a/test/test-stats.el +++ b/test/test-stats.el @@ -109,6 +109,43 @@ (delete-file "test-sexp") (delete-file "test-sexp-2")) +;; `file-name-concat' was only introduced in Emacs 28.1, and we want to support +;; 26.1. Write a replacement in Emacs Lisp. +(defun file-name-concat-1 (&rest components) + "Concatenate file name COMPONENTS into a single path." + (let ((result "")) + (dolist (component components) + (setq result (expand-file-name component result))) + result)) + +(ert-deftest test-issue-32 () + "Regression test against elfeed-score issue #32 +\"Parent dirs in elfeed-score-rule-stats-file are not created +automatically\" + +If `elfeed-score-rule-stats-write' is invoked with an argument +for which some parent directories don't exist, and the caller has +permissions, they should be created automatically." + + ;; Whip-up a few rules... + (let ((r1 (elfeed-score-title-rule--create + :text "Bar" :value 1 :type 's)) + (r2 (elfeed-score-feed-rule--create + :text "feed" :value 1 :type 's :attr 't))) + ;; & generate some stats for 'em. + (elfeed-score-rule-stats-on-match r1) + (elfeed-score-rule-stats-on-match r2) + (should (eq 2 (hash-table-count elfeed-score-rule-stats--table))) + ;; and send 'em to a target file whose parent directories don't exist (yet) + (let ((stats-file + (file-name-concat-1 (make-temp-file "iss-32-" t) + "a" + "b" + "test-stats-file"))) + (elfeed-score-rule-stats-write stats-file) + (should (file-exists-p stats-file))) + (elfeed-score-serde-cleanup-stats))) + (provide 'test-stats) ;;; test-stats.el ends here.