Skip to content

Commit

Permalink
Add automatic Clojush releases on every travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Nov 11, 2015
1 parent 6288858 commit c940987
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 39 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 1,13 @@
sudo: false
sudo: true
language: clojure

# https://github.com/technomancy/leiningen/issues/2014#issuecomment-153829977
before_install: yes y | sudo lein upgrade

script:
# check fails because of "Duplicate Push instruction defined:boolean_and"
# - lein check
- lein test
after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && ./deploy-docs.sh

after_success: ./scripts/after_success.sh 2>&1 | sed "s/$GITHUB_TOKEN/<hidden github token>/"
notifications:
email: false
48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 1,48 @@
# Contributing

[Here](https://gist.github.com/thelmuth/1361411) is a document describrining how
to contribute to this project.

## Travic CI
Recently we have begun using [Travis CI](travis-ci.org) to automate multiple
parts of development.

### Testing

Primarily it serves as a way to test every branch and pull request, using commands
like `lein check` and `lein test`. Currently, the test cases are very limited
and do not cover much of the codebase.

### Docs

Docs are auto generated from function metadata using
[`codox`](https://github.com/weavejester/codox).

On every commit to master, the docs are automatically regenerated and pushed
to the [`gh-pages` branch](http://lspector.github.io/Clojush/).

To generate them locally run `lein doc` and then open `doc/index.html`.

Currently, generating the docs have the side effect of running some examples,
[because I couldn't figure out how stop codox from loading all example files](https://github.com/weavejester/codox/issues/100).

In the metadata, you can [skip functions](https://github.com/weavejester/codox#metadata-options)
and also [link to other functions](https://github.com/weavejester/codox#docstring-formats).

In order for this work, you must set the `GITHUB_TOKEN` environmental variable
in the [repository settings in Travis](http://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings).
It needs this so it can push the updated docs back to Github.

### Releases

We use [the `lein release` command](https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md#releasing-simplified)
to add a new release on every build on the `master` branch. Check the
`:release-tasks` key in the [`project.clj`](./project.clj) for a list of
all steps it takes.

This requires setting the `LEIN_USERNAME` and `LEIN_PASSWORD` in
the [repository settings in Travis](http://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings),
so that it can the release to Clojars. It also needs the `GITHUB_TOKEN`
in order to push the added tag and commit back to Github.

Currently it will always bump a minor version. It
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 84,6 @@ on the method that you use to launch your code.

An additional tutorial is available in src/clojush/problems/demos/tutorial.clj.

## Docs

Docs are auto generated from function metadata using [`codox`](https://github.com/weavejester/codox).

On every commit to master, the docs are automatically regenerated and pushed
to [github pages](http://lspector.github.io/Clojush/), through Travis.

To generate them locally run `lein doc` and then open `doc/index.html`.

Currently generating the docs have some unintended side effects of running some examples,
[because we couldn't figure out how stop codox from loading all the files](https://github.com/weavejester/codox/issues/100).

In the metadata, you can [skip functions](https://github.com/weavejester/codox#metadata-options)
and also [link to other functions](https://github.com/weavejester/codox#docstring-formats).

Description
-----------

Expand Down Expand Up @@ -336,10 321,8 @@ Push3 stuff not (yet) implemented:
spec have not been implemented here. The approach here is quite different,
so this may never be implemented

How to Contribute
-----------------

See [these instructions](https://gist.github.com/thelmuth/1361411).
[How to Contribute](./CONTRIBUTING.md)
--------------------------------------

To Do (sometime, maybe)
-----------------------
Expand Down
12 changes: 0 additions & 12 deletions deploy-docs.sh

This file was deleted.

16 changes: 14 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
(defproject clojush "2.0.40"
(defproject clojush "2.0.41-SNAPSHOT"
:description "The Push programming language and the PushGP genetic programming
system implemented in Clojure.
See http://hampshire.edu/lspector/push.html"
Expand All @@ -20,7 20,19 @@
:defaults {:doc/format :markdown}}
:dev-dependencies [[lein-ccw "1.2.0"][lein-midje "3.1.3"]]
:profiles {:dev {:dependencies [[midje "1.7.0"]]}}
;;;;;;;;;; jvm settings for high performance, using most of the machine's RAM
:repositories [["releases" {:url "https://clojars.org/repo"
:username :env
:sign-releases false
:password :env}]]
:release-tasks [["vcs" "assert-committed"]
["change" "version" "leiningen.release/bump-version" "release"]
["vcs" "commit"]
["vcs" "tag" "v" "--no-sign"] ; disable signing and add "v" prefix
["deploy"]
["change" "version" "leiningen.release/bump-version"]
["vcs" "commit"]
["vcs" "push"]]
;;;;;;;;;; jvm settings for high performance, using most of the machine's RAM
; :jvm-opts ~(let [mem-to-use
; (long (* (.getTotalPhysicalMemorySize
; (java.lang.management.ManagementFactory/getOperatingSystemMXBean))
Expand Down
31 changes: 31 additions & 0 deletions scripts/after_success.sh
Original file line number Diff line number Diff line change
@@ -0,0 1,31 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o xtrace
set -o pipefail

LAST_COMMIT_AUTHOR_EMAIL=$(git --no-pager show -s --format='' HEAD)
echo "last commit ID: $LAST_COMMIT_AUTHOR_EMAIL"
AUTOMATED_AUTHOR_EMAIL=_@_._
AUTOMATED_AUTHOR_NAME=_

# if this commit was a created automatically (by lein release) then we dont
# wanna re release it. If it is, exit.
test $TRAVIS_PULL_REQUEST == "false" && \
test $TRAVIS_BRANCH == "master" &&
test $LAST_COMMIT_AUTHOR_EMAIL != $AUTOMATED_AUTHOR_EMAIL

git remote set-url origin https://$GITHUB_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
git branch --set-upstream-to origin/master master
git config user.name "$AUTOMATED_AUTHOR_NAME"
git config user.email "$AUTOMATED_AUTHOR_EMAIL"
git config push.default simple
# dont output all of lein doc, because its overly long because it tries
# to run experiments
lein doc 2>&1 | head -n 100
./scripts/deploy-docs.sh --verbose
git checkout master
git status
git branch
lein release
git tag
5 changes: 3 additions & 2 deletions deploy.sh → scripts/deploy-docs.sh
Original file line number Diff line number Diff line change
@@ -1,15 1,16 @@
#!/usr/bin/env bash
# modified from https://github.com/X1011/git-directory-deploy/raw/master/deploy.sh
# changed to support automatically intializing, if it deteched the remote branch didnt exist

set -o errexit #abort if any command fails

main() {
deploy_directory=${GIT_DEPLOY_DIR:-dist}
deploy_directory=${GIT_DEPLOY_DIR:-doc}
deploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}

#if no user identity is already set in the current git environment, use this:
default_username=${GIT_DEPLOY_USERNAME:-deploy.sh}
default_email=${GIT_DEPLOY_EMAIL:-}
default_email=${GIT_DEPLOY_EMAIL:-"_@_"}

#repository to deploy to. must be readable and writable.
repo=${GIT_DEPLOY_REPO:-origin}
Expand Down

0 comments on commit c940987

Please sign in to comment.