Skip to content

Commit 994691d

Browse files
authored
Emacs test pipeline (#1301)
This PR creates a workflow to test the Emacs package with different version of Eglot, Math-symbol-lists and Highlight. Note the script used for this purpose hacks the installation process of Elpa to install specific versions of the dependencies because Elpa does not allow as far as I know to install specific (previous) versions of packages.
1 parent 1db22dc commit 994691d

File tree

3 files changed

+191
-0
lines changed

3 files changed

+191
-0
lines changed

.github/workflows/emacs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# check compilation with previous versions of ocaml
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
push:
7+
paths:
8+
- '.github/workflows/emacs.yml'
9+
- 'editors/emacs/**'
10+
workflow_dispatch:
11+
12+
jobs:
13+
test_compile:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
eglot-version: [1.9, 0]
18+
math-symbol-list-version: [1.2.1, 1.3, 0]
19+
highlight-version: [20250724.2154, 20250815.1830, 0]
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@v4
24+
- name: build lambdapi-mode
25+
run: make -C editors/emacs dist
26+
- name: install lambdapi-mode
27+
run: |
28+
chmod +x installAndLaunch.sh
29+
./installAndLaunch.sh lambdapi-mode 1.1.0 /snap/bin/emacs ${{ matrix.eglot-version }} ${{ matrix.math-symbol-list-version }} ${{ matrix.highlight-version }}
30+
working-directory: editors/emacs/

editors/emacs/clean.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
sudo apt remove --purge emacs emacs-common
6+
sudo snap remove --purge emacs
7+
echo removing conf files
8+
rm -rf ~/.emacs.d ~/.emacs ~/.emacs.el ~/.config/emacs
9+
if [ "$1" = "--all" ]; then
10+
echo "removing .emacs.d configuration forlder"
11+
rm -fr ~/.emacs.d
12+
fi

editors/emacs/installAndLaunch.sh

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/bin/bash
2+
3+
set -e
4+
NAME="$1"
5+
VERSION="$2"
6+
BIN="$3"
7+
EGLOT_V="$4"
8+
MATH_SYMB_V="$5"
9+
HIGHLIGHT_V="$6"
10+
11+
# For instance, one can run the scrupt with ./installAndLaunch.sh lambdapi-mode 1.1.0 /snap/bin/emacs 1.5 1.3 20210318.2248 (Does not work because Eglot.V.1.5 is too old)
12+
# ./installAndLaunch.sh lambdapi-mode 1.1.0 /snap/bin/emacs 1.18 1.3 20210318.2248 Does not work because Eglot repo stoped using tags since 2012.
13+
# For using the latest commit of a library just use version 0. For instance : ./installAndLaunch.sh lambdapi-mode 1.1.0 /snap/bin/emacs 0 1.3 0
14+
15+
convertVersionToCommitDate() {
16+
local input="$1"
17+
local date_part=${input%%.*}
18+
19+
printf "%s-%s-%s %s:%s\n" \
20+
"${date_part:0:4}" \
21+
"${date_part:4:2}" \
22+
"${date_part:6:2}"
23+
}
24+
25+
26+
echo "📦 Installation d'Emacs..."
27+
sudo snap install emacs --classic
28+
29+
echo "📁 Préparation du dossier de configuration Emacs..."
30+
mkdir -p ~/.emacs.d
31+
32+
echo "📝 Écriture du fichier init.el avec straight.el et Eglot 1.17..."
33+
cat <<'EOF' > ~/.emacs.d/init.el
34+
(require 'package)
35+
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
36+
(setq package-check-signature nil)
37+
(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/eglot/"))
38+
(require 'eglot)
39+
(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/math-symbol-lists/"))
40+
(require 'math-symbol-lists)
41+
(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/highlight/"))
42+
(require 'highlight)
43+
EOF
44+
echo "creating elpa folder"
45+
mkdir -p ~/.emacs.d/elpa/
46+
47+
echo "cloning dependencies repos"
48+
if [ ! -d ~/.emacs.d/elpa/eglot ]; then
49+
if [[ ${EGLOT_V} == "0" ]]; then # ignore branch
50+
git clone --depth 1 https://github.com/joaotavora/eglot.git ~/.emacs.d/elpa/eglot
51+
EGLOT_V="1.9"
52+
else
53+
git clone --depth 1 --branch ${EGLOT_V} https://github.com/joaotavora/eglot.git ~/.emacs.d/elpa/eglot
54+
fi
55+
echo "Eglot cloned to " ~/.emacs.d/elpa/eglot
56+
else
57+
echo "Eglot is already cloned. Skipping"
58+
fi
59+
if [ ! -d ~/.emacs.d/elpa/math-symbol-lists ]; then
60+
if [[ ${MATH_SYMB_V} == "0" ]]; then # ignore branch
61+
git clone --depth 1 https://github.com/vspinu/math-symbol-lists.git ~/.emacs.d/elpa/math-symbol-lists
62+
MATH_SYMB_V=1.2.1
63+
else
64+
git clone --depth 1 --branch v${MATH_SYMB_V} https://github.com/vspinu/math-symbol-lists.git ~/.emacs.d/elpa/math-symbol-lists
65+
fi
66+
echo "math-symbol-lists cloned to " ~/.emacs.d/elpa/math-symbol-lists
67+
else
68+
echo "math-symbol-lists is already cloned. Skipping"
69+
fi
70+
71+
if [ ! -d ~/.emacs.d/elpa/highlight ]; then
72+
commit_date=$(convertVersionToCommitDate ${HIGHLIGHT_V})
73+
git clone https://github.com/emacsmirror/highlight.git ~/.emacs.d/elpa/highlight
74+
echo "cheking out to ${commit_date}. If commit does not exist (i.e. 0) it is just ignored."
75+
if [[ ${HIGHLIGHT_V} == "0" ]]; then # ignore branch
76+
# git -C ~/.emacs.d/elpa/highlight checkout $(git -C ~/.emacs.d/elpa/highlight rev-list -n 1 --after="${commit_date}" master)
77+
HIGHLIGHT_V=20250815.1830
78+
else
79+
git -C ~/.emacs.d/elpa/highlight checkout $(git -C ~/.emacs.d/elpa/highlight rev-list -n 1 --after="${commit_date}" master)
80+
fi
81+
echo "highlight cloned to " ~/.emacs.d/elpa/highlight
82+
else
83+
echo "Highlight is already cloned. Skipping"
84+
fi
85+
86+
echo "updating version in Elpa"
87+
echo "(define-package \"highlight\" \"${HIGHLIGHT_V}\")" > ~/.emacs.d/elpa/highlight/highlight-pkg.el
88+
echo "(define-package \"eglot\" \"${EGLOT_V}\")" > ~/.emacs.d/elpa/eglot/eglot-pkg.el
89+
echo "(define-package \"math-symbol-lists\" \"${MATH_SYMB_V}\")" > ~/.emacs.d/elpa/math-symbol-lists/math-symbol-lists-pkg.el
90+
91+
touch ~/.emacs.d/elpa/math-symbol-lists/math-symbol-lists-autoloads.el
92+
touch ~/.emacs.d/elpa/highlight/highlight-autoloads.el
93+
94+
echo "🚀 Premier lancement d’Emacs pour déclencher l’installation..."
95+
# (package-refresh-contents)
96+
PATH="$BIN:$PATH" emacs \
97+
-l ~/.emacs.d/init.el \
98+
--eval "(package-install-file \"${NAME}-${VERSION}.tar\")" \
99+
--batch \
100+
# # --eval "(require-package 'math-symbol-lists)" \
101+
echo "🎉 Terminé ! Lance Emacs normalement pour commencer à coder avec Eglot 1.17."
102+
103+
# (use-package eglot)
104+
# (use-package math-symbol-lists)
105+
# (use-package highlight)
106+
# (require-package eglot)
107+
# (require-package math-symbol-lists)
108+
# (require-package highlight)
109+
110+
# curl highilight and math-symbol-lists from https://elpa.gnu.org/packages/math-symbol-lists.html
111+
# extract with tar --lzip -xvf math-symbol-lists-1.1.tar.lz
112+
# or lzip -d math-symbol-lists-1.2.1.el.lz
113+
114+
# move to /home/abdelghani/.emacs.d/elpa/math-symbol-lists and /home/abdelghani/.emacs.d/elpa/highlight
115+
# echo ";; -*- no-byte-compile: t; lexical-binding: nil -*-
116+
#(define-package "highlight" "20210318.2248"
117+
# "Highlighting commands."
118+
# ()
119+
# :url "https://www.emacswiki.org/emacs/download/highlight.el"
120+
# :commit "28557cb8d99b96eb509aaec1334c7cdda162517f"
121+
# :revdesc "28557cb8d99b"
122+
# :keywords '("faces" "help" "local")
123+
# :maintainers '(("Drew Adams (concat \"drew.adams\" \"oracle\" \".com\"" . "\"@\" ")))
124+
# " > elpa/highlight-20210318.2248/highlight-pkg.el
125+
# echo ";; -*- no-byte-compile: t; lexical-binding: nil -*-
126+
# (define-package "math-symbol-lists" "1.2.1"
127+
# "Lists of Unicode math symbols and latex commands."
128+
# ()
129+
# :url "https://github.com/vspinu/math-symbol-lists"
130+
# :commit "ac3eb053d3b576fcdd192b0ac6ad5090ea3a7079"
131+
# :revdesc "ac3eb053d3b5"
132+
# :keywords '("unicode" "symbols" "mathematics")
133+
# :authors '(("Vitalie Spinu" . "[email protected]"))
134+
# :maintainers '(("Vitalie Spinu" . "[email protected]")))
135+
# " > elpa/math-symbol-lists/math-symbol-lists-pkg.el
136+
137+
# REplace versions in *-pkg.el files
138+
139+
140+
# echo
141+
# PATH="$BIN:$PATH" emacs \
142+
# --batch \
143+
# -l ~/.emacs.d/init.el \
144+
# --eval="(package-refresh-contents) "
145+
146+
# echo "\
147+
# " >> ~/.emacs.d/init.el
148+
149+

0 commit comments

Comments
 (0)