Added ci pipeline
This commit is contained in:
parent
1356c84627
commit
0cc6a08fdb
|
@ -24,3 +24,5 @@ _testmain.go
|
|||
*.prof
|
||||
|
||||
esuf
|
||||
credentials.yml
|
||||
ci/credentials.yml
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# build.sh - Build wrapper
|
||||
#
|
||||
# - changes build id from "master" to the commitish of HEAD
|
||||
# - detects if there are uncommitted local changes
|
||||
# - runs go build to build a esuf binary
|
||||
# - undoes the change (so that it doesn't get committed)
|
||||
|
||||
function auto_sed() {
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
sed -i '' -e "$cmd" $@
|
||||
else
|
||||
sed -i -e "$cmd" $@
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# track dirty changes in the local working copy
|
||||
if [[ $(git status --porcelain) != "" ]]; then
|
||||
auto_sed "s/var DIRTY = \".*\"/var DIRTY = \" with uncommitted local changes\"/" main.go
|
||||
fi
|
||||
|
||||
# update BUILD to be the HEAD commit-ish
|
||||
sha1=$(git rev-list --abbrev-commit HEAD -n1)
|
||||
if [[ -z ${IN_RELEASE} ]]; then
|
||||
auto_sed "s/var BUILD = \".*\"/var BUILD = \"${sha1}\"/" main.go
|
||||
else
|
||||
auto_sed "s/var BUILD = \".*\"/var BUILD = \"release\"/" main.go
|
||||
fi
|
||||
|
||||
# do the build
|
||||
if [[ -n ${IN_RELEASE} ]]; then
|
||||
mkdir -p releases
|
||||
gox -osarch="linux/amd64 linux/386 darwin/amd64" --output="${OUTPUT:-releases}/esuf-{{.OS}}-{{.Arch}}"
|
||||
elif [[ -n ${1} ]]; then
|
||||
# allow usage like `./build.sh linux/amd64`
|
||||
gox -osarch="$*" --output="esuf-{{.OS}}-{{.Arch}}"
|
||||
fi
|
||||
|
||||
go build .
|
||||
|
||||
# put it all back
|
||||
auto_sed "s/var BUILD = \".*\"/var BUILD = \"master\"/" main.go
|
||||
auto_sed "s/var DIRTY = \".*\"/var DIRTY = \"\"/" main.go
|
||||
|
||||
# what version?
|
||||
./esuf -v
|
|
@ -0,0 +1,27 @@
|
|||
Pipeline for building/testing release
|
||||
=====================================
|
||||
|
||||
Pipeline running at http://ci.starkandwayne.com:8080/pipelines/esuf-release
|
||||
|
||||
Setup pipeline in Concourse
|
||||
---------------------------
|
||||
|
||||
```
|
||||
fly -t sw c -c pipeline.yml --vars-from credentials.yml esuf-release --paused=false
|
||||
```
|
||||
|
||||
Building/updating the base Docker image for tasks
|
||||
-------------------------------------------------
|
||||
|
||||
Each task within all job build plans uses the same base Docker image for all dependencies. Using the same Docker image is a convenience. This section explains how to re-build and push it to Docker Hub.
|
||||
|
||||
All the resources used in the pipeline are shipped as independent Docker images and are outside the scope of this section.
|
||||
|
||||
```
|
||||
fly -t sw configure \
|
||||
-c ci_image/pipeline.yml \
|
||||
--vars-from credentials.yml \
|
||||
esuf-release-image --paused=false
|
||||
```
|
||||
|
||||
This will ask your targeted Concourse to pull down this project repository, and build the `ci_image/Dockerfile`, and push it to a Docker image on Docker Hub.
|
|
@ -0,0 +1,140 @@
|
|||
groups:
|
||||
- name: build
|
||||
jobs:
|
||||
- testflight
|
||||
- rc
|
||||
- shipit
|
||||
- name: version
|
||||
jobs:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
|
||||
jobs:
|
||||
- name: testflight
|
||||
public: true
|
||||
serial: true
|
||||
plan:
|
||||
- do:
|
||||
- aggregate:
|
||||
- get: esuf
|
||||
resource: git-esuf
|
||||
trigger: true
|
||||
- task: run_tests
|
||||
config:
|
||||
platform: linux
|
||||
image: {{docker-hub-task-image}}
|
||||
inputs:
|
||||
- name: esuf
|
||||
path: .
|
||||
run:
|
||||
path: ./ci/scripts/run_tests.sh
|
||||
args: []
|
||||
|
||||
- name: rc
|
||||
public: true
|
||||
plan:
|
||||
- aggregate:
|
||||
- get: esuf
|
||||
resource: git-esuf
|
||||
passed: [testflight]
|
||||
trigger: true
|
||||
- get: version
|
||||
trigger: false
|
||||
params: {pre: rc}
|
||||
- put: version
|
||||
params: {file: version/number}
|
||||
|
||||
- name: patch
|
||||
public: true
|
||||
plan:
|
||||
- aggregate:
|
||||
- get: version
|
||||
trigger: false
|
||||
params: {bump: patch}
|
||||
- put: version
|
||||
params: {file: version/number}
|
||||
|
||||
- name: minor
|
||||
public: true
|
||||
plan:
|
||||
- aggregate:
|
||||
- get: version
|
||||
trigger: false
|
||||
params: {bump: minor}
|
||||
- put: version
|
||||
params: {file: version/number}
|
||||
|
||||
- name: major
|
||||
public: true
|
||||
plan:
|
||||
- aggregate:
|
||||
- get: version
|
||||
trigger: false
|
||||
params: {bump: major}
|
||||
- put: version
|
||||
params: {file: version/number}
|
||||
|
||||
- name: shipit
|
||||
public: true
|
||||
serial: true
|
||||
plan:
|
||||
- aggregate:
|
||||
- get: version
|
||||
passed: [rc]
|
||||
params: {bump: final}
|
||||
- get: esuf
|
||||
resource: git-esuf
|
||||
passed: [rc]
|
||||
- task: create-final-release
|
||||
config:
|
||||
platform: linux
|
||||
image: {{docker-hub-task-image}}
|
||||
inputs:
|
||||
- name: esuf
|
||||
- name: version
|
||||
run:
|
||||
path: ./esuf/ci/scripts/shipit.sh
|
||||
args: []
|
||||
params:
|
||||
RELEASE: esuf Release
|
||||
VERSION_FROM: ../version/number
|
||||
- put: git-esuf
|
||||
params:
|
||||
repository: create-final-release/esuf
|
||||
rebase: true
|
||||
- aggregate:
|
||||
- put: version
|
||||
params: {file: version/number}
|
||||
- put: github-final-release
|
||||
params:
|
||||
name: create-final-release/esuf/releases/name
|
||||
tag: create-final-release/esuf/releases/tag
|
||||
body: create-final-release/esuf/releases/notes.md
|
||||
globs:
|
||||
- create-final-release/esuf/releases/esuf-*
|
||||
|
||||
|
||||
resources:
|
||||
- name: version
|
||||
type: semver
|
||||
source:
|
||||
key: current-version
|
||||
bucket: {{pipeline-aws-bucket}}
|
||||
access_key_id: {{pipeline-aws-access-key-id}}
|
||||
secret_access_key: {{pipeline-aws-secret-access-key}}
|
||||
initial_version: 0.1.0
|
||||
|
||||
- name: git-esuf
|
||||
type: git
|
||||
source:
|
||||
uri: git@github.com:starkandwayne/esuf.git
|
||||
branch: master
|
||||
private_key: {{github-private-key}}
|
||||
|
||||
- name: github-final-release
|
||||
type: github-release
|
||||
source:
|
||||
user: starkandwayne
|
||||
repository: esuf
|
||||
access_token: {{github-access-token}}
|
|
@ -0,0 +1,3 @@
|
|||
Initial release of `esuf`
|
||||
|
||||
For fixing unassigned shards in elasticsearch clusters
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
# change to root of release
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
cd $DIR/../..
|
||||
|
||||
godep restore
|
||||
|
||||
go vet -x ./...
|
||||
golint ./...
|
||||
go test -v ./...
|
|
@ -0,0 +1,109 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
[ -n "${DEBUG}" ] && set -x
|
||||
PACKAGE=github.com/starkandwayne/esuf
|
||||
|
||||
#
|
||||
# ci/scripts/shipit.sh - Perform Release Activities for esuf
|
||||
#
|
||||
# This script is run from a Concourse pipeline (per ci/pipeline.yml).
|
||||
#
|
||||
# It is chiefly responsible for:
|
||||
# - bumping the version embedded in main.go,
|
||||
# - committing that change back to the repo (and pushing it),
|
||||
# - cross-compiling esuf for the desired platforms
|
||||
# - copying release notes around
|
||||
# - providing a final 'releases/' directory for use by the
|
||||
# next step in the pipeline (a github-release put)
|
||||
#
|
||||
# The structure of 'releases/' directory is:
|
||||
# ${ROOT}/releases/
|
||||
# ├── name
|
||||
# ├── notes.md
|
||||
# ├── esuf-${OS}-${ARCH}*
|
||||
# └── tag
|
||||
#
|
||||
# Environment Variables
|
||||
# RELEASE - The name of the RELEASE (i.e. "esuf Release")
|
||||
# VERSION - The version to bump to. If not set, the version number
|
||||
# *must* be found in the file ${VERSION_FROM} (which must
|
||||
# contain the path to a real, regular file)
|
||||
#
|
||||
|
||||
function auto_sed() {
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
sed -i '' -e "$cmd" $@
|
||||
else
|
||||
sed -i -e "$cmd" $@
|
||||
fi
|
||||
}
|
||||
|
||||
# change to root of esuf repository (from ci/scripts)
|
||||
ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )
|
||||
cd $ROOT
|
||||
|
||||
# NB: VERSION_FROM overrides whatever explicit version has been set
|
||||
# in the environment, since only Concourse should be setting VERSION_FROM
|
||||
if [[ -z "${VERSION:-}" || -n "${VERSION_FROM:-}" ]]; then
|
||||
if [[ -z "${VERSION_FROM:-}" ]]; then
|
||||
echo >&2 "No VERSION env var specified, and VERSION_FROM is empty or not set"
|
||||
echo >&2 "You need to either set an explicit version via VERSION=<x.y.z>,"
|
||||
echo >&2 "or, point me at a file containing the version via VERSION_FROM=<path>"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f ${VERSION_FROM} ]]; then
|
||||
echo >&2 "No VERSION env var specified, and ${VERSION_FROM} file not found"
|
||||
echo >&2 " (from cwd $PWD)"
|
||||
exit 1
|
||||
fi
|
||||
VERSION=$(cat ${VERSION_FROM})
|
||||
if [[ -z "${VERSION:-}" ]]; then
|
||||
echo >&2 "VERSION not found in ${VERSION_FROM}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "${RELEASE:-}" ]]; then
|
||||
RELEASE="esuf Release"
|
||||
fi
|
||||
|
||||
echo ">> Bumping ${RELEASE} to ${VERSION}"
|
||||
auto_sed "s/var VERSION = \".*\"/var VERSION = \"${VERSION}\"/" main.go
|
||||
|
||||
set +e
|
||||
if [[ -z $(git config --global user.email) ]]; then
|
||||
git config --global user.email "drnic+bot@starkandwayne.com"
|
||||
fi
|
||||
if [[ -z $(git config --global user.name) ]]; then
|
||||
git config --global user.name "CI Bot"
|
||||
fi
|
||||
set -e
|
||||
|
||||
echo ">> Running git operations as $(git config --global user.name) <$(git config --global user.email)>"
|
||||
echo ">> Getting back to master (from detached-head)"
|
||||
git merge --no-edit master
|
||||
echo ">> Adding all modified files"
|
||||
git add -A
|
||||
git status
|
||||
echo ">> Committing version bump (and any other changes)"
|
||||
git commit -m "update release version to v${VERSION}"
|
||||
|
||||
|
||||
echo "Preparing Github release"
|
||||
mkdir -p ${ROOT}/releases
|
||||
cp ${ROOT}/ci/release_notes.md ${ROOT}/releases/notes.md
|
||||
echo "${RELEASE} v${VERSION}" > ${ROOT}/releases/name
|
||||
echo "v${VERSION}" > ${ROOT}/releases/tag
|
||||
|
||||
echo ">> Running cross-compiling build (in $(pwd))"
|
||||
godep restore
|
||||
go get github.com/mitchellh/gox
|
||||
OUTPUT=${ROOT}/releases IN_RELEASE=yes ./build.sh
|
||||
./esuf -v 2>&1 | grep "./esuf - Version ${VERSION} (release)"
|
||||
|
||||
echo ">> Github release is ready to go (in ${ROOT}/releases)"
|
||||
|
||||
# vim:ft=bash
|
Loading…
Reference in New Issue