Skip to content

Commit 5e92385

Browse files
tests(ci): switch over to using jenkins (#112)
1 parent d31319b commit 5e92385

4 files changed

Lines changed: 134 additions & 53 deletions

File tree

.travis.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

Jenkinsfile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
def workpath_linux = "/src/github.com/deis/workflow-cli"
2+
def keyfile = "tmp/key.json"
3+
4+
def upload_artifacts = { String filepath ->
5+
withCredentials([[$class: 'FileBinding', credentialsId: 'e80fd033-dd76-4d96-be79-6c272726fb82', variable: 'GCSKEY']]) {
6+
sh "cat \"\${GCSKEY}\" > ${filepath}"
7+
sh "make upload-gcs"
8+
}
9+
}
10+
11+
def gopath_linux = {
12+
def gopath = pwd() + "/gopath"
13+
env.GOPATH = gopath
14+
gopath
15+
}
16+
17+
def workdir_linux = { String gopath ->
18+
gopath + workpath_linux
19+
}
20+
21+
node('windows') {
22+
def gopath = pwd() + "\\gopath"
23+
env.GOPATH = gopath
24+
def workdir = gopath + "\\src\\github.com\\deis\\workflow-cli"
25+
26+
def pscmd = { String cmd ->
27+
"powershell -NoProfile -ExecutionPolicy Bypass -Command \"${cmd}\""
28+
}
29+
30+
dir(workdir) {
31+
stage 'Checkout Windows'
32+
checkout scm
33+
stage 'Install Windows'
34+
bat pscmd('.\\make bootstrap')
35+
stage 'Test Windows'
36+
bat pscmd('.\\make test')
37+
}
38+
}
39+
40+
node('linux') {
41+
def gopath = gopath_linux()
42+
def workdir = workdir_linux(gopath)
43+
44+
dir(workdir) {
45+
stage 'Checkout Linux'
46+
checkout scm
47+
stage 'Install Linux'
48+
sh 'make bootstrap'
49+
stage 'Test Linux'
50+
sh 'make test'
51+
}
52+
}
53+
54+
stage 'Build and Upload Artifacts'
55+
56+
parallel(
57+
revision: {
58+
node('linux') {
59+
def gopath = gopath_linux()
60+
def workdir = workdir_linux(gopath)
61+
62+
dir(workdir) {
63+
checkout scm
64+
65+
// HACK: Recommended approach for getting command output is writing to and then reading a file.
66+
sh 'mkdir -p tmp'
67+
sh 'git rev-parse --abbrev-ref HEAD > tmp/GIT_BRANCH'
68+
sh 'git tag -l --contains HEAD > tmp/GIT_TAG'
69+
def git_branch = readFile('tmp/GIT_BRANCH')
70+
def git_tag = readFile('tmp/GIT_TAG')
71+
72+
if (git_branch != "master" && git_tag == "") {
73+
echo "Skipping build of 386 binaries to shorten CI for Pull Requests"
74+
env.BUILD_ARCH = "amd64"
75+
}
76+
77+
sh 'make bootstrap'
78+
sh 'make build-revision'
79+
80+
upload_artifacts(keyfile)
81+
}
82+
}
83+
},
84+
latest: {
85+
node('linux') {
86+
def gopath = gopath_linux()
87+
def workdir = workdir_linux(gopath)
88+
89+
dir(workdir) {
90+
checkout scm
91+
92+
// HACK: Recommended approach for getting command output is writing to and then reading a file.
93+
sh 'mkdir -p tmp'
94+
sh 'git rev-parse --abbrev-ref HEAD > tmp/GIT_BRANCH'
95+
def git_branch = readFile('tmp/GIT_BRANCH')
96+
97+
if (git_branch == "master") {
98+
sh 'make bootstrap'
99+
sh 'make build-latest'
100+
101+
upload_artifacts(keyfile)
102+
} else {
103+
echo "Skipping build of latest artifacts because this build is not on the master branch (branch: ${git_branch})"
104+
}
105+
}
106+
}
107+
}
108+
)

Makefile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,30 @@ else
1010
GOOS=linux
1111
endif
1212

13+
BUILD_OS ?=linux darwin windows
14+
BUILD_ARCH ?=amd64 386
15+
1316
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.10.0
1417
DEV_ENV_WORK_DIR := /go/src/${repo_path}
1518
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -e CGO_ENABLED=0 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
1619
DEV_ENV_PREFIX_CGO_ENABLED := docker run --rm -e GO15VENDOREXPERIMENT=1 -e CGO_ENABLED=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
1720
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
1821
DIST_DIR := _dist
1922

23+
GSUTIL_IMAGE := google/cloud-sdk:latest
24+
GSUTIL_PREFIX := docker run --rm -v ${CURDIR}/tmp:/.config -v ${CURDIR}/${DIST_DIR}:/upload
25+
GSUTIL_CMD := ${GSUTIL_PREFIX} ${GSUTIL_IMAGE}
26+
GCS_BUCKET ?= "gs://workflow-cli"
27+
2028
GO_FILES = $(wildcard *.go)
2129
GO_LDFLAGS = -ldflags "-s -X ${repo_path}/version.BuildVersion=${VERSION}"
2230
GO_PACKAGES = cmd parser $(wildcard pkg/*)
2331
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
2432
GOFMT = gofmt -e -l -s
2533
GOTEST = go test --cover --race -v
2634

35+
# The tag of the commit
36+
GIT_TAG := $(shell git tag -l --contains HEAD)
2737
VERSION ?= $(shell git rev-parse --short HEAD)
2838

2939
define check-static-binary
@@ -44,14 +54,19 @@ glideup:
4454
build: binary-build
4555
@$(call check-static-binary,deis)
4656

47-
build-all:
48-
${DEV_ENV_CMD} gox -verbose ${GO_LDFLAGS} -os="linux darwin windows" -arch="amd64 386" -output="$(DIST_DIR)/deis-latest-{{.OS}}-{{.Arch}}" .
49-
ifdef TRAVIS_TAG
50-
${DEV_ENV_CMD} gox -verbose ${GO_LDFLAGS} -os="linux darwin windows" -arch="amd64 386" -output="$(DIST_DIR)/${TRAVIS_TAG}/deis-${TRAVIS_TAG}-{{.OS}}-{{.Arch}}" .
57+
build-latest:
58+
${DEV_ENV_CMD} gox -verbose -parallel=3 ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="$(DIST_DIR)/deis-latest-{{.OS}}-{{.Arch}}" .
59+
60+
build-revision:
61+
ifdef GIT_TAG
62+
${DEV_ENV_CMD} gox -verbose -parallel=3 ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="$(DIST_DIR)/${GIT_TAG}/deis-${GIT_TAG}-{{.OS}}-{{.Arch}}" .
5163
else
52-
${DEV_ENV_CMD} gox -verbose ${GO_LDFLAGS} -os="linux darwin windows" -arch="amd64 386" -output="$(DIST_DIR)/${VERSION}/deis-${VERSION}-{{.OS}}-{{.Arch}}" .
64+
${DEV_ENV_CMD} gox -verbose -parallel=3 ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="$(DIST_DIR)/${VERSION}/deis-${VERSION}-{{.OS}}-{{.Arch}}" .
5365
endif
5466

67+
build-all: build-latest build-revision
68+
69+
5570
binary-build:
5671
${DEV_ENV_PREFIX} -e GOOS=${GOOS} ${DEV_ENV_IMAGE} go build -a -installsuffix cgo ${GO_LDFLAGS} -o deis .
5772

@@ -86,3 +101,9 @@ test-style:
86101

87102
test-unit:
88103
${DEV_ENV_PREFIX_CGO_ENABLED} ${DEV_ENV_IMAGE} sh -c '${GOTEST} $$(glide nv)'
104+
105+
upload-gcs:
106+
${GSUTIL_CMD} sh -c 'gcloud auth activate-service-account -q --key-file /.config/key.json'
107+
${GSUTIL_CMD} sh -c 'gsutil -mq cp -a public-read -r /upload/* ${GCS_BUCKET}'
108+
# This has to run in the container to delete files created by the container
109+
${GSUTIL_CMD} sh -c 'rm -rf /.config/*'

appveyor.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)