Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add CI with GitHub Action #410

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# * test.yml --- Test libvterm using makem.sh on GitHub Actions

# Based on Alphapapa's makem.sh
# https://github.com/alphapapa/makem.sh

# Based on Steve Purcell's examples at
# <https://github.com/purcell/setup-emacs/blob/master/.github/workflows/test.yml>,
# <https://github.com/purcell/package-lint/blob/master/.github/workflows/test.yml>.

# * License:

# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# * Code:

name: "CI"
on:
pull_request:
push:
# Comment out this section to enable testing of all branches.
# branches:
# - master

jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
emacs_version:
- snapshot
use_system_libvterm:
- no
- yes
steps:
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}

- uses: actions/checkout@v2

- name: Grab makem.sh
uses: wei/wget@v1
with:
args: https://raw.githubusercontent.com/alphapapa/makem.sh/master/makem.sh

- name: Initialize sandbox
run: |
SANDBOX_DIR=$(mktemp -d) || exit 1
echo "{SANDBOX_DIR}={$SANDBOX_DIR}" >> $GITHUB_ENV
bash makem.sh -vv --sandbox=$SANDBOX_DIR --install-deps --install-linters

- name: Install CMake
run: nix-env -f "<nixpkgs>" -iA cmake

- name: Install other dependencies
run: nix-env -f "<nixpkgs>" -iA libtool

- name: Install spell-checker
run: |
nix-env -f "<nixpkgs>" -iA hunspell
nix-env -f "<nixpkgs>" -iA hunspellDicts.en_US

- name: Compile vterm
if: ${{matrix.use_system_libvterm == 'yes'}}
run: nix-shell -p libvterm-neovim --run "mkdir build && cd build && cmake .. && make"

- name: Require vterm
if: ${{matrix.use_system_libvterm == 'no'}}
run: bash makem.sh -vv --sandbox=$SANDBOX batch -- --eval "(require 'vterm)"

- name: Require vterm
run: bash makem.sh -vv --sandbox=$SANDBOX batch -- --eval "(require 'vterm)"

- name: Lint
# We only need to lint once
continue-on-error: true
run: bash makem.sh -vv --sandbox=$SANDBOX_DIR --exclude makem-pre-test-conf.el lint

# - name: Test
# if: always() # Run test even if linting fails.
# run: bash makem.sh -vv --sandbox=$SANDBOX_DIR test

# Local Variables:
# eval: (outline-minor-mode)
# End:
24 changes: 24 additions & 0 deletions makem-pre-test-conf.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
;;; makem-pre-test-conf.el --- Configuration for tests -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2020 Gabriele Bozzola
;;
;; Author: Gabriele Bozzola <http://github/sbozzolo>
;; Maintainer: Gabriele Bozzola <[email protected]>
;; Created: July 25, 2020
;; Modified: July 25, 2020
;; Version: 0.0.1
;; Keywords:
;; Package-Requires: ((emacs 25.1))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; https://github.com/alphapapa/makem.sh/issues/24
;;
;;; Code:

(setq vterm-always-compile-module t)

(provide 'a-makem-pre-test-conf)
;;; makem-pre-test-conf.el ends here
49 changes: 26 additions & 23 deletions vterm.el
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ confirmation before compiling."
"Name of the buffer used for compiling vterm-module.")

(defun vterm-module--cmake-is-available ()
"Return t if cmake is available.
"Return t if CMake is available.
CMake is needed to build vterm, here we check that we can find
the executable."

Expand Down Expand Up @@ -129,7 +129,7 @@ the executable."
;; If the vterm-module is not compiled yet, compile it
(unless (require 'vterm-module nil t)
(if (or vterm-always-compile-module
(y-or-n-p "Vterm needs `vterm-module' to work. Compile it now? "))
(y-or-n-p "Vterm needs `vterm-module' to work. Compile it now? "))
(progn
(vterm-module-compile)
(require 'vterm-module))
Expand All @@ -141,16 +141,16 @@ the executable."
(declare-function display-line-numbers-update-width "display-line-numbers")

;; Generate this list with:
;; awk -F\" '/bind_function*/ {print "(declare-function", $2, "\"vterm-module\")"}' vterm-module.c
(declare-function vterm--new "vterm-module")
(declare-function vterm--update "vterm-module")
(declare-function vterm--redraw "vterm-module")
(declare-function vterm--write-input "vterm-module")
(declare-function vterm--set-size "vterm-module")
(declare-function vterm--set-pty-name "vterm-module")
(declare-function vterm--get-pwd-raw "vterm-module")
(declare-function vterm--reset-point "vterm-module")
(declare-function vterm--get-icrnl "vterm-module")
;; awk -F\" '/bind_function*/ {print "(declare-function", $2, "\"ext:vterm-module\" t t)"}' vterm-module.c
(declare-function vterm--new "ext:vterm-module" t t)
(declare-function vterm--update "ext:vterm-module" t t)
(declare-function vterm--redraw "ext:vterm-module" t t)
(declare-function vterm--write-input "ext:vterm-module" t t)
(declare-function vterm--set-size "ext:vterm-module" t t)
(declare-function vterm--set-pty-name "ext:vterm-module" t t)
(declare-function vterm--get-pwd-raw "ext:vterm-module" t t)
(declare-function vterm--reset-point "ext:vterm-module" t t)
(declare-function vterm--get-icrnl "ext:vterm-module" t t)

(require 'subr-x)
(require 'cl-lib)
Expand Down Expand Up @@ -233,8 +233,8 @@ Each function is called with two arguments: the vterm buffer of
the process if any, and a string describing the event passed from
the sentinel.

This hook applies only to new vterms, created after setting this
value with `add-hook'.
This hook applies only to new vterm buffers, created after
setting this value with `add-hook'.

Note that this hook will not work if another package like
`shell-pop' sets its own sentinel to the `vterm' process."
Expand Down Expand Up @@ -324,8 +324,8 @@ used to set the current directory and prompt location. This
detection method is the most-reliable. To use it, you have
to change your shell prompt to print 51;A.

The second method is using a regular expression. This method does
not require any shell-side configuration. See
The second method is using a regular expression. This method does
not require any shell-side configuration. See
`term-prompt-regexp', for more information."
:type 'boolean
:group 'vterm)
Expand Down Expand Up @@ -434,7 +434,7 @@ Only background is used."
(defvar vterm-timer-delay 0.1
"Delay for refreshing the buffer after receiving updates from libvterm.

A larger delary improves performance when receiving large bursts
A larger delay improves performance when receiving large bursts
of data. If nil, never delay. The units are seconds.")

;;; Keybindings
Expand Down Expand Up @@ -463,7 +463,7 @@ of data. If nil, never delay. The units are seconds.")

;; Function keys and most of C- and M- bindings
(defun vterm--exclude-keys (map exceptions)
"Remove EXCEPTIONS from the keys bound by `vterm-define-keys'.
"Remove EXCEPTIONS from MAP the keys bound by `vterm-define-keys'.

Exceptions are defined by `vterm-keymap-exceptions'."
(mapc (lambda (key)
Expand Down Expand Up @@ -598,7 +598,7 @@ Exceptions are defined by `vterm-keymap-exceptions'."
;; mode can break this, leading to segmentation faults.
(add-hook 'change-major-mode-hook
(lambda () (interactive)
(user-error "You cannot change major mode in vterm buffers")) nil t)
(user-error "You cannot change major mode in vterm buffers")) nil t)

(vterm--set-pty-name vterm--term (process-tty-name vterm--process))
(process-put vterm--process 'adjust-window-size-function
Expand Down Expand Up @@ -1016,13 +1016,13 @@ Argument EVENT process event."
(setq width (+ width (or display-line-numbers-width 0) 4)))
width))

(defun vterm--delete-lines (line-num count &optional delete-whole-line)
"Delete COUNT lines from LINE-NUM.
If LINE-NUM is negative backward-line from end of buffer.
(defun vterm--delete-lines (line-number count &optional delete-whole-line)
"Delete COUNT lines from LINE-NUMBER.
If LINE-NUMBER is negative backward-line from end of buffer.
If option DELETE-WHOLE-LINE is non-nil, then this command kills
the whole line including its terminating newline"
(save-excursion
(when (vterm--goto-line line-num)
(when (vterm--goto-line line-number)
(delete-region (point) (point-at-eol count))
(when (and delete-whole-line
(looking-at "\n"))
Expand Down Expand Up @@ -1261,3 +1261,6 @@ can find them and remove them."

(provide 'vterm)
;;; vterm.el ends here

;;; LocalWords: vterm libvterm CMake scrollback arg
;;; LocalWords: zsh html tldp http whitelisted