Skip to content

Commit

Permalink
Migrate from Semaphore CI to CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Nov 17, 2019
1 parent d56b8af commit 68d8755
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 72 deletions.
44 changes: 44 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 2
shared: &shared
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
# This command will pick up $VERSION from the environment.
- run: >-
make docker
CMD="make -k compile checkdoc longlines"
jobs:
emacs-25.1:
<<: *shared
environment:
VERSION: "25.1"
emacs-25.2:
<<: *shared
environment:
VERSION: "25.2"
emacs-25.3:
<<: *shared
environment:
VERSION: "25.3"
emacs-26.1:
<<: *shared
environment:
VERSION: "26.1"
emacs-26.2:
<<: *shared
environment:
VERSION: "26.2"
emacs-master:
<<: *shared
environment:
VERSION: "master"
workflows:
version: 2
ci:
jobs:
- emacs-25.2
- emacs-25.3
- emacs-26.1
- emacs-26.2
- emacs-master
24 changes: 0 additions & 24 deletions .semaphore/semaphore.yml

This file was deleted.

12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG VERSION
FROM silex/emacs:$VERSION

ARG UID

COPY scripts/docker-install.bash /tmp/
RUN /tmp/docker-install.bash "$UID"

USER $UID
WORKDIR /home/docker/src

CMD bash
32 changes: 15 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
VERSION ?=
CMD ?=

EMACS ?= emacs
VERSION ?= latest

# The order is important for compilation.
for_compile := *.el
for_checkdoc := *.el
for_longlines := $(wildcard *.el *.md *.yml) Makefile

.PHONY: all
all: compile checkdoc longlines ## Build project and run all linters
.PHONY: help
help: ## Show this message
@echo "usage:" >&2
@grep -h "[#]# " $(MAKEFILE_LIST) | \
sed 's/^/ make /' | \
sed 's/:[^#]*[#]# /|/' | \
sed 's/%/LANG/' | \
column -t -s'|' >&2

.PHONY: lint
lint: compile checkdoc longlines ## Build project and run all linters

.PHONY: compile
compile: ## Check for byte-compiler errors
# Deleting the .elc file first is sometimes necessary
# apparently when switching between different versions of
# Emacs; otherwise we may get an error saying we can't
# overwrite the file.
@for file in $(for_compile); do \
echo "[compile] $$file" ;\
rm -f "$${file}c" ;\
Expand All @@ -36,8 +43,8 @@ checkdoc: ## Check for missing or poorly formatted docstrings

.PHONY: longlines
longlines: ## Check for lines longer than 79 characters
@echo "[longlines] $(for_longlines)"
@for file in $(for_longlines); do \
echo "[longlines] $$file" ;\
cat "$$file" \
| sed '/[l]onglines-start/,/longlines-stop/d' \
| grep -E '.{80}' \
Expand All @@ -54,12 +61,3 @@ clean: ## Remove build artifacts
.PHONY: docker
docker: ## Start a Docker shell; e.g. make docker VERSION=25.3
@scripts/docker.bash $(VERSION)

.PHONY: help
help: ## Show this message
@echo "usage:" >&2
@grep -h "[#]# " $(MAKEFILE_LIST) | \
sed 's/^/ make /' | \
sed 's/:[^#]*[#]# /|/' | \
sed 's/%/LANG/' | \
column -t -s'|' >&2
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,11 @@ The following user options are also available:

## Contributing

Development of Apheleia happens using the provided Makefile:

% make help
usage:
make all Build project and run all linters
make compile Check for byte-compiler errors
make checkdoc Check for missing or poorly formatted docstrings
make longlines Check for lines longer than 79 characters
make clean Remove build artifacts
make docker Start a Docker shell; e.g. make docker VERSION=25.3
make help Show this message

All commits are automatically tested using `make all` (== `make`) for
all supported Emacs versions on the excellent [Semaphore
CI](https://semaphoreci.com/) platform. Please make sure you can
successfully run `make` before submitting a pull request.
Development of Apheleia happens using the provided Makefile. Run `make
help` for documentation. All commits are automatically tested using
`make lint` for all supported Emacs versions on the excellent
[CircleCI](https://circleci.com/) platform. Please make sure you can
successfully run `make lint` before submitting a pull request.

If the CI fails, it may be that your change is not compatible with one
of the Emacs versions supported by Apheleia. Suppose that the failure
Expand Down
37 changes: 37 additions & 0 deletions scripts/docker-install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -e
set -o pipefail

if (( $# != 1 )); then
echo "usage: docker-install.bash UID" >&2
exit 1
fi

uid="$1"

packages="
# needed to run build system
make
# needed for 'make help'
bsdmainutils
# for checking diffs if you want
git
# just in case we want root
sudo
"

export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y $(grep -v "^#" <<< "$packages")
rm -rf /var/lib/apt/lists/*

useradd --uid="$uid" --create-home --groups sudo docker
passwd -d docker

rm "$0"
28 changes: 13 additions & 15 deletions scripts/docker.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
set -e
set -o pipefail

if [[ -z "$1" ]]; then
echo "docker.sh: no tag provided" 1>&2
if [[ -n "$1" && "$1" != master && ! "$1" =~ [0-9]+\.[0-9]+ ]]; then
echo "docker.bash: malformed tag: $1" >&2
exit 1
else
tag="$1"
fi

tag="${1:-latest}"

args=(bash)
if [[ -n "$2" ]]; then
args=("${args[@]}" -c "$2")
fi

docker() {
Expand All @@ -18,15 +23,8 @@ docker() {
fi
}

script="$(cat <<"EOF"
apt-get update
apt-get install -y bsdmainutils make
cd /src
make help
exec bash
EOF
)"
docker build . -t "apheleia:$tag" \
--build-arg "UID=$UID" \
--build-arg "VERSION=$tag"

docker run -it --rm -v "$PWD:/src" silex/emacs:"$tag" bash -c "$script"
docker run -it --rm -v "$PWD:/home/docker/src" "apheleia:$tag" "${args[@]}"

0 comments on commit 68d8755

Please sign in to comment.