From 1a6b8836a31e57306c306deb1351b2be908362fb Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 18:34:46 +0300 Subject: [PATCH 01/25] Move to eask --- .forgejo/workflows/ci.yml | 26 ++++++++++++++++++++++++++ .gitignore | 3 ++- Cask | 10 ---------- Eask | 18 ++++++++++++++++++ Makefile | 9 ++++----- counsel-projectile.el | 16 ++++++++-------- targets/compile.el | 3 --- targets/elpa.el | 6 ------ tests/test-counsel-projectile.el | 5 +++++ 9 files changed, 63 insertions(+), 33 deletions(-) create mode 100644 .forgejo/workflows/ci.yml delete mode 100644 Cask create mode 100644 Eask delete mode 100644 targets/compile.el delete mode 100644 targets/elpa.el create mode 100644 tests/test-counsel-projectile.el diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..db8562d --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,26 @@ +on: [push] +jobs: + test: + name: Test config on ${{matrix.node}} + runs-on: docker + strategy: + matrix: + node: ["20"] + + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + + - name: Setup NodeJS + uses: https://code.forgejo.org/actions/setup-node@v4 + with: + node-version: ${{matrix.node}} + + - name: Install eask + run: npm install -g @emacs-eask/cli + + - name: Run tests + run: eask test buttercup + + - name: Uninstall eask + run: npm uninstall -g @emacs-eask/cli diff --git a/.gitignore b/.gitignore index 1304fa2..edf700e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.elc -/.cask/ +/.eask/ +/dist/ diff --git a/Cask b/Cask deleted file mode 100644 index ce1fddc..0000000 --- a/Cask +++ /dev/null @@ -1,10 +0,0 @@ -(source gnu) -(source melpa) - -(package-file "counsel-projectile.el") - -(files "*.el") - -(development - (depends-on "counsel") - (depends-on "projectile")) diff --git a/Eask b/Eask new file mode 100644 index 0000000..f2ee0d1 --- /dev/null +++ b/Eask @@ -0,0 +1,18 @@ +(package "counsel-projectile" + "0.4.0" + "Ivy integration for Projectile") + +(website-url "https://git.icejam.ee/maciej/counsel-projectile") +(keywords "project" "convenience") + +(package-file "counsel-projectile.el") + +(source "gnu") +(source "melpa") + +(depends-on "emacs" "26.1") +(depends-on "projectile") +(depends-on "counsel") + +(development + (depends-on "buttercup")) diff --git a/Makefile b/Makefile index d473676..eb4e300 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,13 @@ emacs ?= emacs -CASK = ~/.cask/bin/cask -BEMACS = $(emacs) -batch -l targets/elpa.el +EASK ?= eask all: compile -cask: - $(CASK) +eask: + $(EASK) compile: - $(BEMACS) -l targets/compile.el + $(EASK) compile .PHONY: all compile clean cask diff --git a/counsel-projectile.el b/counsel-projectile.el index 81b6b01..8cc42b8 100644 --- a/counsel-projectile.el +++ b/counsel-projectile.el @@ -3,10 +3,10 @@ ;; Copyright (C) 2016-2021 Eric Danan ;; Author: Eric Danan -;; URL: https://github.com/ericdanan/counsel-projectile +;; URL: https://git.icejam.ee/maciej/counsel-projectile ;; Keywords: project, convenience -;; Version: 0.3.2 -;; Package-Requires: ((counsel "0.13.4") (projectile "2.5.0")) +;; Version: 0.4.0 +;; Package-Requires: ((counsel "0.13.4") (projectile "2.5.0") (emacs "26.1")) ;; This file is NOT part of GNU Emacs. @@ -348,7 +348,7 @@ on `counsel-find-file-ignore-regexp'." ;; We apply `counsel--find-file-matcher' to `cands' so we can ;; honor `ivy-use-ignore', but we don't need to filter ;; again. - (counsel--find-file-matcher nil cands)))) + (counsel--find-file-matcher nil cands)))) (defun counsel-projectile-find-file-action (file) "Find FILE and run `projectile-find-file-hook'." @@ -450,7 +450,7 @@ The sorting function can be modified by adding an entry for ("p" counsel-projectile-find-dir-action-switch-project "switch project")) 'counsel-projectile) - + (defun counsel-projectile--project-directories () "Return a list of current project's directories." (if projectile-find-dir-includes-top-level @@ -923,7 +923,7 @@ is called with a `\\[universal-argument]' prefix argument." (projectile--globally-ignored-file-suffixes-glob) (projectile-ignored-files-rel) (projectile-ignored-directories-rel)) - " ")) + " ")) (counsel-rg-base-command (let ((counsel-ag-command counsel-rg-base-command)) (counsel--format-ag-command ignored "%s")))) @@ -1110,7 +1110,7 @@ The format is the same as in `org-capture-templates-contexts'." "Switch project action for `counsel-projectile-org-capture'." (setq org-capture-templates counsel-projectile--org-capture-templates-backup) (counsel-projectile-switch-project 'counsel-projectile-switch-project-action-org-capture)) - + ;;;###autoload (defun counsel-projectile-org-capture (&optional from-buffer) "Capture into the current project. @@ -1576,7 +1576,7 @@ files." (if (member name counsel-projectile--buffers) (ivy--kill-buffer-action name) (counsel-projectile-find-file-action-delete name))) - + (defun counsel-projectile-action-find-file-manually (name) "Call `counsel-find-file' from default directory of buffer directory of file named NAME." diff --git a/targets/compile.el b/targets/compile.el deleted file mode 100644 index 06ed493..0000000 --- a/targets/compile.el +++ /dev/null @@ -1,3 +0,0 @@ -(setq files '("counsel-projectile.el")) -(setq byte-compile--use-old-handlers nil) -(mapc #'byte-compile-file files) diff --git a/targets/elpa.el b/targets/elpa.el deleted file mode 100644 index 3e15e4e..0000000 --- a/targets/elpa.el +++ /dev/null @@ -1,6 +0,0 @@ -(setq package-user-dir - (expand-file-name (format ".cask/%s/elpa" emacs-version))) -(package-initialize) -(message "ELPA dir: %S" package-user-dir) -(add-to-list 'load-path default-directory) - diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el new file mode 100644 index 0000000..d616661 --- /dev/null +++ b/tests/test-counsel-projectile.el @@ -0,0 +1,5 @@ +;;; -*- lexical-binding: t; -*- + +(describe "counsel-projectile" + (it "always passes" + (expect 1 :to-equal 1))) From f96762ce06d86bde26863ac3b15620148fba182c Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 18:42:41 +0300 Subject: [PATCH 02/25] CI more --- .forgejo/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index db8562d..f808655 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -6,6 +6,7 @@ jobs: strategy: matrix: node: ["20"] + emacs-version: [26.3, 27.2, 28.2, 29.1, snapshot] steps: - name: Checkout @@ -16,6 +17,11 @@ jobs: with: node-version: ${{matrix.node}} + - name: Setup emacs + uses: jcs090218/setup-emacs@master + with: + version: ${{ matrix.emacs-version }} + - name: Install eask run: npm install -g @emacs-eask/cli From 15be90691f50f61571f665d981fee1fde450216b Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 18:43:51 +0300 Subject: [PATCH 03/25] Github action full name --- .forgejo/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index f808655..d9c324f 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: node-version: ${{matrix.node}} - name: Setup emacs - uses: jcs090218/setup-emacs@master + uses: https://github.com/actions/jcs090218/setup-emacs@master with: version: ${{ matrix.emacs-version }} From 2f44d12c4cdf0302983e662b8250eb50dc86343b Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 19:00:37 +0300 Subject: [PATCH 04/25] let's try this --- .forgejo/install-emacs/action.yml | 13 +++ .forgejo/install-emacs/flake.lock | 42 +++++++++ .forgejo/install-emacs/flake.nix | 21 +++++ .forgejo/install-emacs/install-nix.sh | 123 ++++++++++++++++++++++++++ .forgejo/install-emacs/install.sh | 21 +++++ .forgejo/workflows/ci.yml | 2 +- 6 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 .forgejo/install-emacs/action.yml create mode 100644 .forgejo/install-emacs/flake.lock create mode 100644 .forgejo/install-emacs/flake.nix create mode 100644 .forgejo/install-emacs/install-nix.sh create mode 100644 .forgejo/install-emacs/install.sh diff --git a/.forgejo/install-emacs/action.yml b/.forgejo/install-emacs/action.yml new file mode 100644 index 0000000..f27e80d --- /dev/null +++ b/.forgejo/install-emacs/action.yml @@ -0,0 +1,13 @@ +name: 'Set up Emacs' +description: 'Install a specific Emacs version for use in your workflow.' +author: 'Steve Purcell' +inputs: + version: + description: 'The version of Emacs to install, e.g. "24.3", or "snapshot" for a recent development version.' +runs: + using: 'composite' + steps: + - run: ${{ github.action_path }}/install.sh + shell: bash + env: + INPUT_VERSION: ${{ inputs.version }} diff --git a/.forgejo/install-emacs/flake.lock b/.forgejo/install-emacs/flake.lock new file mode 100644 index 0000000..c25e6bb --- /dev/null +++ b/.forgejo/install-emacs/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1669165918, + "narHash": "sha256-hIVruk2+0wmw/Kfzy11rG3q7ev3VTi/IKVODeHcVjFo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3b400a525d92e4085e46141ff48cbf89fd89739e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} \ No newline at end of file diff --git a/.forgejo/install-emacs/flake.nix b/.forgejo/install-emacs/flake.nix new file mode 100644 index 0000000..9610be0 --- /dev/null +++ b/.forgejo/install-emacs/flake.nix @@ -0,0 +1,21 @@ +{ + description = "Setup Emacs Action"; + + inputs = + { + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ pkgs.shellcheck ]; + }; + } + ); +} \ No newline at end of file diff --git a/.forgejo/install-emacs/install-nix.sh b/.forgejo/install-emacs/install-nix.sh new file mode 100644 index 0000000..0fe2428 --- /dev/null +++ b/.forgejo/install-emacs/install-nix.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +set -euo pipefail + +if nix_path="$(type -p nix)" ; then + echo "Aborting: Nix is already installed at ${nix_path}" + exit +fi + +if [[ ($OSTYPE =~ linux) && ($INPUT_ENABLE_KVM == 'true') ]]; then + enable_kvm() { + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-install-nix-action-kvm.rules + sudo udevadm control --reload-rules && sudo udevadm trigger --name-match=kvm + } + + echo '::group::Enabling KVM support' + enable_kvm && echo 'Enabled KVM' || echo 'KVM is not available' + echo '::endgroup::' +fi + +# GitHub command to put the following log messages into a group which is collapsed by default +echo "::group::Installing Nix" + +# Create a temporary workdir +workdir=$(mktemp -d) +trap 'rm -rf "$workdir"' EXIT + +# Configure Nix +add_config() { + echo "$1" >> "$workdir/nix.conf" +} +add_config "show-trace = true" +# Set jobs to number of cores +add_config "max-jobs = auto" +if [[ $OSTYPE =~ darwin ]]; then + add_config "ssl-cert-file = /etc/ssl/cert.pem" +fi +# Allow binary caches for user +add_config "trusted-users = root ${USER:-}" +# Add a GitHub access token. +# Token-less access is subject to lower rate limits. +if [[ -n "${INPUT_GITHUB_ACCESS_TOKEN:-}" ]]; then + echo "::debug::Using the provided github_access_token for github.com" + add_config "access-tokens = github.com=$INPUT_GITHUB_ACCESS_TOKEN" +# Use the default GitHub token if available. +# Skip this step if running an Enterprise instance. The default token there does not work for github.com. +elif [[ -n "${GITHUB_TOKEN:-}" && $GITHUB_SERVER_URL == "https://github.com" ]]; then + echo "::debug::Using the default GITHUB_TOKEN for github.com" + add_config "access-tokens = github.com=$GITHUB_TOKEN" +else + echo "::debug::Continuing without a GitHub access token" +fi +# Append extra nix configuration if provided +if [[ -n "${INPUT_EXTRA_NIX_CONFIG:-}" ]]; then + add_config "$INPUT_EXTRA_NIX_CONFIG" +fi +if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "experimental-features" ]]; then + add_config "experimental-features = nix-command flakes" +fi +# Always allow substituting from the cache, even if the derivation has `allowSubstitutes = false`. +# This is a CI optimisation to avoid having to download the inputs for already-cached derivations to rebuild trivial text files. +if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "always-allow-substitutes" ]]; then + add_config "always-allow-substitutes = true" +fi + +# Nix installer flags +installer_options=( + --no-channel-add + --darwin-use-unencrypted-nix-store-volume + --nix-extra-conf-file "$workdir/nix.conf" +) + +# only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported +if [[ (! $INPUT_INSTALL_OPTIONS =~ "--no-daemon") && ($OSTYPE =~ darwin || -e /run/systemd/system) ]]; then + installer_options+=( + --daemon + --daemon-user-count "$(python3 -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)')" + ) +else + # "fix" the following error when running nix* + # error: the group 'nixbld' specified in 'build-users-group' does not exist + add_config "build-users-group =" + sudo mkdir -p /etc/nix + sudo chmod 0755 /etc/nix + sudo cp "$workdir/nix.conf" /etc/nix/nix.conf +fi + +if [[ -n "${INPUT_INSTALL_OPTIONS:-}" ]]; then + IFS=' ' read -r -a extra_installer_options <<< "$INPUT_INSTALL_OPTIONS" + installer_options=("${extra_installer_options[@]}" "${installer_options[@]}") +fi + +echo "installer options: ${installer_options[*]}" + +# There is --retry-on-errors, but only newer curl versions support that +curl_retries=5 +while ! curl -sS -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://releases.nixos.org/nix/nix-2.22.1/install}" +do + sleep 1 + ((curl_retries--)) + if [[ $curl_retries -le 0 ]]; then + echo "curl retries failed" >&2 + exit 1 + fi +done + +sh "$workdir/install" "${installer_options[@]}" + +# Set paths +echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" +# new path for nix 2.14 +echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH" + +if [[ -n "${INPUT_NIX_PATH:-}" ]]; then + echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV" +fi + +# Set temporary directory (if not already set) to fix https://github.com/cachix/install-nix-action/issues/197 +if [[ -z "${TMPDIR:-}" ]]; then + echo "TMPDIR=${RUNNER_TEMP}" >> "$GITHUB_ENV" +fi + +# Close the log message group which was opened above +echo "::endgroup::" diff --git a/.forgejo/install-emacs/install.sh b/.forgejo/install-emacs/install.sh new file mode 100644 index 0000000..42bd940 --- /dev/null +++ b/.forgejo/install-emacs/install.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Users should use install-nix-action if they want to customise how Nix is installed. + +set -euo pipefail + +if ! type -p nix &>/dev/null ; then + env INPUT_EXTRA_NIX_CONFIG= \ + INPUT_INSTALL_OPTIONS= \ + INPUT_INSTALL_URL= \ + INPUT_NIX_PATH="nixpkgs=channel:nixos-unstable" \ + INPUT_ENABLE_KVM=true \ + "$(dirname "$0")"/install-nix.sh + # Make the installed Nix immediately available here + source "$GITHUB_ENV" + while IFS= read -r dir; do PATH="$dir:$PATH"; done < "$GITHUB_PATH" +fi + +echo "::group::Configuring build cache and installing Emacs" +nix profile install --accept-flake-config "github:purcell/nix-emacs-ci#emacs-${INPUT_VERSION/./-}" +echo "::endgroup::" diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index d9c324f..16eb425 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: node-version: ${{matrix.node}} - name: Setup emacs - uses: https://github.com/actions/jcs090218/setup-emacs@master + uses: uses: ./.forgejo/install-emacs with: version: ${{ matrix.emacs-version }} From 9137bea67b196ae5e50c85ca5ddaf1be5aab5c95 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 19:04:04 +0300 Subject: [PATCH 05/25] Valid? --- .forgejo/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 16eb425..0f6f64f 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: node-version: ${{matrix.node}} - name: Setup emacs - uses: uses: ./.forgejo/install-emacs + uses: ./.forgejo/install-emacs with: version: ${{ matrix.emacs-version }} From 9d640a49a5442ac8d015efb7b98a81bde047619d Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 19:05:33 +0300 Subject: [PATCH 06/25] Valid? --- .forgejo/install-emacs/install-nix.sh | 0 .forgejo/install-emacs/install.sh | 0 .forgejo/workflows/ci.yml | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 .forgejo/install-emacs/install-nix.sh mode change 100644 => 100755 .forgejo/install-emacs/install.sh diff --git a/.forgejo/install-emacs/install-nix.sh b/.forgejo/install-emacs/install-nix.sh old mode 100644 new mode 100755 diff --git a/.forgejo/install-emacs/install.sh b/.forgejo/install-emacs/install.sh old mode 100644 new mode 100755 diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 0f6f64f..c8c5a32 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -1,7 +1,7 @@ on: [push] jobs: test: - name: Test config on ${{matrix.node}} + name: Test on ${{matrix.emacs-version}} runs-on: docker strategy: matrix: From 32391f944900b8fcbb77b06ef3d8fdfe8230d690 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 19:58:22 +0300 Subject: [PATCH 07/25] Remove sudo --- .forgejo/install-emacs/install-nix.sh | 6 +++--- .forgejo/workflows/ci.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.forgejo/install-emacs/install-nix.sh b/.forgejo/install-emacs/install-nix.sh index 0fe2428..f606947 100755 --- a/.forgejo/install-emacs/install-nix.sh +++ b/.forgejo/install-emacs/install-nix.sh @@ -79,9 +79,9 @@ else # "fix" the following error when running nix* # error: the group 'nixbld' specified in 'build-users-group' does not exist add_config "build-users-group =" - sudo mkdir -p /etc/nix - sudo chmod 0755 /etc/nix - sudo cp "$workdir/nix.conf" /etc/nix/nix.conf + mkdir -p /etc/nix + chmod 0755 /etc/nix + cp "$workdir/nix.conf" /etc/nix/nix.conf fi if [[ -n "${INPUT_INSTALL_OPTIONS:-}" ]]; then diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index c8c5a32..7898c96 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: node: ["20"] - emacs-version: [26.3, 27.2, 28.2, 29.1, snapshot] + emacs-version: ["29.1"] steps: - name: Checkout From 5773b4a4dd9d61c26f012a59dd1e9fe9953a327f Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 20:06:35 +0300 Subject: [PATCH 08/25] This? --- .forgejo/install-emacs/install-nix.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.forgejo/install-emacs/install-nix.sh b/.forgejo/install-emacs/install-nix.sh index f606947..6af4388 100755 --- a/.forgejo/install-emacs/install-nix.sh +++ b/.forgejo/install-emacs/install-nix.sh @@ -79,9 +79,11 @@ else # "fix" the following error when running nix* # error: the group 'nixbld' specified in 'build-users-group' does not exist add_config "build-users-group =" - mkdir -p /etc/nix - chmod 0755 /etc/nix - cp "$workdir/nix.conf" /etc/nix/nix.conf + apt-get update -qq + apt-get install -y sudo + sudo mkdir -p /etc/nix + sudo chmod 0755 /etc/nix + sudo cp "$workdir/nix.conf" /etc/nix/nix.conf fi if [[ -n "${INPUT_INSTALL_OPTIONS:-}" ]]; then From 25496624965448b82986c06696996bb9e26b86cf Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 20:13:19 +0300 Subject: [PATCH 09/25] Add emacs versions --- .forgejo/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 7898c96..bf5e7ee 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: node: ["20"] - emacs-version: ["29.1"] + emacs-version: ["snapshot", "28", "29"] steps: - name: Checkout From d9347fcc2255aa096902fd4abe9b5bc5fc3d62a5 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 20:14:14 +0300 Subject: [PATCH 10/25] Apparently they need to be with dots --- .forgejo/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index bf5e7ee..c2b27c8 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: node: ["20"] - emacs-version: ["snapshot", "28", "29"] + emacs-version: ["snapshot", "28.2", "29.1"] steps: - name: Checkout From 6db71f77c3c60d1e908112178b2f307589778b81 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 20:26:07 +0300 Subject: [PATCH 11/25] Cache nix --- .forgejo/install-emacs/action.yml | 14 ++++++++++++++ .forgejo/install-emacs/install-nix.sh | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.forgejo/install-emacs/action.yml b/.forgejo/install-emacs/action.yml index f27e80d..6fe1a2b 100644 --- a/.forgejo/install-emacs/action.yml +++ b/.forgejo/install-emacs/action.yml @@ -7,7 +7,21 @@ inputs: runs: using: 'composite' steps: + - name: Restore cached version + id: cache-restore + uses: https://code.forgejo.org/actions/cache/restore@v4 + with: + path: | + /nix/store + key: ${{ inputs.version }}-${{ hashFiles('flake.lock') }} - run: ${{ github.action_path }}/install.sh shell: bash env: INPUT_VERSION: ${{ inputs.version }} + - name: Cache version + id: cache-put + uses: https://code.forgejo.org/actions/cache/save@v4 + with: + path: | + /nix/store + key: ${{ inputs.version }}-${{ hashFiles('flake.lock') }} diff --git a/.forgejo/install-emacs/install-nix.sh b/.forgejo/install-emacs/install-nix.sh index 6af4388..75c0177 100755 --- a/.forgejo/install-emacs/install-nix.sh +++ b/.forgejo/install-emacs/install-nix.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +# Sudo is required by this installer +apt-get update -qq +apt-get install -y sudo + if nix_path="$(type -p nix)" ; then echo "Aborting: Nix is already installed at ${nix_path}" exit @@ -79,8 +83,6 @@ else # "fix" the following error when running nix* # error: the group 'nixbld' specified in 'build-users-group' does not exist add_config "build-users-group =" - apt-get update -qq - apt-get install -y sudo sudo mkdir -p /etc/nix sudo chmod 0755 /etc/nix sudo cp "$workdir/nix.conf" /etc/nix/nix.conf From 93731661a8f0bb79fb113799efa069ca8776f366 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 20:31:30 +0300 Subject: [PATCH 12/25] Cache not snapshots --- .forgejo/install-emacs/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.forgejo/install-emacs/action.yml b/.forgejo/install-emacs/action.yml index 6fe1a2b..7945785 100644 --- a/.forgejo/install-emacs/action.yml +++ b/.forgejo/install-emacs/action.yml @@ -10,10 +10,11 @@ runs: - name: Restore cached version id: cache-restore uses: https://code.forgejo.org/actions/cache/restore@v4 + if: inputs.version != 'snapshot' with: path: | /nix/store - key: ${{ inputs.version }}-${{ hashFiles('flake.lock') }} + key: ${{ inputs.version }}-${{ hashFiles('**/flake.lock') }} - run: ${{ github.action_path }}/install.sh shell: bash env: @@ -21,7 +22,8 @@ runs: - name: Cache version id: cache-put uses: https://code.forgejo.org/actions/cache/save@v4 + if: inputs.version != 'snapshot' with: path: | /nix/store - key: ${{ inputs.version }}-${{ hashFiles('flake.lock') }} + key: ${{ inputs.version }}-${{ hashFiles('**/flake.lock') }} From c32fedaa6a31edbde10da025a9e6898ae862d611 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 21:32:06 +0300 Subject: [PATCH 13/25] Build step --- .forgejo/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index c2b27c8..021b6ea 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -28,5 +28,8 @@ jobs: - name: Run tests run: eask test buttercup + - name: Build package to dist + run: eask package + - name: Uninstall eask run: npm uninstall -g @emacs-eask/cli From 005ce6d828a8c9a4e7f68605be820142b45f5a1e Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 21:42:35 +0300 Subject: [PATCH 14/25] Disable cache, it doesn't work anyway --- .forgejo/install-emacs/action.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.forgejo/install-emacs/action.yml b/.forgejo/install-emacs/action.yml index 7945785..f27e80d 100644 --- a/.forgejo/install-emacs/action.yml +++ b/.forgejo/install-emacs/action.yml @@ -7,23 +7,7 @@ inputs: runs: using: 'composite' steps: - - name: Restore cached version - id: cache-restore - uses: https://code.forgejo.org/actions/cache/restore@v4 - if: inputs.version != 'snapshot' - with: - path: | - /nix/store - key: ${{ inputs.version }}-${{ hashFiles('**/flake.lock') }} - run: ${{ github.action_path }}/install.sh shell: bash env: INPUT_VERSION: ${{ inputs.version }} - - name: Cache version - id: cache-put - uses: https://code.forgejo.org/actions/cache/save@v4 - if: inputs.version != 'snapshot' - with: - path: | - /nix/store - key: ${{ inputs.version }}-${{ hashFiles('**/flake.lock') }} From 2475965b801c09ec3304b4a94d159c64c5b96620 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 15 Aug 2024 22:27:34 +0300 Subject: [PATCH 15/25] Install deps and run tests --- .forgejo/workflows/ci.yml | 3 +++ tests/test-counsel-projectile.el | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 021b6ea..a8f0dae 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -25,6 +25,9 @@ jobs: - name: Install eask run: npm install -g @emacs-eask/cli + - name: Install deps + run: eask install-deps --dev + - name: Run tests run: eask test buttercup diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el index d616661..0d23712 100644 --- a/tests/test-counsel-projectile.el +++ b/tests/test-counsel-projectile.el @@ -1,5 +1,13 @@ -;;; -*- lexical-binding: t; -*- +;;; test-counsel-projectile.el --- Buttercup tests for counsel-projectile -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: -(describe "counsel-projectile" - (it "always passes" - (expect 1 :to-equal 1))) +(require 'buttercup) +(require 'counsel-projectile) + +;; Example test! +(describe "A suite" + (it "contains a spec with an expectation" + (expect counsel-projectile--buffers :to-be nil))) + +;;; test-counsel-projectile.el ends here From 8aada5b29a7609c52818538a258c88522f58d7c7 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Sun, 18 Aug 2024 19:02:36 +0300 Subject: [PATCH 16/25] Use with-simulated-input for tests --- Eask | 1 + counsel-projectile.el | 2 +- tests/test-counsel-projectile.el | 40 ++++++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Eask b/Eask index f2ee0d1..f507150 100644 --- a/Eask +++ b/Eask @@ -15,4 +15,5 @@ (depends-on "counsel") (development + (depends-on "with-simulated-input") (depends-on "buttercup")) diff --git a/counsel-projectile.el b/counsel-projectile.el index 8cc42b8..a13d618 100644 --- a/counsel-projectile.el +++ b/counsel-projectile.el @@ -58,7 +58,7 @@ with default value ACTION, to be used as `:action' parameter for COMMAND's `ivy-read' call. -This variable holds either a single action function, or an action +;; This variable holds either a single action function, or an action list whose first element is the index of the default action in the list and the remaining elements are the actions (a key, a function, and a name for each action)." diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el index 0d23712..8013965 100644 --- a/tests/test-counsel-projectile.el +++ b/tests/test-counsel-projectile.el @@ -1,13 +1,43 @@ ;;; test-counsel-projectile.el --- Buttercup tests for counsel-projectile -*- lexical-binding: t; -*- ;;; Commentary: ;;; Code: - -(require 'buttercup) +(require 'with-simulated-input) (require 'counsel-projectile) ;; Example test! -(describe "A suite" - (it "contains a spec with an expectation" - (expect counsel-projectile--buffers :to-be nil))) +(describe "counsel-projectile-switch-project with a mock" + (before-each + (spy-on 'ivy-read) + (spy-on 'projectile-project-root :and-return-value "/usr/fake-project") + (setq + projectile-known-projects '("/usr/fake-project" "~/some-project") + counsel-projectile-switch-project-action 'counsel-projectile-switch-project-action)) + (it "spies on ivy-read arguments" + (counsel-projectile-switch-project) + (expect 'projectile-project-root :to-have-been-called) + + (expect 'ivy-read :to-have-been-called-with + "[fake-project] Switch to project: " + '("/usr/fake-project" "~/some-project") + :preselect "/usr/fake-project" + :action counsel-projectile-switch-project-action + :require-match t + :sort nil + :caller 'counsel-projectile-switch-project))) + +(describe "counsel-projectile-switch-project with the real ivy-read" + (before-each + (spy-on 'projectile-project-root :and-return-value "/usr/fake-project") + (setq + counsel-projectile-switch-project-action 'counsel-projectile-switch-project-action)) + + (it "signals error when project is unknown" + (expect + (with-simulated-input "/usr/fake RET" + (condition-case err + (counsel-projectile-switch-project) + (file-missing + (error-message-string err)))) + :to-equal "Setting current directory: No such file or directory, /usr/fake-project"))) ;;; test-counsel-projectile.el ends here From 6e04a02ccf26c1c0ff9eb9f7e063dc004e459f34 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Sun, 18 Aug 2024 19:39:16 +0300 Subject: [PATCH 17/25] Indent correctly --- Eask | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Eask b/Eask index f507150..a3f8186 100644 --- a/Eask +++ b/Eask @@ -16,4 +16,4 @@ (development (depends-on "with-simulated-input") - (depends-on "buttercup")) + (depends-on "buttercup")) From 04edfc1ec200812ee19bb5c431aaa196f4fa3b85 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 19 Aug 2024 18:31:31 +0300 Subject: [PATCH 18/25] Test directly in docker maybe? --- .forgejo/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index a8f0dae..b2663e0 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -1,5 +1,22 @@ on: [push] jobs: + test_directly_in_docker: + runs-on: docker + name: "Test in docker on 29" + container: docker.io/silex/emacs:29.4-ci + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + + - name: Install deps + run: eask install-deps --dev + + - name: Run tests + run: eask test buttercup + + - name: Build package to dist + run: eask package + test: name: Test on ${{matrix.emacs-version}} runs-on: docker From 859d7480690e28582222169e935275a27e9f1f6b Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 19 Aug 2024 18:32:28 +0300 Subject: [PATCH 19/25] It won't work --- .forgejo/workflows/ci.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index b2663e0..a8f0dae 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -1,22 +1,5 @@ on: [push] jobs: - test_directly_in_docker: - runs-on: docker - name: "Test in docker on 29" - container: docker.io/silex/emacs:29.4-ci - steps: - - name: Checkout - uses: https://code.forgejo.org/actions/checkout@v4 - - - name: Install deps - run: eask install-deps --dev - - - name: Run tests - run: eask test buttercup - - - name: Build package to dist - run: eask package - test: name: Test on ${{matrix.emacs-version}} runs-on: docker From fdf4c9da848dbea6b26eca02a9cf83c8eff80696 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 19 Aug 2024 20:14:27 +0300 Subject: [PATCH 20/25] Add tests for last function I use --- tests/test-counsel-projectile.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el index 8013965..d5fb25a 100644 --- a/tests/test-counsel-projectile.el +++ b/tests/test-counsel-projectile.el @@ -40,4 +40,19 @@ (file-missing (error-message-string err)))) :to-equal "Setting current directory: No such file or directory, /usr/fake-project"))) + +(describe "counsel-projectile-find-file" + (before-each + (spy-on 'ivy-read) + (spy-on 'projectile-project-root :and-return-value user-emacs-directory)) + + (it "finds a file" + (counsel-projectile-find-file) + (expect 'ivy-read :to-have-been-called-with + "[29.1] Find file: " nil + :matcher 'counsel-projectile--find-file-matcher + :require-match t + :sort nil + :action counsel-projectile-find-file-action + :caller 'counsel-projectile-find-file))) ;;; test-counsel-projectile.el ends here From 5ac22ced29b0027d78460193a36ddcb9bdcdbd0c Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Tue, 20 Aug 2024 08:41:16 +0300 Subject: [PATCH 21/25] Remove with-simulated-input --- Eask | 1 - tests/test-counsel-projectile.el | 52 ++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Eask b/Eask index a3f8186..53d1357 100644 --- a/Eask +++ b/Eask @@ -15,5 +15,4 @@ (depends-on "counsel") (development - (depends-on "with-simulated-input") (depends-on "buttercup")) diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el index d5fb25a..62d98cc 100644 --- a/tests/test-counsel-projectile.el +++ b/tests/test-counsel-projectile.el @@ -1,11 +1,11 @@ ;;; test-counsel-projectile.el --- Buttercup tests for counsel-projectile -*- lexical-binding: t; -*- ;;; Commentary: ;;; Code: -(require 'with-simulated-input) (require 'counsel-projectile) +(require 'buttercup) ;; Example test! -(describe "counsel-projectile-switch-project with a mock" +(describe "counsel-projectile-switch-project" (before-each (spy-on 'ivy-read) (spy-on 'projectile-project-root :and-return-value "/usr/fake-project") @@ -13,43 +13,55 @@ projectile-known-projects '("/usr/fake-project" "~/some-project") counsel-projectile-switch-project-action 'counsel-projectile-switch-project-action)) - (it "spies on ivy-read arguments" + (it "calls ivy-read" (counsel-projectile-switch-project) (expect 'projectile-project-root :to-have-been-called) - - (expect 'ivy-read :to-have-been-called-with + (expect + 'ivy-read + :to-have-been-called-with "[fake-project] Switch to project: " '("/usr/fake-project" "~/some-project") :preselect "/usr/fake-project" - :action counsel-projectile-switch-project-action + :action 'counsel-projectile-switch-project-action :require-match t :sort nil :caller 'counsel-projectile-switch-project))) -(describe "counsel-projectile-switch-project with the real ivy-read" +(describe "counsel-projectile-rg" (before-each - (spy-on 'projectile-project-root :and-return-value "/usr/fake-project") - (setq - counsel-projectile-switch-project-action 'counsel-projectile-switch-project-action)) + (spy-on 'ivy-read) + (spy-on 'projectile-project-root :and-return-value "/usr/fake-project")) - (it "signals error when project is unknown" + (it "calls ivy-read" + (counsel-projectile-rg) (expect - (with-simulated-input "/usr/fake RET" - (condition-case err - (counsel-projectile-switch-project) - (file-missing - (error-message-string err)))) - :to-equal "Setting current directory: No such file or directory, /usr/fake-project"))) + 'ivy-read + :to-have-been-called-with + "[fake-project] rg: " + 'counsel-ag-function + :initial-input nil + :dynamic-collection t + :keymap '(keymap + (24 keymap (4 . counsel-cd)) + (67108903 . swiper-avy) + (27 keymap (113 . counsel-git-grep-query-replace)) + (12 . ivy-call-and-recenter)) + :history 'counsel-git-grep-history + :action 'counsel-git-grep-action + :require-match t + :caller 'counsel-rg))) (describe "counsel-projectile-find-file" (before-each (spy-on 'ivy-read) (spy-on 'projectile-project-root :and-return-value user-emacs-directory)) - (it "finds a file" + (it "calls ivy-read" (counsel-projectile-find-file) - (expect 'ivy-read :to-have-been-called-with - "[29.1] Find file: " nil + (expect + 'ivy-read + :to-have-been-called-with "[29.1] Find file: " + nil :matcher 'counsel-projectile--find-file-matcher :require-match t :sort nil From c4b79b28299b6bedc81379d53cf1397e1897c7fd Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 2 Sep 2024 12:45:18 +0300 Subject: [PATCH 22/25] Change emacs version --- .forgejo/workflows/ci.yml | 2 +- tests/test-counsel-projectile.el | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index a8f0dae..de23af0 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: node: ["20"] - emacs-version: ["snapshot", "28.2", "29.1"] + emacs-version: ["snapshot", "28.2", "29.4"] steps: - name: Checkout diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el index 62d98cc..db7d083 100644 --- a/tests/test-counsel-projectile.el +++ b/tests/test-counsel-projectile.el @@ -67,4 +67,7 @@ :sort nil :action counsel-projectile-find-file-action :caller 'counsel-projectile-find-file))) +;; Local Variables: +;; no-byte-compile: t +;; End: ;;; test-counsel-projectile.el ends here From a2c0085cf15c9c1654e09e36b0e369cc364b8ebc Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 2 Sep 2024 12:50:03 +0300 Subject: [PATCH 23/25] Use format instead of hardcode string --- tests/test-counsel-projectile.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-counsel-projectile.el b/tests/test-counsel-projectile.el index db7d083..f6a2e82 100644 --- a/tests/test-counsel-projectile.el +++ b/tests/test-counsel-projectile.el @@ -60,7 +60,7 @@ (counsel-projectile-find-file) (expect 'ivy-read - :to-have-been-called-with "[29.1] Find file: " + :to-have-been-called-with (format "[%s] Find file: " emacs-version) nil :matcher 'counsel-projectile--find-file-matcher :require-match t From 4561b9dde2a79bd36d99ae088a5f1c576ed23035 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 2 Sep 2024 12:56:54 +0300 Subject: [PATCH 24/25] Install ripgrep --- .forgejo/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index de23af0..8556dc1 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -17,6 +17,9 @@ jobs: with: node-version: ${{matrix.node}} + - name: Install ripgrep + run: apt-get install ripgrep -y + - name: Setup emacs uses: ./.forgejo/install-emacs with: From e664a7525676aec6bc3c8feda13e073d6e074318 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 2 Sep 2024 12:58:24 +0300 Subject: [PATCH 25/25] Install ripgrep --- .forgejo/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 8556dc1..7ced8e7 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: node-version: ${{matrix.node}} - name: Install ripgrep - run: apt-get install ripgrep -y + run: apt-get update -qq && apt-get install ripgrep -y - name: Setup emacs uses: ./.forgejo/install-emacs