-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The test is more of a demonstration than an actual test.
- Loading branch information
Showing
4 changed files
with
183 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
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,13 @@ | ||
machine: | ||
java: | ||
version: oraclejdk8 | ||
|
||
test: | ||
override: | ||
- lein test || true | ||
|
||
deployment: | ||
all: | ||
branch: /.*/ | ||
commands: | ||
- bash release.sh |
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,155 @@ | ||
#!/bin/bash | ||
|
||
set -o nounset | ||
|
||
export GITHUB_USER=conormcd | ||
export GITHUB_REPO=clojure-test-junit-output | ||
|
||
abort() { | ||
echo "$@" | ||
exit 1 | ||
} | ||
|
||
current_version() { | ||
grep -m1 '(defproject' project.clj | \ | ||
sed -e 's,^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$,\1,' | ||
} | ||
|
||
major() { | ||
current_version | cut -d. -f1 | ||
} | ||
|
||
minor() { | ||
current_version | cut -d. -f2 | ||
} | ||
|
||
patch() { | ||
if [ -n "${CIRCLE_BUILD_NUM:-}" ]; then | ||
echo "${CIRCLE_BUILD_NUM}" | ||
else | ||
current_version | cut -d. -f3 | ||
fi | ||
} | ||
|
||
branch() { | ||
if [ -n "${CIRCLE_BRANCH:-}" ]; then | ||
echo "${CIRCLE_BRANCH}" | ||
else | ||
git rev-parse --abbrev-ref HEAD | ||
fi | ||
} | ||
|
||
sha() { | ||
if [ -n "${CIRCLE_SHA1:-}" ]; then | ||
echo "${CIRCLE_SHA1}" | ||
else | ||
git rev-parse HEAD | ||
fi | ||
} | ||
|
||
sha_short() { | ||
sha | sed -e 's,^\(........\).*,\1,' | ||
} | ||
|
||
new_version() { | ||
if [ "$(branch)" != "master" ]; then | ||
echo "$(major).$(minor).$(patch)-$(branch)-$(sha_short)" | ||
else | ||
echo "$(major).$(minor).$(patch)" | ||
fi | ||
} | ||
|
||
sed_inplace() { | ||
if sed --help 2>&1 | grep -q -m 1 GNU; then | ||
sed -i -e "$@" | ||
else | ||
sed -i '' -e "$@" | ||
fi | ||
} | ||
|
||
update_project_clj() { | ||
local _v=$1 | ||
echo "Updating project.clj to version ${_v}" | ||
sed_inplace "s,\((defproject ${GITHUB_REPO} \)\"[^\"]*\",\1\"${_v}\"," project.clj | ||
} | ||
|
||
build_jars() { | ||
echo "Building JARs..." | ||
lein jar 2>&1 | sed -e 's,^, ,' | ||
} | ||
|
||
save_artifacts() { | ||
if [ -n "${CIRCLE_ARTIFACTS:-}" ]; then | ||
echo "Copying JARs to CircleCI artifacts..." | ||
find . -name '*.jar' -exec cp {} "${CIRCLE_ARTIFACTS}" \; | ||
echo "Copying junit.xml to CircleCI artifacts..." | ||
cp test/junit.xml "${CIRCLE_ARTIFACTS}/" | ||
fi | ||
} | ||
|
||
ensure_github_release_tool_installed() { | ||
local _cwd | ||
_cwd=$(pwd) | ||
|
||
if [ -z "${GOPATH:-}" ]; then | ||
export GOPATH=${_cwd}/.go | ||
fi | ||
export PATH="${PATH}:${GOPATH}/bin" | ||
if ! which github-release > /dev/null 2>&1; then | ||
echo "Installing github-release..." | ||
go get github.com/aktau/github-release | ||
fi | ||
} | ||
|
||
github_release() { | ||
local _version | ||
_version=$1 | ||
|
||
echo "Releasing ${_version}" | ||
github-release release \ | ||
--user "${GITHUB_USER}" \ | ||
--repo "${GITHUB_REPO}" \ | ||
--tag "${_version}" \ | ||
--target "$(sha)" \ | ||
--description "Release version ${_version}" | ||
find . -name '*.jar' | while read -r _jar; do | ||
github-release upload \ | ||
--user "${GITHUB_USER}" \ | ||
--repo "${GITHUB_REPO}" \ | ||
--tag "${_version}" \ | ||
--name "$(basename "${_jar}")" \ | ||
--file "${_jar}" | ||
done | ||
} | ||
|
||
clojars_deploy() { | ||
lein deploy clojars 2>&1 | sed -e 's,^, ,' | ||
} | ||
|
||
cleanup() { | ||
git clean -ffdx | ||
} | ||
|
||
v=$(new_version) | ||
update_project_clj "${v}" | ||
build_jars | ||
save_artifacts | ||
if [ "$(branch)" = "master" ]; then | ||
if [ -z "${CLOJARS_USERNAME:-}" ]; then | ||
abort "Missing environment variable: CLOJARS_USERNAME" | ||
fi | ||
if [ -z "${CLOJARS_PASSWORD:-}" ]; then | ||
abort "Missing environment variable: CLOJARS_PASSWORD" | ||
fi | ||
if [ -z "${GITHUB_TOKEN:-}" ]; then | ||
abort "Missing environment variable: GITHUB_TOKEN" | ||
fi | ||
|
||
# Make a GitHub release | ||
ensure_github_release_tool_installed | ||
github_release "${v}" | ||
|
||
# Push to clojars | ||
clojars_deploy | ||
fi | ||
cleanup |
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,13 @@ | ||
(ns clojure-test-junit-output.test-core | ||
(:require [clojure.test :refer :all] | ||
[clojure-test-junit-output.core :refer (with-junit-output)])) | ||
|
||
(use-fixtures :once (with-junit-output "test/junit.xml")) | ||
|
||
(deftest some-sort-of-a-test | ||
(testing "Success works" | ||
(is (= 1 1))) | ||
(testing "Failure works" | ||
(is (= 1 0))) | ||
(testing "Errors work." | ||
(throw (Exception. "This shouldn't really kill things.")))) |