Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .cilibs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash -e

GATE_VERSION=release-1.20.x
BUILD_OS=linux
BUILD_ARCH=amd64


while getopts "o:a:g:c:" opt; do
case ${opt} in
o) #Build OS
BUILD_OS=${OPTARG}
;;
a) #Build arch
BUILD_ARCH=${OPTARG}
;;
g) #Gate version
GATE_VERSION=${OPTARG}
;;
c) #Send Coverity
SEND_COVERITY=${OPTARG}
;;
esac
done

.cilibs/get_dependencies.sh

.cilibs/examine_source_code_with_go_get.sh

.cilibs/execute_go_tests.sh

.cilibs/compile_code.sh -o ${BUILD_OS} -a ${BUILD_ARCH} -g ${GATE_VERSION}

.cilibs/calculate_code_coverage.sh $SEND_COVERITY

.cilibs/check_linting.sh

.cilibs/copy_binaries_for_later_use.sh

.cilibs/generate_checksum.sh -o ${BUILD_OS} -a ${BUILD_ARCH} -g ${GATE_VERSION}

31 changes: 31 additions & 0 deletions .cilibs/calculate_code_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -e

SEND_COVERITY=$1
COMMIT_ID="${CIRCLE_SHA1:-$TRAVIS_COMMIT}"


echo "Calculate code coverage"
REQUIREDCODECOVERAGE=60
go tool cover -func cover.out | tee codecoverage.txt
CURRENTCODECOVERAGE=$(grep 'total:' codecoverage.txt | awk '{print substr($3, 1, length($3)-1)}')

echo "Send coverity report to SeriesCI"
if [[ $SEND_COVERITY == "send" ]]
then
curl \
--header "Authorization: Token ${SERIESCI_TOKEN}" \
--header "Content-Type: application/json" \
--data "{\"value\":\"${CURRENTCODECOVERAGE} %\",\"sha\":\"${COMMIT_ID}\"}" \
https://seriesci.com/api/codilime/floodgate/coverage/one
else
echo "Skipping"
fi
if [ ${CURRENTCODECOVERAGE%.*} -lt ${REQUIREDCODECOVERAGE} ]
then
echo "Not enough code coverage!"
echo "Current code coverage: ${CURRENTCODECOVERAGE}%"
echo "Required code coverage: ${REQUIREDCODECOVERAGE}%"
exit 1
else
echo "Code coverage is at least ${REQUIREDCODECOVERAGE}% : OK"
fi
8 changes: 8 additions & 0 deletions .cilibs/check_linting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

echo "Check linting"
for GOSRCFILE in $( find . -type f -name '*.go' -not -path './gateapi/*')
do
golint -set_exit_status $GOSRCFILE
done

42 changes: 42 additions & 0 deletions .cilibs/compile_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash -e

GATE_VERSION=release-1.20.x
BUILD_OS=linux
BUILD_ARCH=amd64
COMMIT_ID="${CIRCLE_SHA1:-$TRAVIS_COMMIT}"


while getopts "o:a:g:" opt; do
case ${opt} in
o) #Build OS
BUILD_OS=${OPTARG}
;;
a) #Build arch
BUILD_ARCH=${OPTARG}
;;
g) #Gate version
GATE_VERSION=${OPTARG}
;;
esac
done

if [ ! -z "$TRAVIS_BRANCH" ]
then
export RELEASE=$TRAVIS_BRANCH
elif [ -z "$CIRCLE_BRANCH" ]
then
export RELEASE=$(echo $CIRCLE_TAG | sed 's/^v[0-9]\+\.[0-9]\+\.[0-9]\+-\?//')
else
export RELEASE=$CIRCLE_BRANCH
fi

echo "Compile code"

env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} go build -ldflags \
"-X github.com/codilime/floodgate/version.GitCommit=$COMMIT_ID \
-X github.com/codilime/floodgate/version.BuiltDate=$(date +%Y-%m-%d_%H:%M:%S) \
-X github.com/codilime/floodgate/version.Release=$RELEASE \
-X github.com/codilime/floodgate/version.GoVersion=$GOLANG_VERSION \
-X github.com/codilime/floodgate/version.GateVersion=$(echo ${GATE_API_BRANCH} | sed 's/release-//') \
"

7 changes: 7 additions & 0 deletions .cilibs/copy_binaries_for_later_use.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -e

echo "Copy binaries for later use"
mkdir -p /floodgate/bin
chmod 777 /floodgate/bin
cp /go/src/github.com/codilime/floodgate/floodgate /floodgate/bin/floodgate

4 changes: 4 additions & 0 deletions .cilibs/examine_source_code_with_go_get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e

echo "Examine source code with go vet"
go vet -v ./...
4 changes: 4 additions & 0 deletions .cilibs/execute_go_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e

echo "Execute go tests"
go test -v ./... -coverprofile cover.out
26 changes: 26 additions & 0 deletions .cilibs/generate_checksum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -e

GATE_API_BRANCH=release-1.20.x
BUILD_OS=linux
BUILD_ARCH=amd64


while getopts "o:a:g:" opt; do
case ${opt} in
o) #Build OS
BUILD_OS=${OPTARG}
;;
a) #Build arch
BUILD_ARCH=${OPTARG}
;;
g) #Gate version
GATE_API_BRANCH=${OPTARG}
;;
esac
done

echo "Generate checksum"
cd /go/src/github.com/codilime/floodgate/
cp floodgate floodgate-$GATE_API_BRANCH.$BUILD_OS.$BUILD_ARCH
sha1sum floodgate-$GATE_API_BRANCH.$BUILD_OS.$BUILD_ARCH > floodgate-$GATE_API_BRANCH.$BUILD_OS.$BUILD_ARCH.sha1sum

8 changes: 8 additions & 0 deletions .cilibs/generate_swagger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

GATE_API_BRANCH=$1

.cilibs/prepare_extra_directories.sh

.cilibs/setup_swagger.sh $GATE_API_BRANCH

5 changes: 5 additions & 0 deletions .cilibs/get_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

echo "Get dependencies"
go mod download
go get -u golang.org/x/lint/golint
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/bash -xe
#!/bin/bash -e

EXEC_DIR=$(dirname "$0")
HAL_VERSION=${HAL_VERSION:-1.35.0}

# Install packages
sudo apt update
sudo apt install -y jq

# Install Halyard
curl -O https://raw.githubusercontent.com/spinnaker/halyard/master/install/debian/InstallHalyard.sh
USERNAME=`whoami`
sudo bash InstallHalyard.sh --version ${HAL_VERSION} --user $USERNAME -y
hal -v

# Create Kind cluster
kind create cluster --config="${EXEC_DIR}/kind-cluster-config.yaml"
kind create cluster --config="${EXEC_DIR}/templates/kind-cluster-config.yaml"
kubectl config use-context kind-kind
kubectl cluster-info

Expand All @@ -22,12 +26,16 @@ GATE_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
hal -q config provider kubernetes enable
CONTEXT=$(kubectl config current-context)
hal -q config provider kubernetes account add my-k8s-v2-account --provider-version v2 --context $CONTEXT
## Configure account for inner kind communication
cp ~/.kube/config ~/.kube/kind
sed -i "s/server:\ .*/server:\ https:\/\/10.96.0.1:443/g" ~/.kube/kind
hal -q config provider kubernetes account add inner-kind --provider-version v2 --context $CONTEXT --kubeconfig-file ~/.kube/kind
hal -q config deploy edit --type distributed --account-name my-k8s-v2-account

## Install minio
kubectl create namespace spinnaker
sed -i 's/LoadBalancer/ClusterIP/g' "${EXEC_DIR}/minio-standalone.yaml"
kubectl -n spinnaker create -f "${EXEC_DIR}/minio-standalone.yaml"
sed -i 's/LoadBalancer/ClusterIP/g' "${EXEC_DIR}/templates/minio-standalone.yaml"
kubectl -n spinnaker create -f "${EXEC_DIR}/templates/minio-standalone.yaml"
mkdir -p ~/.hal/default/profiles
echo "spinnaker.s3.versioning: false" >> ~/.hal/default/profiles/front50-local.yml

Expand All @@ -47,8 +55,8 @@ hal config security api edit --override-base-url='http://spinnaker/api/v1'
echo 'window.spinnakerSettings.authEnabled = true;' > ~/.hal/default/profiles/settings-local.js
mkdir -p ~/.hal/default/service-settings
echo 'healthEndpoint: /api/v1/health' > ~/.hal/default/service-settings/gate.yml
sed -i "s/GATE_PASS/${GATE_PASS}/g" "${EXEC_DIR}/gate-local.yml"
cp "${EXEC_DIR}/gate-local.yml" ~/.hal/default/profiles/gate-local.yml
sed -i "s/GATE_PASS/${GATE_PASS}/g" "${EXEC_DIR}/templates/gate-local.yml"
cp "${EXEC_DIR}/templates/gate-local.yml" ~/.hal/default/profiles/gate-local.yml

# Install Spinnaker
hal -q deploy apply
Expand All @@ -58,11 +66,11 @@ do
done

# Install Ingress controller
kubectl apply -f "${EXEC_DIR}/ingress-mandatory.yaml"
kubectl apply -f "${EXEC_DIR}/ingress-service-nodeport.yaml"
kubectl apply -f "${EXEC_DIR}/templates/ingress-mandatory.yaml"
kubectl apply -f "${EXEC_DIR}/templates/ingress-service-nodeport.yaml"
kubectl patch deployments -n ingress-nginx nginx-ingress-controller -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx-ingress-controller","ports":[{"containerPort":80,"hostPort":80},{"containerPort":443,"hostPort":443}]}],"nodeSelector":{"ingress-ready":"true"},"tolerations":[{"key":"node-role.kubernetes.io/master","operator":"Equal","effect":"NoSchedule"}]}}}}'
kubectl -n spinnaker apply -f "${EXEC_DIR}/spinnaker-ingress.yaml"
kubectl -n spinnaker apply -f "${EXEC_DIR}/templates/spinnaker-ingress.yaml"

# Generate Floodgate config file
sed -i "s/GATE_PASS/${GATE_PASS}/g" "${EXEC_DIR}/floodgate-config.yaml"
cp "${EXEC_DIR}/floodgate-config.yaml" ~/floodgate.yaml
sed -i "s/GATE_PASS/${GATE_PASS}/g" "${EXEC_DIR}/templates/floodgate-config.yaml"
cp "${EXEC_DIR}/templates/floodgate-config.yaml" ~/floodgate.yaml
13 changes: 13 additions & 0 deletions .cilibs/install_spinnaker_and_configure_floodgate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -e

GATE_API_BRANCH=$1

echo Install Spinnaker and configure Floodgate
export NEED_SPINNAKER_VERSION=$( echo $GATE_API_BRANCH | egrep -o "[0-9]\.[0-9]+" )
.cilibs/install-and-run-spinnaker.sh
until [ $( curl -w '%{http_code}' -o /dev/null http://spinnaker/api/v1 ) -eq 302 ]
do
echo "Waiting for Spinnaker"
sleep 10
done

8 changes: 8 additions & 0 deletions .cilibs/install_toolset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/
13 changes: 13 additions & 0 deletions .cilibs/prepare_directories.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -e

BUILD_OS=linux
BUILD_ARCH=amd64

sudo bash -c "source .cilibs/prepare_extra_directories.sh"
mkdir -p /floodgate/libs
mkdir -p /floodgate/resources
cp -r sponnet /floodgate/libs/
cp -r examples /floodgate/resources/
cp floodgate /floodgate/bin/
chmod +x /floodgate/bin/floodgate

5 changes: 5 additions & 0 deletions .cilibs/prepare_extra_directories.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

echo "Prepare extra directories"
mkdir -p /floodgate/bin
chmod 777 -R /floodgate
23 changes: 23 additions & 0 deletions .cilibs/setup_swagger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -e
export TERM=${TERM:-dumb} #Needed because sudo is used in CircleCi
GATE_API_BRANCH=$1

echo "Setup swagger-codegen"
SWAGGER_VERSION=$(cat gateapi/.swagger-codegen/VERSION)
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_VERSION}/swagger-codegen-cli-${SWAGGER_VERSION}.jar -O swagger-codegen-cli.jar
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_VERSION}/swagger-codegen-cli-${SWAGGER_VERSION}.jar.sha1 -O swagger-codegen-cli.jar.sha1
echo ' swagger-codegen-cli.jar' >> swagger-codegen-cli.jar.sha1
sha1sum -c swagger-codegen-cli.jar.sha1
mv swagger-codegen-cli.jar /floodgate/bin/

echo "Get gate code"
git clone https://github.com/spinnaker/gate.git -b ${GATE_API_BRANCH} /floodgate/gate

echo "Generate swagger.json"
cd /floodgate/gate
./gradlew clean
./gradlew gate-web:test --tests *GenerateSwagger* --max-workers 2
cat gate-web/swagger.json | json_pp > ./gate-swagger.json

echo "Generate gateapi go code"
java -jar /floodgate/bin/swagger-codegen-cli.jar generate -l go -i /floodgate/gate/gate-swagger.json -o /floodgate/gateapi
31 changes: 31 additions & 0 deletions .cilibs/start_spinnaker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -e

while getopts "o:a:g:e:" opt; do
case ${opt} in
o) #Build OS
BUILD_OS=${OPTARG}
;;
a) #Build arch
BUILD_ARCH=${OPTARG}
;;
g) #Gate version
GATE_VERSION=${OPTARG}
;;
e) #Floodgate extra params
FLOODGATE_EXTRA_PARAMS=${OPTARG}
;;
esac
done


.cilibs/prepare_directories.sh

.cilibs/install_toolset.sh

.cilibs/update_hosts.sh

.cilibs/wait_for_dpkg.sh

.cilibs/install_spinnaker_and_configure_floodgate.sh $GATE_API_BRANCH

.cilibs/test_floodgate_against_running_spinnaker_instance.sh $FLOODGATE_EXTRA_PARAMS
File renamed without changes.
17 changes: 17 additions & 0 deletions .cilibs/test_floodgate_against_running_spinnaker_instance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

FLOODGATE_EXTRA_PARAMS=$1

echo Test Floodgate against running Spinnaker instance

echo "Print version using version flag"
/floodgate/bin/floodgate --version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can add some info about what is happening before executing this commands?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added printing as was in .circleci/config.yml

echo "Print version using version command"
/floodgate/bin/floodgate version
echo "Comare changes - clean Spinnaker"
/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare && exit 1 || echo "Found changes"
echo "Apply local resources"
/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml sync
echo "Compare changes - synced resources"
/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare

Loading