From 2fd45d3c46f21d42ec121231fed576a4d0d181d1 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 8 Aug 2024 11:33:08 +1200 Subject: [PATCH] ci: run .el files against byte-compile-file --- .github/workflows/{test.yaml => check.yml} | 6 +++--- .gitignore | 1 + scripts/{indent-lisp-files.el => check-lisp-files.el} | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) rename .github/workflows/{test.yaml => check.yml} (93%) create mode 100644 .gitignore rename scripts/{indent-lisp-files.el => check-lisp-files.el} (81%) diff --git a/.github/workflows/test.yaml b/.github/workflows/check.yml similarity index 93% rename from .github/workflows/test.yaml rename to .github/workflows/check.yml index fd734e8..6660347 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/check.yml @@ -27,8 +27,8 @@ jobs: - name: Run tests run: just test - - name: Check indentation - run: emacs --script scripts/indent-lisp-files.el + - name: Check .el files + run: emacs --script scripts/check-lisp-files.el - - name: Compare changes + - name: Check indentation run: git diff --exit-code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c531d98 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.elc diff --git a/scripts/indent-lisp-files.el b/scripts/check-lisp-files.el similarity index 81% rename from scripts/indent-lisp-files.el rename to scripts/check-lisp-files.el index f4d55f5..03bfaf3 100644 --- a/scripts/indent-lisp-files.el +++ b/scripts/check-lisp-files.el @@ -1,5 +1,6 @@ ;;; indent-lisp-files.el --- call `indent-region' over all Lisp files -*- lexical-binding: t; -*- +(require 'bytecomp) (require 'seq) (when (version< emacs-version "29.1") (require 'compat)) ; file-name-parent-directory @@ -17,9 +18,13 @@ (files (.el-files-in root-path)) (scripts (.el-files-in (concat root-path "/scripts/")))) (dolist (file (append files scripts)) + (setq + byte-compile-error-on-warn t + indent-tabs-mode nil + lisp-indent-offset 2) + (unless (byte-compile-file file) + (error "byte-compile-file failed (%s)" file)) (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)))))