Skip to content

Commit

Permalink
feat: check indentation in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jtbx committed Aug 5, 2024
1 parent 2d7a20b commit f1163c5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Emacs Tests
name: Test .el files

on:
push:
Expand All @@ -12,11 +12,10 @@ jobs:
- name: Checkout source
uses: actions/checkout@v3

- name: Download Emacs25 package
run: wget http://mirrors.kernel.org/ubuntu/pool/main/e/emacs25/emacs25-nox_25.2+1-6_amd64.deb http://mirrors.kernel.org/ubuntu/pool/main/e/emacs25/emacs25-bin-common_25.2+1-6_amd64.deb http://mirrors.kernel.org/ubuntu/pool/main/e/emacs25/emacs25-common_25.2+1-6_all.deb http://mirrors.kernel.org/ubuntu/pool/main/e/emacsen-common/emacsen-common_2.0.8_all.deb

- name: Install Emacs
run: sudo apt-get install --allow-downgrades ./emacs25-nox_25.2+1-6_amd64.deb ./emacs25-bin-common_25.2+1-6_amd64.deb ./emacs25-common_25.2+1-6_all.deb ./emacsen-common_2.0.8_all.deb
- name: Install Emacs 25
run: |
wget http://mirrors.kernel.org/ubuntu/pool/main/e/emacs25/emacs25-nox_25.2+1-6_amd64.deb http://mirrors.kernel.org/ubuntu/pool/main/e/emacs25/emacs25-bin-common_25.2+1-6_amd64.deb http://mirrors.kernel.org/ubuntu/pool/main/e/emacs25/emacs25-common_25.2+1-6_all.deb http://mirrors.kernel.org/ubuntu/pool/main/e/emacsen-common/emacsen-common_2.0.8_all.deb http://mirrors.kernel.org/ubuntu/pool/universe/c/compat-el/elpa-compat_29.1.4.4+dfsg-1_all.deb
sudo apt-get install --allow-downgrades ./emacs25-nox_25.2+1-6_amd64.deb ./emacs25-bin-common_25.2+1-6_amd64.deb ./emacs25-common_25.2+1-6_all.deb ./emacsen-common_2.0.8_all.deb ./elpa-compat_29.1.4.4+dfsg-1_all.deb
- name: Install Just
uses: extractions/setup-just@v1
Expand All @@ -27,3 +26,9 @@ jobs:

- name: Run tests
run: just test

- name: Check indentation
run: emacs --script scripts/indent-lisp-files.el

- name: Compare changes
run: git diff --exit-code
22 changes: 22 additions & 0 deletions scripts/indent-lisp-files.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
;;; indent-lisp-files.el --- call `indent-region' over all Lisp files -*- lexical-binding: t; -*-

(require 'seq)
(when (version< emacs-version "29.1")
(require 'compat)) ; file-name-parent-directory

(defun .el-files-in (directory)
(seq-filter #'(lambda (path) (string-match "^.+\\.el$" path))
(directory-files directory)))

(let*
((root-path (file-name-parent-directory
(file-name-parent-directory load-file-name)))
(files (.el-files-in root-path))
(scripts (.el-files-in (concat root-path "/scripts"))))
(dolist (file (append files scripts))
(with-current-buffer (find-file-noselect file)
(setq indent-tabs-mode nil
lisp-indent-offset 2)
(indent-region (point-min) (point-max))
(save-buffer)
(kill-buffer (current-buffer)))))

0 comments on commit f1163c5

Please sign in to comment.