-
Notifications
You must be signed in to change notification settings - Fork 93
/
Makefile
142 lines (117 loc) · 5.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
export CASK ?= cask
export EMACS ?= $(shell which emacs)
export CASK_DIR := $(shell EMACS=$(EMACS) $(CASK) package-directory)
PKBUILD=2.3
TESTSSRC = $(shell ls tests/*.el)
ELCTESTS = $(TESTSSRC:.el=.elc)
.DEFAULT_GOAL := compile
.PHONY: test
test: cask compile test-3
.PHONY: test-3
test-3: test-3-tornado test-3-flask
.PHONY: test-3-tornado
test-3-tornado:
EL_REQUEST_TEST_SERVER=tornado $(MAKE) test-2
.PHONY: test-3-flask
test-3-flask:
EL_REQUEST_TEST_SERVER=flask $(MAKE) test-2
.PHONY: test-2
test-2: test-2-url-retrieve test-2-curl
.PHONY: test-2-url-retrieve
test-2-url-retrieve:
EL_REQUEST_BACKEND=url-retrieve $(MAKE) test-1
.PHONY: test-2-curl
test-2-curl:
EL_REQUEST_BACKEND=curl $(MAKE) test-1
test-1:
EL_REQUEST_NO_CAPTURE_MESSAGE=$(EL_REQUEST_NO_CAPTURE_MESSAGE) EL_REQUEST_MESSAGE_LEVEL=$(EL_REQUEST_MESSAGE_LEVEL) $(CASK) emacs -Q --batch -L . -L tests -l test-request.el -f ert-run-tests-batch-and-exit
README.rst: README.in.rst request.el
grep ';;' request.el \
| awk '/;;;\s*Commentary/{within=1;next}/;;;\s*/{within=0}within' \
| sed -e 's/^\s*;;*\s*//g' \
| tools/readme-sed.sh "COMMENTARY" README.in.rst > README.rst
.PHONY: cask
cask: $(CASK_DIR)
$(CASK_DIR): Cask
$(CASK) install
touch $(CASK_DIR)
.PHONY: compile
compile: cask
! ($(CASK) eval \
"(cl-letf (((symbol-function (quote cask-files)) (lambda (&rest _args) (mapcar (function symbol-name) (quote ($(TESTSSRC))))))) \
(let ((byte-compile-error-on-warn t)) (cask-cli/build)))" 2>&1 | egrep -a "(Warning|Error):") ; (ret=$$? ; rm -f $(ELCTESTS) && exit $$ret)
! ($(CASK) eval "(let ((byte-compile-error-on-warn t)) (cask-cli/build))" 2>&1 | egrep -a "(Warning|Error):") ; (ret=$$? ; $(CASK) clean-elc && exit $$ret)
.PHONY: lint
lint: compile
bash -ex tools/melpazoid.sh
.PHONY: clean
clean:
$(CASK) clean-elc
make -C doc clean
rm -rf tests/test-install
rm -rf melpazoid-master/emacs-request
.PHONY: dist-clean
dist-clean:
rm -rf dist
.PHONY: dist
dist: dist-clean
$(CASK) package
.PHONY: install
install: compile dist
$(EMACS) -Q --batch --eval "(package-initialize)" \
--eval "(package-install-file \"dist/request-$(shell $(CASK) version).tar\")"
define SET_GITHUB_ACTOR =
GITHUB_ACTOR := $(shell if [ -z ${GITHUB_ACTOR} ]; then git config user.name; else echo ${GITHUB_ACTOR} ; fi)
endef
define SET_GITHUB_ACTOR_REPOSITORY =
GITHUB_ACTOR_REPOSITORY := $(GITHUB_ACTOR)/$(shell basename `git rev-parse --show-toplevel`)
endef
define SET_GITHUB_HEAD_REF =
GITHUB_HEAD_REF := $(shell if [ -z ${GITHUB_HEAD_REF} ]; then git rev-parse --abbrev-ref HEAD; else echo ${GITHUB_HEAD_REF} ; fi)
endef
define SET_GITHUB_SHA =
GITHUB_SHA := $(shell if [ -z ${GITHUB_SHA} ] ; then git rev-parse origin/${GITHUB_HEAD_REF}; else echo ${GITHUB_SHA}; fi)
endef
define SET_GITHUB_COMMIT =
GITHUB_COMMIT := $(shell if git show -s --format=%s "${GITHUB_SHA}" | egrep -q "^Merge .* into" ; then git show -s --format=%s "${GITHUB_SHA}" | cut -d " " -f2 ; else echo "${GITHUB_SHA}" ; fi)
endef
.PHONY: test-install-vars
test-install-vars:
$(eval $(call SET_GITHUB_ACTOR))
$(eval $(call SET_GITHUB_ACTOR_REPOSITORY))
$(eval $(call SET_GITHUB_HEAD_REF))
$(eval $(call SET_GITHUB_SHA))
$(eval $(call SET_GITHUB_COMMIT))
git show -s --format=%s $(GITHUB_COMMIT)
# this needs to be the github implicit merge commit
# e.g., "Merge 8feb544 into 2c33e45",
git show -s --format=%s $(GITHUB_SHA)
# The timing of the github implicit merge commit for PRs
# is elusive. So the following won't halt CI.
.PHONY: test-install
test-install: test-install-vars
mkdir -p tests/test-install
if [ ! -s "tests/test-install/$(PKBUILD).tar.gz" ] ; then \
cd tests/test-install ; curl -sLOk https://github.com/melpa/package-build/archive/$(PKBUILD).tar.gz ; fi
cd tests/test-install ; tar xfz $(PKBUILD).tar.gz
cd tests/test-install ; rm -f $(PKBUILD).tar.gz
cd tests/test-install/package-build-$(PKBUILD) ; make -s loaddefs
mkdir -p tests/test-install/recipes
cd tests/test-install/recipes ; curl -sfLOk https://raw.githubusercontent.com/melpa/melpa/master/recipes/request || cp -f ../../../tools/recipe ./request
! ( $(EMACS) -Q --batch -L tests/test-install/package-build-$(PKBUILD) \
--eval "(require 'package-build)" \
--eval "(require 'subr-x)" \
--eval "(package-initialize)" \
--eval "(add-to-list 'package-archives '(\"melpa\" . \"http://melpa.org/packages/\"))" \
--eval "(package-refresh-contents)" \
--eval "(setq rcp (package-recipe-lookup \"request\"))" \
--eval "(unless (file-exists-p package-build-archive-dir) \
(make-directory package-build-archive-dir))" \
--eval "(let* ((my-repo \"$(GITHUB_ACTOR_REPOSITORY)\") \
(my-branch \"$(GITHUB_HEAD_REF)\") \
(my-commit \"$(GITHUB_COMMIT)\")) \
(oset rcp :repo my-repo) \
(oset rcp :branch my-branch) \
(oset rcp :commit my-commit))" \
--eval "(package-build--package rcp (package-build--checkout rcp))" \
--eval "(package-install-file (car (file-expand-wildcards (concat package-build-archive-dir \"request*.el\"))))" 2>&1 | egrep -ia "error: |fatal")