From 68d875533379cbc1ac46b2adcf96d6722de6968a Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sat, 16 Nov 2019 21:59:32 -0800 Subject: [PATCH] Migrate from Semaphore CI to CircleCI --- .circleci/config.yml | 44 +++++++++++++++++++++++++++++++++++++ .semaphore/semaphore.yml | 24 -------------------- Dockerfile | 12 ++++++++++ Makefile | 32 +++++++++++++-------------- README.md | 21 +++++------------- scripts/docker-install.bash | 37 +++++++++++++++++++++++++++++++ scripts/docker.bash | 28 +++++++++++------------ 7 files changed, 126 insertions(+), 72 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .semaphore/semaphore.yml create mode 100644 Dockerfile create mode 100755 scripts/docker-install.bash diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..468e0a2 --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml deleted file mode 100644 index 957fc62..0000000 --- a/.semaphore/semaphore.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: v1.0 -name: Apheleia -agent: - machine: - type: e1-standard-2 - os_image: ubuntu1804 -blocks: - - name: Apheleia CI - task: - jobs: - - name: Apheleia CI - matrix: - - env_var: EMACS_VERSION - values: - - "25.2" - - "25.3" - - "26.1" - - "26.2" - commands: - - checkout - - >- - docker run --rm -v "$PWD:/src" - silex/emacs:"$EMACS_VERSION" bash -c - 'apt-get update && apt-get install -y make && make -C /src' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..258f03c --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index c0b78d4..1b0fa16 100644 --- a/Makefile +++ b/Makefile @@ -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" ;\ @@ -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}' \ @@ -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 diff --git a/README.md b/README.md index 21338c2..128b4f2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/docker-install.bash b/scripts/docker-install.bash new file mode 100755 index 0000000..779ebbf --- /dev/null +++ b/scripts/docker-install.bash @@ -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" diff --git a/scripts/docker.bash b/scripts/docker.bash index d9000b2..d33e680 100755 --- a/scripts/docker.bash +++ b/scripts/docker.bash @@ -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() { @@ -18,15 +23,8 @@ docker() { fi } -script="$(cat <<"EOF" +docker build . -t "apheleia:$tag" \ + --build-arg "UID=$UID" \ + --build-arg "VERSION=$tag" -apt-get update -apt-get install -y bsdmainutils make -cd /src -make help -exec bash - -EOF -)" - -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[@]}"