From fde1da69387be9bddc3c74a8f5bfb783e404ab48 Mon Sep 17 00:00:00 2001 From: Daniel Compton Date: Tue, 5 Mar 2019 14:34:23 +1300 Subject: [PATCH 1/2] Add CircleCI config --- .circleci/config.yml | 38 +++++++++++++++++++++++++++++++ .travis.yml | 48 --------------------------------------- README.md | 2 +- travis-ci/install-cask.sh | 35 ---------------------------- travis-ci/install-evm.sh | 20 ---------------- travis-ci/prompt.sh | 1 - travis-ci/retry.sh | 27 ---------------------- 7 files changed, 39 insertions(+), 132 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml delete mode 100755 travis-ci/install-cask.sh delete mode 100755 travis-ci/install-evm.sh delete mode 100644 travis-ci/prompt.sh delete mode 100644 travis-ci/retry.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..d5388ca35 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,38 @@ +version: 2.1 + +# Default actions to perform on each Emacs version +default: &default-steps + steps: + - checkout + - run: apt-get update && apt-get install make leiningen=2.8.1-6 -y + - run: make elpa + - run: emacs --version + - run: make test + - run: make lint + +jobs: + test-emacs-25: + docker: + - image: silex/emacs:25-dev + entrypoint: bash + <<: *default-steps + + test-emacs-26: + docker: + - image: silex/emacs:26-dev + entrypoint: bash + <<: *default-steps + + test-emacs-master: + docker: + - image: silex/emacs:master-dev + entrypoint: bash + <<: *default-steps + +workflows: + version: 2 + ci-test-matrix: + jobs: + - test-emacs-25 + - test-emacs-26 + - test-emacs-master diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f867d8fa9..000000000 --- a/.travis.yml +++ /dev/null @@ -1,48 +0,0 @@ -sudo: false -language: emacs-lisp - -cache: - directories: - - $HOME/local - -env: - global: - - PATH=$HOME/local/bin:$HOME/local/evm/bin:$HOME/local/cask/bin:$PATH - matrix: - - EMACS_BINARY=emacs-25.1-travis MAKE_TEST=test - - EMACS_BINARY=emacs-25.2-travis MAKE_TEST=test - - EMACS_BINARY=emacs-25.3-travis MAKE_TEST=test - - EMACS_BINARY=emacs-26.1-travis MAKE_TEST=test - - EMACS_BINARY=emacs-git-snapshot-travis MAKE_TEST=test - -stages: - - check - - test - -jobs: - include: - # linting for code quality - - stage: check - env: EMACS_BINARY=emacs-25.1-travis MAKE_TEST=lint - - stage: check - env: EMACS_BINARY=emacs-25.2-travis MAKE_TEST=lint - - stage: check - env: EMACS_BINARY=emacs-25.3-travis MAKE_TEST=lint - - stage: check - env: EMACS_BINARY=emacs-26.1-travis MAKE_TEST=lint - - stage: check - env: EMACS_BINARY=emacs-git-snapshot-travis MAKE_TEST=lint - - # "matrix" of tests is implicit in the "test" stage - - allow_failures: - - env: EMACS_BINARY=emacs-git-snapshot-travis MAKE_TEST=test - - env: EMACS_BINARY=emacs-git-snapshot-travis MAKE_TEST=lint - -before_script: - - sh travis-ci/install-evm.sh - - evm install $EMACS_BINARY --use --skip - - sh travis-ci/install-cask.sh -script: - - emacs --version - - make $MAKE_TEST diff --git a/README.md b/README.md index 21ed78fe0..3ca5e7d6f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![License GPL 3][badge-license]](http://www.gnu.org/licenses/gpl-3.0.txt) [![MELPA](http://melpa.org/packages/cider-badge.svg)](http://melpa.org/#/cider) [![MELPA Stable](http://stable.melpa.org/packages/cider-badge.svg)](http://stable.melpa.org/#/cider) -[![Build Status](https://travis-ci.org/clojure-emacs/cider.png?branch=master)](https://travis-ci.org/clojure-emacs/cider) +[![CircleCI](https://circleci.com/gh/clojure-emacs/cider.svg?style=svg)](https://circleci.com/gh/clojure-emacs/cider) CIDER is the **C**lojure(Script) **I**nteractive **D**evelopment **E**nvironment that **R**ocks! diff --git a/travis-ci/install-cask.sh b/travis-ci/install-cask.sh deleted file mode 100755 index fc2438b6f..000000000 --- a/travis-ci/install-cask.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -x - -# Install cask for Travis CI -# or if already installed, then check for updates - -WORKDIR=${HOME}/local -CASKDIR=$WORKDIR/cask -SCRIPTDIR=`dirname $(readlink -f $0)` - -. $SCRIPTDIR/retry.sh - -cask_upgrade_cask_or_reset() { - cask upgrade-cask || { rm -rf $HOME/.emacs.d/.cask && false; } -} - -cask_install_or_reset() { - cask install || { rm -rf .cask && false; } -} - -# Bootstrap the cask tool and its dependencies -if [ -d $CASKDIR ] -then - travis_retry cask_upgrade_cask_or_reset -else - git clone https://github.com/cask/cask.git $CASKDIR - travis_retry cask_upgrade_cask_or_reset -fi - -# Install dependencies for cider as descriped in ./Cask -# Effect is identical to "make elpa", but here we can retry -# in the event of network failures. -if [ -f Cask ] -then - travis_retry cask_install_or_reset && touch elpa-emacs -fi diff --git a/travis-ci/install-evm.sh b/travis-ci/install-evm.sh deleted file mode 100755 index ef9bb979b..000000000 --- a/travis-ci/install-evm.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -x - -# Install evm for Travis CI -# or if already installed, then check for updates - -WORKDIR=${HOME}/local -EVMDIR=$WORKDIR/evm -SCRIPTDIR=`dirname $(readlink -f $0)` - -. $SCRIPTDIR/retry.sh - -if [ -d $EVMDIR ] -then - cd $EVMDIR - git pull origin master -else - git clone https://github.com/rejeep/evm.git $EVMDIR - evm config path /tmp - travis_retry evm install emacs-24.3-travis --use --skip -fi diff --git a/travis-ci/prompt.sh b/travis-ci/prompt.sh deleted file mode 100644 index ef95931cd..000000000 --- a/travis-ci/prompt.sh +++ /dev/null @@ -1 +0,0 @@ -export PS1="(\$(sed -ne 's/^.*\(emacs-.*-travis\).*$/\1/p' ~/local/evm/.config)) \w$ " diff --git a/travis-ci/retry.sh b/travis-ci/retry.sh deleted file mode 100644 index 7a5e2c819..000000000 --- a/travis-ci/retry.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Copied retry logic from Travis CI [http://bit.ly/2jPDCtV] - -ANSI_RED="\033[31;1m" -ANSI_GREEN="\033[32;1m" -ANSI_RESET="\033[0m" -ANSI_CLEAR="\033[0K" - -travis_retry() { - local result=0 - local count=1 - while [ $count -le 3 ]; do - [ $result -ne 0 ] && { - echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 - } - "$@" - result=$? - [ $result -eq 0 ] && break - count=$(($count + 1)) - sleep 1 - done - - [ $count -gt 3 ] && { - echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2 - } - - return $result -} From 234f1b7715b9cd6a164fd6c2f33c9c757d47e21a Mon Sep 17 00:00:00 2001 From: Daniel Compton Date: Thu, 7 Mar 2019 13:31:05 +1300 Subject: [PATCH 2/2] Update docs to explain how to run CircleCI tests locally Replacing the docs for how to run Travis CI tests locally. --- Dockerfile | 34 ------------- doc/hacking_on_cider.md | 110 +++++++++++++++++++--------------------- docker/build.sh | 4 -- docker/run.sh | 4 -- 4 files changed, 52 insertions(+), 100 deletions(-) delete mode 100644 Dockerfile delete mode 100755 docker/build.sh delete mode 100755 docker/run.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e610bdea5..000000000 --- a/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -FROM travisci/ci-garnet:packer-1512502276-986baf0 - -RUN apt-get update -y \ - && apt-get install -y \ - autogen \ - ca-certificates \ - curl \ - gcc \ - git \ - libgmp-dev \ - m4 \ - make \ - pkg-config \ - python \ - ruby \ - xz-utils - -USER travis -ENV HOME=/home/travis -ENV PATH="${HOME}/local/evm/bin:${HOME}/local/cask/bin:${HOME}/local/bin:${PATH}" - -ADD travis-ci/ ${HOME}/cider-setup/travis-ci/ -RUN echo ". ${HOME}/cider-setup/travis-ci/prompt.sh" >> ${HOME}/.bashrc - -RUN ${HOME}/cider-setup/travis-ci/install-gnutls.sh -RUN ${HOME}/cider-setup/travis-ci/install-evm.sh -RUN ${HOME}/cider-setup/travis-ci/install-cask.sh - -RUN evm install emacs-25.3-travis --use -RUN evm install emacs-26-pretest-travis -RUN evm install emacs-git-snapshot-travis - -WORKDIR /home/travis/cider -CMD /bin/bash diff --git a/doc/hacking_on_cider.md b/doc/hacking_on_cider.md index 03477815d..fb0a9d4cf 100644 --- a/doc/hacking_on_cider.md +++ b/doc/hacking_on_cider.md @@ -91,76 +91,70 @@ You can also check for compliance with a variety of coding standards in batch mo $ make lint ``` -#### Running the tests in Travis CI +#### Running the tests in CircleCI -If you prefer to see the full Travis CI test suite run successfully, the easiest +If you prefer to see the full CircleCI CI test suite run successfully, the easiest way to achieve that is to create your own personal account on -https://travis-ci.org. View your profile details on the Travis CI site, and -toggle the switch to enable builds on your fork of the cider project. +https://circleci.com. Fork CIDER on GitHub, and then add your fork on CircleCI to +start building. Every time you push code to a branch, CircleCI will build it. -Subsequent pushes to your fork will generate a Travis CI build you can monitor +Subsequent pushes to your fork will generate a CircleCI build you can monitor for success or failure. -#### Simulating the Travis CI tests locally in Docker +#### Simulating the Circle CI tests locally in Docker -If you prefer not to wait for Travis CI all the time, or if you need to debug -something that fails in Travis CI but does not fail for you on your own machine, -then you can also run the Travis CI tests manually in Docker. +If you prefer not to wait for CircleCI all the time, or if you need to debug +something that fails in CircleCI but does not fail for you on your own machine, +then you can also run the CircleCI tests locally with the CircleCI CLI (that's +a mouthful!). -You will need to run some scripts to build and launch the Docker image. +To do this, first [install](https://circleci.com/docs/2.0/local-cli/#installation) +the CircleCI CLI, and [Docker](https://docs.docker.com/install/). -To build: +Currently the CircleCI CLI [doesn't support local builds with version 2.1](https://github.com/CircleCI-Public/circleci-cli/issues/79) +of the CircleCI config, so for now we need to convert it to the 2.0 format. +Make sure not to commit these changes to the `config.yml` file. -``` -$ docker/build.sh -``` - -The build script uses a base image provided by the engineers at Travis CI. - -*Note: The Travis docker image is currently more than 8GB, so be prepared with a -good internet connection and time to spare.* - -The resulting docker image is tagged simply `cider-travis`. You can run this -image by hand, but there is a convenience script available: - -``` -$ docker/run.sh -``` - -This script launches a docker container and bind-mounts your cider project -directory as `/home/travis/cider` such that you can instantly see any code -changes reflected inside the docker environment. - -For instance, first you can run tests on Emacs 25.3: - -``` -(emacs-25.3-travis) ~/cider$ make test -``` - -And then switch to Emacs 26.1 and test again: - -``` -(emacs-25.3-travis) ~/cider$ evm use Emacs-26-pretest-travis -(emacs-26.1-travis) ~/cider$ cask install -(emacs-26.1-travis) ~/cider$ make test -``` - -You can test byte compilation too - -``` -(emacs-26.1-travis) ~/cider$ make test-bytecomp +```shell +$ circleci config process .circleci/config.yml > .circleci/config.yml.tmp && \ + mv .circleci/config.yml.tmp .circleci/config.yml ``` -When you are done working in docker, just `exit` the bash prompt, and the docker -container will also exit. Note that `docker/run.sh` runs the container with -`--rm`, meaning any changes to the docker container are discarded when the -container exits. +Now, we're finally ready to +[run a CircleCI container on our machine](https://circleci.com/docs/2.0/local-cli/#run-a-job-in-a-container-on-your-machine). +Run `circleci local execute --job=` where `` is one of those listed +in `.circleci/config.yml`, e.g. `test-emacs-26`. -So for example, by default, the docker image pre-installs only the most recent -releases of Emacs 25, Emacs 26, and a recent snapshot of the Emacs git -repository. The `evm` tool is available should you need to install some other -specific build. However additional versions of Emacs will be discarded when -you exit the docker container. +```shell +$ circleci local execute --job=test-emacs-26 +Docker image digest: sha256:65b2102646d5658f892e0ad8253b7912c676126c857c87c8c12460f0aa4f5aa1 +====>> Spin up Environment +Build-agent version 1.0.8563-43047892 (2019-03-06T15:11:54+0000) +Starting container silex/emacs:26-dev + image cache not found on this host, downloading silex/emacs:26-dev +26-dev: Pulling from silex/emacs +6cf436f81810: Already exists +987088a85b96: Already exists +e58f362a948a: Waiting +... +====>> make elpa + #!/bin/bash -eo pipefail +make elpa +Compute dependencies +cask install +Loading package information... done +Package operations: 10 installs, 0 removals +... +Indenting region... +Indenting region...done +* Run indent-character +* Run trailing-whitespace +** ELISP-LINT: cider-overlays.el OK +Success! +``` + +This may take a while to download the CircleCI build agent and the build containers +the first time you run the tests locally. ## Hacking on cider-nrepl (Clojure) diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 67c48bb6b..000000000 --- a/docker/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -docker build -t cider-travis . - diff --git a/docker/run.sh b/docker/run.sh deleted file mode 100755 index 33ff3e2f8..000000000 --- a/docker/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -docker run -it --rm -v `pwd`:/home/travis/cider cider-travis bash -