[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/kotlin-mode fddd747e5b 5/5: Merge pull request #77 from ta
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/kotlin-mode fddd747e5b 5/5: Merge pull request #77 from taku0/add_linter |
Date: |
Mon, 23 Jan 2023 15:00:07 -0500 (EST) |
branch: elpa/kotlin-mode
commit fddd747e5b4736e8b27a147960f369b86179ddff
Merge: ddb3e5838e 8fbc1a9d74
Author: Gregg Hernandez <greggory.hz@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #77 from taku0/add_linter
Add GitHub Actions for tests and linters
---
.dir-locals.el | 8 ++++++++
.github/workflows/run-test.yml | 27 +++++++++++++++++++++++++++
Cask | 3 ++-
Makefile | 19 +++++++++++++------
kotlin-mode-indent.el | 4 ----
kotlin-mode-lexer.el | 2 --
kotlin-mode.el | 12 +++++++++++-
scripts/invoke_cask.sh | 18 ++++++++++++++++++
scripts/run_linter.sh | 19 +++++++++++++++++++
scripts/run_linter_in_docker.sh | 21 +++++++++++++++++++++
scripts/run_test.sh | 16 ++++++++++++++++
scripts/run_test_in_docker.sh | 23 +++++++++++++++++++++++
12 files changed, 158 insertions(+), 14 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000000..b3fb854d9c
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,8 @@
+((emacs-lisp-mode . ((package-lint-main-file . "kotlin-mode.el")
+ (eval . (checkdoc-minor-mode))
+ (indent-tabs-mode . nil)
+ (fill-column . 80)
+ (tab-width . 8)
+ (sentence-end-double-space . t)
+ (emacs-lisp-docstring-fill-column . 75)
+ (elisp-lint-indent-specs .
((kotlin-mode--save-mark-and-excursion . 0))))))
diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml
new file mode 100644
index 0000000000..7a1a818916
--- /dev/null
+++ b/.github/workflows/run-test.yml
@@ -0,0 +1,27 @@
+name: Run Tests
+
+on:
+ push:
+ branches: [ main, master ]
+ pull_request:
+ branches: [ main, master ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ continue-on-error: ${{matrix.version == 'snapshot'}}
+
+ strategy:
+ matrix:
+ # Cask does't support Emacs 24.
+ version: ['25.1', '25.2', '25.3', '26.1', '26.2', '26.3', '27.1',
'27.2', '28.1', '28.2', 'snapshot']
+
+ steps:
+ - uses: actions/checkout@v3
+ - uses: purcell/setup-emacs@master
+ with:
+ version: ${{ matrix.version }}
+ - name: Run linters
+ run: ./scripts/run_linter.sh
+ - name: Run tests
+ run: ./scripts/run_test.sh
diff --git a/Cask b/Cask
index 2755da6ab0..e2f44050f4 100644
--- a/Cask
+++ b/Cask
@@ -6,4 +6,5 @@
(development
(depends-on "ecukes")
(depends-on "ert-expectations")
- (depends-on "ert-runner"))
+ (depends-on "ert-runner")
+ (depends-on "elisp-lint"))
diff --git a/Makefile b/Makefile
index aa17634b0c..ab982e7176 100644
--- a/Makefile
+++ b/Makefile
@@ -48,9 +48,16 @@ clean:
test:
## Tests the package.
- $(CASK) exec $(EMACS) --batch -q \
- --eval "(add-to-list 'load-path \""$(shell readlink -f .)"\")" \
- --eval "(add-to-list 'load-path \""$(shell readlink -f .)"/test\")" \
- -f batch-byte-compile \
- *.el
- cask exec ert-runner -L . -L test
+ CASK="${CASK}" EMACS="${EMACS}" scripts/run_test.sh
+
+test_in_docker:
+## Tests the package in Docker.
+ CASK="${CASK}" EMACS="${EMACS}" scripts/run_test_in_docker.sh
+
+lint:
+## Run linters.
+ CASK="${CASK}" EMACS="${EMACS}" scripts/run_linter.sh
+
+lint_in_docker:
+## Run linters in Docker.
+ CASK="${CASK}" EMACS="${EMACS}" scripts/run_linter_in_docker.sh
diff --git a/kotlin-mode-indent.el b/kotlin-mode-indent.el
index bccfaa3792..401ef72467 100644
--- a/kotlin-mode-indent.el
+++ b/kotlin-mode-indent.el
@@ -3,10 +3,6 @@
;; Copyright (C) 2019 taku0
;; Authors: taku0 (http://github.com/taku0)
-;; Keywords: languages
-;; Package-Requires: ((emacs "24.3"))
-;; Version: 0.0.1
-;; URL: https://github.com/Emacs-Kotlin-Mode-Maintainers/kotlin-mode
;; This file is not part of GNU Emacs.
diff --git a/kotlin-mode-lexer.el b/kotlin-mode-lexer.el
index c19e999bc4..cf1b56d595 100644
--- a/kotlin-mode-lexer.el
+++ b/kotlin-mode-lexer.el
@@ -5,8 +5,6 @@
;; Author: Shodai Yokoyama (quantumcars@gmail.com)
;; taku0 (http://github.com/taku0)
-;; Keywords: languages
-;; Package-Requires: ((emacs "24.3"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
diff --git a/kotlin-mode.el b/kotlin-mode.el
index 32143cc4b6..f9ae1fb018 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -87,10 +87,20 @@ START and END define region within current buffer."
(interactive)
(kotlin-do-and-repl-focus 'kotlin-send-buffer))
+(defmacro kotlin-mode--save-mark-and-excursion (&rest body)
+ "Polyfill of `save-mark-and-excursion' for <25.1.
+
+For argument BODY, see `save-mark-and-excursion'."
+ (declare (indent 0) (debug t))
+ (let ((save-mark-and-excursion (if (fboundp 'save-mark-and-excursion)
+ #'save-mark-and-excursion
+ #'save-excursion)))
+ (cons save-mark-and-excursion body)))
+
(defun kotlin-send-block ()
"Send block to Kotlin interpreter."
(interactive)
- (save-mark-and-excursion
+ (kotlin-mode--save-mark-and-excursion
(mark-paragraph)
(kotlin-send-region (region-beginning) (region-end))))
diff --git a/scripts/invoke_cask.sh b/scripts/invoke_cask.sh
new file mode 100755
index 0000000000..23b24dbd46
--- /dev/null
+++ b/scripts/invoke_cask.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# A little wrapper for Cask. Used in Makefile.
+# If ${CASK} is executable, use it.
+# Otherwise, download the Cask to .cask/cask if not exists, then execute it.
+
+if command -v "${CASK}" > /dev/null
+then
+ "${CASK}" "$@"
+elif command -v .cask/cask/bin/cask > /dev/null
+then
+ .cask/cask/bin/cask "$@"
+else
+ mkdir -p .cask || exit 1
+ git clone --depth 1 https://github.com/cask/cask.git .cask/cask || exit 1
+ chmod a+x .cask/cask/bin/cask || exit 1
+ .cask/cask/bin/cask "$@"
+fi
diff --git a/scripts/run_linter.sh b/scripts/run_linter.sh
new file mode 100755
index 0000000000..61e55b283c
--- /dev/null
+++ b/scripts/run_linter.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Run linter. Used in Makefile.
+
+if ! [ -d ".cask/$(./scripts/invoke_cask.sh eval '(princ
emacs-version)')/elpa/elisp-lint-"* ]
+then
+ ./scripts/invoke_cask.sh install || exit 1
+fi
+
+./scripts/invoke_cask.sh emacs --version || exit 1
+rm -f *.elc test/*.elc || exit 1
+rm -f *-autoloads.el || exit 1
+./scripts/invoke_cask.sh emacs --batch -Q \
+ -l elisp-lint.el \
+ --eval '(setq elisp-lint--debug t)' \
+ -f elisp-lint-files-batch \
+ *.el || exit 1
+rm -f *.elc test/*.elc || exit 1
+rm -f *-autoloads.el || exit 1
diff --git a/scripts/run_linter_in_docker.sh b/scripts/run_linter_in_docker.sh
new file mode 100755
index 0000000000..44ebf6bc78
--- /dev/null
+++ b/scripts/run_linter_in_docker.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Run linter in Docker. Used in Makefile.
+
+# Cask does't support Emacs 24.
+for version in 28 27 26 25 # 24
+do
+ docker \
+ run \
+ --rm \
+ --volume="$(pwd)":/src \
+ --user="$(id -u):$(id -g)" \
+ --workdir="/src" \
+ --env=ELDEV_DIR=/src/.eldev \
+ --env=HOME=/tmp \
+ silex/emacs:${version} \
+ bash -c "/src/scripts/run_linter.sh" \
+ || exit 1
+done
+
+echo "done"
diff --git a/scripts/run_test.sh b/scripts/run_test.sh
new file mode 100755
index 0000000000..cc38930d86
--- /dev/null
+++ b/scripts/run_test.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# Run tests. Used in Makefile.
+
+if ! [ -d ".cask/$(./scripts/invoke_cask.sh eval '(princ
emacs-version)')/elpa/ert-runner-"* ]
+then
+ ./scripts/invoke_cask.sh install || exit 1
+fi
+
+./scripts/invoke_cask.sh emacs --version || exit 1
+./scripts/invoke_cask.sh emacs --batch -q \
+ --eval "(add-to-list 'load-path \"$(readlink -f .)\")" \
+ --eval "(add-to-list 'load-path \"$(readlink -f .)/test\")" \
+ -f batch-byte-compile \
+ *.el test/*.el || exit 1
+./scripts/invoke_cask.sh exec ert-runner -L . -L test
diff --git a/scripts/run_test_in_docker.sh b/scripts/run_test_in_docker.sh
new file mode 100755
index 0000000000..2e3dc69d03
--- /dev/null
+++ b/scripts/run_test_in_docker.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Run tests in Docker. Used in Makefile.
+
+# Cask does't support Emacs 24.
+for version in 28 27 26 25 # 24
+do
+ rm -f *.elc test/*.elc
+ rm -f *-autoloads.el
+ docker \
+ run \
+ --rm \
+ --volume="$(pwd)":/src \
+ --user="$(id -u):$(id -g)" \
+ --workdir="/src" \
+ --env=ELDEV_DIR=/src/.eldev \
+ --env=HOME=/tmp \
+ silex/emacs:${version} \
+ bash -c "/src/scripts/run_test.sh" \
+ || exit 1
+done
+
+echo "done"