Skip to content

Commit

Permalink
Merge pull request #205 from leaf-ai/feature/184_flux_trial
Browse files Browse the repository at this point in the history
Feature/184 CI Pipeline that avoids Travis and a$$ociated dependencies
  • Loading branch information
karlmutch authored Feb 6, 2019
2 parents 1d67a9a + 507d2e1 commit 0dcdfa0
Show file tree
Hide file tree
Showing 14 changed files with 521 additions and 23 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ FIXES:

IMPROVMENTS

* Image repository naming modified to work with dockerhub, images now pushed to the docker hub leafai account
* Image repository naming modified to work with dockerhub, images can now be pushed to the docker hub leafai account
* Git actions ready, changes to allow larger base containers to be prebuilt reducing build requirements in the Git infrastructure
* Test quay.io based builds from github commit/push on any branch.
* quay.io based builds from github commit/push on any branch
* keel.sh based CI with automatted builds and tests using git commit notifications
22 changes: 19 additions & 3 deletions Dockerfile_standalone
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ MAINTAINER [email protected]

ENV LANG C.UTF-8

ENV GO_VERSION 1.11.4
ENV GO_VERSION 1.11.5

RUN \
apt-get update && apt-get install -y apt-transport-https && \
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list && \
apt-get update && \
apt-get install -y kubectl

RUN \
mkdir -p /project/go && \
Expand All @@ -26,13 +33,22 @@ WORKDIR /project/src/github.com/leaf-ai/studio-go-runner

RUN mkdir $GOPATH/bin && \
(curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh) && \
git config --global url."git://github.com".insteadOf "https://github.com" && \
git config --global url."https://github.com/".insteadOf [email protected]: && \
git config --global url."https://".insteadOf git:// && \
go get github.com/karlmutch/enumer && \
go get github.com/karlmutch/petname && \
go install github.com/karlmutch/petname/cmd/petname && \
wget -q -O $GOPATH/bin/semver https://github.com/karlmutch/duat/releases/download/0.9.3/semver-linux-amd64 && \
wget -q -O $GOPATH/bin/stencil https://github.com/karlmutch/duat/releases/download/0.9.3/stencil-linux-amd64 && \
chmod +x $GOPATH/bin/semver && \
chmod +x $GOPATH/bin/stencil && \
rm /usr/bin/nvidia-*

LABEL author="Karl Mutch"

COPY . /project/src/github.com/leaf-ai/studio-go-runner/

CMD /bin/bash -c 'set -e ; set -o pipefail ; (dep ensure && go run build.go -r -dirs=internal && go run build.go -r -dirs=cmd && echo "Build Success" || echo "Build Failure") 2>&1 '
CMD /bin/bash -c './ci.sh'

# Done last to prevent lots of disruption when bumping versions
LABEL vendor="Open Source"
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# studio-go-runner

Version: <repo-version>0.9.9</repo-version>
Version: <repo-version>0.9.10</repo-version>

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/leaf-ai/studio-go-runner/blob/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/leaf-ai/studio-go-runner)](https://goreportcard.com/report/leaf-ai/studio-go-runner)[![DepShield Badge](https://depshield.sonatype.org/badges/leaf-ai/studio-go-runner/depshield.svg)](https://depshield.github.io)

Expand Down Expand Up @@ -130,9 +130,11 @@ To install the tools on Ubuntu use the following commands:

```shell
mkdir -p $GOPATH/bin
wget -O $GOPATH/bin/semver https://github.com/karlmutch/duat/releases/download/0.9.2/semver-linux-amd64
wget -O $GOPATH/bin/stencil https://github.com/karlmutch/duat/releases/download/0.9.2/stencil-linux-amd64
wget -O $GOPATH/bin/github-release https://github.com/karlmutch/duat/releases/download/0.9.2/github-release-linux-amd64
go get github.com/karlmutch/petname
go install github.com/karlmutch/petname/cmd/petname
wget -O $GOPATH/bin/semver https://github.com/karlmutch/duat/releases/download/0.9.3/semver-linux-amd64
wget -O $GOPATH/bin/stencil https://github.com/karlmutch/duat/releases/download/0.9.3/stencil-linux-amd64
wget -O $GOPATH/bin/github-release https://github.com/karlmutch/duat/releases/download/0.9.3/github-release-linux-amd64
chmod +x $GOPATH/bin/semver
chmod +x $GOPATH/bin/stencil
chmod +x $GOPATH/bin/github-release
Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ declare -i travis_end_time
}
fi

go get github.com/karlmutch/petname

go get -u github.com/golang/dep/cmd/dep

dep ensure
Expand Down Expand Up @@ -90,6 +92,7 @@ trap Tidyup 1 2 3 15

export SEMVER=`semver`
export GIT_BRANCH=`echo '{{.duat.gitBranch}}'|stencil - | tr '_' '-' | tr '\/' '-'`
GIT_COMMIT=`git rev-parse HEAD`
export RUNNER_BUILD_LOG=build-$GIT_BRANCH.log
exit_code=0

Expand Down
124 changes: 124 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/bin/bash -e

[ -z "$GOPATH" ] && echo "Error: env variable GOPATH must be set" && exit 1;
[ -z "$GITHUB_TOKEN" ] && echo "Warning : env variable GITHUB_TOKEN should be set in the event that a release is to be generated" ;
[ -z ${azure_registry_name+x} ] && echo "Warning : env variable azure_registry_name not set";

if [[ ":$PATH:" != *":$GOPATH/bin:"* ]]; then
export PATH=$PATH:$GOPATH/bin
fi

export LOGXI="*=DBG"
export LOGXI_FORMAT="happy,maxcol=1024"

[ -z "$TERM" ] && export TERM=xterm+256color;

if [ -n "$(type -t travis_fold)" ] && [ "$(type -t travis_fold)" = function ]; then
type travis_fold
type travis_nanoseconds
type travis_time_start
type travis_time_finish
:
else
declare -i travis_start_time
declare -i travis_end_time

function travis_nanoseconds () {
local cmd="date";
local format="+%s%N";
local os=$(uname);
if hash gdate > /dev/null 2>&1; then
cmd="gdate";
else
if [[ "$os" = Darwin ]]; then
format="+%s000000000";
fi;
fi;
$cmd -u $format
}

function travis_fold() {
local action=$1;
local name=$2;
echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}"
}
function travis_time_start() {
travis_timer_id=$(printf %08x $(( RANDOM * RANDOM )));
travis_start_time=$(travis_nanoseconds);
echo -en "travis_time:start:$travis_timer_id\r${ANSI_CLEAR}"
}
function travis_time_finish() {
local result=$?;
travis_end_time=$(travis_nanoseconds);
local duration=$(($travis_end_time-$travis_start_time));
echo -en "\ntravis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r${ANSI_CLEAR}";
return $result

}
fi

go get -u github.com/golang/dep/cmd/dep

dep ensure

bash -c "while true; do echo \$(date) - building ...; sleep 180s; done" &
PING_LOOP_PID=$!

function cleanup {
# nicely terminate the ping output loop
kill $PING_LOOP_PID
}
trap cleanup EXIT

function ExitWithError
{
echo "$*">&2
rm -f $working_file
exit 1
}

function Tidyup
{
ExitWithError "Abort"
}

umask 077
working_file=$$.studio-go-runner-working
rm -f $working_file
trap Tidyup 1 2 3 15

export GIT_BRANCH=`echo '{{.duat.gitBranch}}' | stencil - | tr '_' '-' | tr '\/' '-'`
export RUNNER_BUILD_LOG=build-$GIT_BRANCH.log

exit_code=0

# Determine if we are running under a keel based CI build and if so ...
export

travis_fold start "build.image"
travis_time_start
set -o pipefail ; (go run build.go -r -dirs=internal && go run build.go -r -dirs=cmd && echo "Success" || echo "Failure") 2>&1 | tee $RUNNER_BUILD_LOG
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
travis_time_finish
travis_fold end "build.image"

cleanup

echo "Starting the namespace injections etc" $K8S_POD_NAME
kubectl label deployment build keel.sh/policy=force --namespace=$K8S_NAMESPACE
kubectl scale --namespace $K8S_NAMESPACE --replicas=0 rc/rabbitmq-controller
kubectl scale --namespace $K8S_NAMESPACE --replicas=0 deployment/minio-deployment

for (( ; ; ))
do
sleep 600
done

if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

exit 0
Loading

0 comments on commit 0dcdfa0

Please sign in to comment.