-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dickmao
committed
Oct 14, 2024
0 parents
commit 4f8f6e8
Showing
50 changed files
with
4,243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- '**.md' | ||
- '**.rst' | ||
push: | ||
paths-ignore: | ||
- '**.md' | ||
- '**.rst' | ||
branches-ignore: | ||
- 'master' | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
emacs_version: [27.2, 28.2, 29.3] | ||
python_version: [3.8] | ||
include: | ||
- os: macos-12 | ||
emacs_version: 29.3 | ||
python_version: 3.8 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
|
||
- uses: purcell/setup-emacs@master | ||
with: | ||
version: ${{ matrix.emacs_version }} | ||
|
||
- uses: actions/cache@v2 | ||
if: startsWith(runner.os, 'Linux') | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-000 | ||
|
||
- uses: actions/cache@v2 | ||
if: startsWith(runner.os, 'macOS') | ||
with: | ||
path: ~/Library/Caches/pip | ||
key: ${{ runner.os }}-pip-000 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/local | ||
key: ${{ runner.os }}-local-000 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.emacs.d | ||
key: emacs.d | ||
|
||
- name: apt-get | ||
if: startsWith(runner.os, 'Linux') | ||
run: | | ||
sudo apt-get -yq update | ||
DEBIAN_FRONTEND=noninteractive sudo apt-get -yq install gnutls-bin sharutils dirmngr libreadline-dev libcurl4-openssl-dev virtualenv | ||
- uses: actions/cache@v2 | ||
id: cache-cask-packages | ||
with: | ||
path: .cask | ||
key: cache-cask-packages-000 | ||
|
||
- uses: actions/cache@v2 | ||
id: cache-cask-executable | ||
with: | ||
path: ~/.cask | ||
key: cache-cask-executable-000 | ||
|
||
- uses: conao3/setup-cask@master | ||
if: steps.cache-cask-executable.outputs.cache-hit != 'true' | ||
with: | ||
version: snapshot | ||
|
||
- name: paths | ||
run: | | ||
echo "$HOME/local/bin" >> $GITHUB_PATH | ||
echo "$HOME/.cask/bin" >> $GITHUB_PATH | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
echo "LD_LIBRARY_PATH=$HOME/.local/lib" >> $GITHUB_ENV | ||
- name: test | ||
run: | | ||
make test-run | ||
make test | ||
continue-on-error: ${{ matrix.emacs_version == 'snapshot' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
build | ||
venv-nnreddit-test | ||
.ecukes* | ||
.cask | ||
.newsrc* | ||
*.pyc | ||
dist | ||
todo.org | ||
mimeapps.list | ||
*autoloads.el | ||
super-secret-refresh-token | ||
\#* | ||
.\#* | ||
todo.org | ||
ert-profile* | ||
tests/log | ||
nnreddit.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(source gnu) | ||
(source melpa) | ||
|
||
(package-descriptor "lisp/nnreddit-pkg.el") | ||
(files "lisp/*.el" "setup.py" "requirements.txt" "nnreddit") | ||
|
||
(development | ||
(depends-on "ert-runner") | ||
(depends-on "package-lint") | ||
(depends-on "ecukes") | ||
(depends-on "f")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
SHELL := /bin/bash | ||
EMACS ?= $(shell which emacs) | ||
export PYTHON ?= python | ||
ifeq ($(shell command -v $(PYTHON) 2>/dev/null),) | ||
$(error $(PYTHON) not found) | ||
endif | ||
ifeq ($(shell expr $$($(PYTHON) --version 2>&1 | cut -d' ' -f2) \< 3),1) | ||
$(error Set PYTHON to python3) | ||
endif | ||
ifeq ($(shell expr $$($(PYTHON) --version 2>&1 | cut -d'.' -f2) \< 11),0) | ||
$(error Set PYTHON to an older python3) | ||
endif | ||
SRC=$(shell cask files) | ||
PKBUILD=2.3 | ||
ELCFILES = $(SRC:.el=.elc) | ||
CASK_DIR := $(shell EMACS=$(EMACS) cask package-directory || exit 1) | ||
export TEST_PYTHON ?= $(PYTHON) | ||
ifeq ($(shell command -v $(TEST_PYTHON) 2>/dev/null),) | ||
$(error $(TEST_PYTHON) not found) | ||
endif | ||
|
||
.DEFAULT_GOAL := test-compile | ||
|
||
.PHONY: cask | ||
cask: $(CASK_DIR) | ||
|
||
$(CASK_DIR): Cask | ||
cask install | ||
touch $(CASK_DIR) | ||
|
||
lisp/nnreddit-pkg.el: nnreddit/VERSION lisp/nnreddit-pkg.el.in | ||
sed 's/VERSION/"$(shell cat $<)"/' lisp/nnreddit-pkg.el.in > $@ | ||
|
||
.PHONY: autoloads | ||
autoloads: lisp/nnreddit-pkg.el | ||
cask emacs -Q --batch -l package --eval "(let ((v (format \"%s.%s\" emacs-major-version emacs-minor-version))) (custom-set-variables (backquote (package-user-dir ,(concat \".cask/\" v)))))" -f package-initialize --eval "(package-generate-autoloads \"nnreddit\" \"./lisp\")" | ||
|
||
README.rst: README.in.rst lisp/nnreddit.el | ||
grep ';;' lisp/nnreddit.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: clean | ||
clean: | ||
cask clean-elc | ||
pyclean nnreddit | ||
$(PYTHON) setup.py clean | ||
rm -f tests/log/* | ||
rm -rf tests/test-install | ||
|
||
.PHONY: pylint | ||
ifeq ($(shell expr $$($(PYTHON) --version 2>&1 | cut -d'.' -f2) \> 9),1) | ||
pylint: | ||
$(PYTHON) -m pip -q install --user pylint | ||
$(PYTHON) -m pylint nnreddit --rcfile=nnreddit/pylintrc | ||
else | ||
pylint: | ||
@echo forgoing pylint | ||
endif | ||
|
||
.PHONY: test-compile | ||
test-compile: cask autoloads pylint | ||
sh -e tools/package-lint.sh lisp/nnreddit.el | ||
! (cask eval "(let ((byte-compile-error-on-warn t) (bytecomp--inhibit-lexical-cookie-warning t) (byte-compile--suppressed-warnings (quote ((obsolete define-package))))) (cask-cli/build))" 2>&1 | egrep -a "(Warning|Error):") | ||
cask clean-elc | ||
|
||
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) | ||
git show -s --format=%s $(GITHUB_SHA) | ||
|
||
.PHONY: test-install-defunct | ||
test-install-defunct: 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/nnreddit || cp -f ../../../tools/recipe ./nnreddit | ||
! ( $(EMACS) -Q --batch -L tests/test-install/package-build-$(PKBUILD) \ | ||
--eval "(require 'package-build)" \ | ||
--eval "(require 'subr-x)" \ | ||
-f package-initialize \ | ||
--eval "(add-to-list 'package-archives '(\"melpa\" . \"http://melpa.org/packages/\"))" \ | ||
--eval "(package-refresh-contents)" \ | ||
--eval "(setq rcp (package-recipe-lookup \"nnreddit\"))" \ | ||
--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 \"nnreddit*.tar\"))))" 2>&1 | egrep -ia "error: |fatal" ) | ||
|
||
.PHONY: test-venv | ||
test-venv: test-install-defunct | ||
$(EMACS) -Q --batch -f package-initialize \ | ||
--eval "(custom-set-variables (quote (gnus-verbose 8)))" \ | ||
--eval "(require (quote nnreddit))" \ | ||
--eval "nnreddit-venv" | ||
|
||
define TESTRUN | ||
--eval "(custom-set-variables \ | ||
(quote (gnus-select-method (quote (nnreddit \"\")))) \ | ||
(backquote (venv-location ,(file-name-as-directory (make-temp-file \"testrun-\" t)))) \ | ||
(quote (nnreddit-python-command \"$(PYTHON)\"))\ | ||
(quote (gnus-verbose 8)) \ | ||
(quote (nnreddit-log-rpc t)))" \ | ||
--eval "(setq debug-on-error t)" \ | ||
--eval "(fset (quote gnus-y-or-n-p) (function ignore))" | ||
endef | ||
|
||
.PHONY: test-run | ||
test-run: cask autoloads | ||
cask emacs -Q --batch \ | ||
$(TESTRUN) \ | ||
--eval "(require 'nnreddit)" \ | ||
--eval "(cl-assert (nnreddit-rpc-get))" \ | ||
--eval "(sleep-for 0 7300)" \ | ||
-f nnreddit-dump-diagnostics \ | ||
--eval "(cl-assert nnreddit-processes)" | ||
|
||
.PHONY: test-run-interactive | ||
test-run-interactive: cask autoloads | ||
cask emacs -Q \ | ||
$(TESTRUN) \ | ||
-f gnus | ||
|
||
.PHONY: test-unit | ||
test-unit: | ||
PYTHON=$(TEST_PYTHON) cask exec ert-runner -L . -L tests tests/test*.el | ||
|
||
.PHONY: test | ||
test: test-compile test-unit test-int | ||
|
||
.PHONY: test-int | ||
test-int: | ||
@>/dev/null expr $$($(TEST_PYTHON) --version 2>&1 | cut -d'.' -f2) \< 9 || { echo "need python less than 3.9" ; exit -1; } | ||
rm -rf venv-nnreddit-test | ||
$(TEST_PYTHON) -m venv venv-nnreddit-test | ||
( \ | ||
source venv-nnreddit-test/bin/activate; \ | ||
python -m pip -q install -r requirements-dev.txt; \ | ||
python -m pytest tests/test_oauth.py; \ | ||
rm -f tests/.newsrc.eld; \ | ||
cask exec ecukes --reporter magnars --tags "~@inbox"; \ | ||
rm -f tests/.newsrc.eld; \ | ||
cask exec ecukes --reporter magnars --tags "@inbox"; \ | ||
) | ||
|
||
.PHONY: dist-clean | ||
dist-clean: | ||
rm -rf dist | ||
|
||
.PHONY: dist | ||
dist: dist-clean | ||
cask package | ||
|
||
.PHONY: install | ||
install: dist autoloads | ||
$(EMACS) -Q --batch -f package-initialize \ | ||
--eval "(add-to-list 'package-archives '(\"melpa\" . \"http://melpa.org/packages/\"))" \ | ||
--eval "(package-refresh-contents)" \ | ||
--eval "(package-install-file (car (file-expand-wildcards \"dist/nnreddit*.tar\")))" |
Oops, something went wrong.
4f8f6e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You rock!