Skip to content

Commit 22a016f

Browse files
authored
Merge pull request #91 from jcs-PR/ci
Add CI test for windows and macOS
2 parents be9f979 + 0283c80 commit 22a016f

File tree

3 files changed

+105
-7
lines changed

3 files changed

+105
-7
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ on:
99
- master
1010

1111
jobs:
12-
tests:
13-
runs-on: ubuntu-latest
12+
unix-test:
13+
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
16+
os: [ubuntu-latest, macos-latest]
1617
emacs-version:
1718
- 26.1
1819
- 26.2
@@ -21,7 +22,7 @@ jobs:
2122
- snapshot
2223

2324
steps:
24-
- uses: actions/checkout@v1
25+
- uses: actions/checkout@v2
2526

2627
- uses: actions/setup-python@v2
2728
with:
@@ -41,5 +42,30 @@ jobs:
4142
version: 0.8.4
4243

4344
- name: Run tests
44-
run: 'make ci'
45+
run: 'make unix-ci'
4546

47+
windows-test:
48+
runs-on: windows-latest
49+
strategy:
50+
matrix:
51+
emacs-version:
52+
- 26.1
53+
- 26.2
54+
- 26.3
55+
- 27.1
56+
- snapshot
57+
58+
steps:
59+
- uses: actions/checkout@v2
60+
61+
- uses: actions/setup-python@v2
62+
with:
63+
python-version: '3.6'
64+
architecture: 'x64'
65+
66+
- uses: jcs090218/setup-emacs-windows@master
67+
with:
68+
version: ${{ matrix.emacs-version }}
69+
70+
- name: Run tests
71+
run: 'make windows-ci'

Makefile

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ SHELL=/usr/bin/env bash
33
EMACS ?= emacs
44
CASK ?= cask
55

6+
WINDOWS-INSTALL=-l test/windows-bootstrap.el
7+
68
INIT="(progn \
79
(require 'package) \
810
(push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
@@ -16,14 +18,30 @@ LINT="(progn \
1618
(setq package-lint-main-file \"lsp-dart.el\") \
1719
(package-lint-batch-and-exit))"
1820

21+
ARCHIVES-INIT="(progn \
22+
(require 'package) \
23+
(setq package-archives '((\"melpa\" . \"https://melpa.org/packages/\") \
24+
(\"gnu\" . \"https://elpa.gnu.org/packages/\"))))"
25+
26+
# NOTE: Bad request occurs during Cask installation on macOS in Emacs
27+
# version 26.x. By setting variable `package-archives` manually resolved
28+
# this issue.
1929
build:
30+
@$(CASK) $(EMACS) -Q --batch \
31+
--eval $(ARCHIVES-INIT)
2032
cask install
2133

22-
ci: clean build compile checkdoc lint test
34+
35+
unix-ci: WINDOWS-INSTALL=
36+
unix-ci: clean build compile checkdoc lint unix-test
37+
38+
windows-ci: CASK=
39+
windows-ci: clean compile checkdoc lint windows-test
2340

2441
compile:
2542
@echo "Compiling..."
2643
@$(CASK) $(EMACS) -Q --batch \
44+
$(WINDOWS-INSTALL) \
2745
-L . \
2846
--eval '(setq byte-compile-error-on-warn t)' \
2947
-f batch-byte-compile \
@@ -57,9 +75,17 @@ lint:
5775
--eval $(LINT) \
5876
*.el
5977

60-
test:
78+
unix-test:
6179
@$(CASK) exec ert-runner
6280

81+
windows-test:
82+
@$(EMACS) -Q --batch \
83+
$(WINDOWS-INSTALL) \
84+
-L . \
85+
$(LOAD-TEST-FILES) \
86+
--eval "(ert-run-tests-batch-and-exit \
87+
'(and (not (tag no-win)) (not (tag org))))"
88+
6389
clean:
6490
rm -rf .cask *.elc
6591

@@ -76,4 +102,4 @@ tag:
76102
%:
77103
@:
78104

79-
.PHONY : ci compile checkdoc lint test clean tag
105+
.PHONY : ci compile checkdoc lint unix-test windows-test clean tag

test/windows-bootstrap.el

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
;;; windows-bootstrap.el --- Windows test bootstrap -*- lexical-binding: t; -*-
2+
;;
3+
;; Copyright (C) 2020-2021 emacs-lsp maintainers
4+
;;
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
;;
18+
;;; Commentary:
19+
;;
20+
;; Windows test bootstrap
21+
;;
22+
;;; Code:
23+
24+
(require 'package)
25+
26+
(setq user-emacs-directory (expand-file-name (make-temp-name ".emacs.d")
27+
"~")
28+
package-user-dir (expand-file-name (make-temp-name "tmp-elpa")
29+
user-emacs-directory))
30+
31+
(let* ((package-archives '(("melpa" . "https://melpa.org/packages/")
32+
("gnu" . "https://elpa.gnu.org/packages/")))
33+
(pkgs (append '(lsp-treemacs lsp-mode dap-mode f dash pkg-info dart-mode)
34+
'(el-mock ert-runner undercover spinner))))
35+
(package-initialize)
36+
(package-refresh-contents)
37+
38+
(mapc (lambda (pkg)
39+
(unless (package-installed-p pkg)
40+
(package-install pkg)))
41+
pkgs)
42+
43+
(add-hook 'kill-emacs-hook
44+
`(lambda () (delete-directory ,user-emacs-directory t))))
45+
46+
;;; windows-bootstrap.el ends here

0 commit comments

Comments
 (0)