From 1e82c8c088f1510b84ea50651ae9a9a9f34221cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 16 Jun 2020 11:05:39 +0200 Subject: [PATCH 01/18] add travis configuration --- .travis.yml | 19 ++ .travisci/.generate_swagger.sh.swp | Bin 0 -> 12288 bytes .travisci/build.sh | 69 ++++++ .travisci/floodgate-config.yaml | 13 ++ .travisci/gate-local.yml | 15 ++ .travisci/generate_swagger.sh | 30 +++ .travisci/ingress-mandatory.yaml | 295 ++++++++++++++++++++++++ .travisci/ingress-service-nodeport.yaml | 27 +++ .travisci/install-and-run-spinnaker.sh | 76 ++++++ .travisci/install-toolset.sh | 8 + .travisci/kind-cluster-config.yaml | 21 ++ .travisci/minio-standalone.yaml | 98 ++++++++ .travisci/spinnaker-ingress.yaml | 21 ++ .travisci/start_spinnaker.sh | 42 ++++ .travisci/trigger-pipelines.sh | 53 +++++ .travisci/wait_for_dpkkg.sh | 7 + 16 files changed, 794 insertions(+) create mode 100644 .travis.yml create mode 100644 .travisci/.generate_swagger.sh.swp create mode 100644 .travisci/build.sh create mode 100644 .travisci/floodgate-config.yaml create mode 100644 .travisci/gate-local.yml create mode 100644 .travisci/generate_swagger.sh create mode 100644 .travisci/ingress-mandatory.yaml create mode 100644 .travisci/ingress-service-nodeport.yaml create mode 100755 .travisci/install-and-run-spinnaker.sh create mode 100644 .travisci/install-toolset.sh create mode 100644 .travisci/kind-cluster-config.yaml create mode 100644 .travisci/minio-standalone.yaml create mode 100644 .travisci/spinnaker-ingress.yaml create mode 100644 .travisci/start_spinnaker.sh create mode 100755 .travisci/trigger-pipelines.sh create mode 100644 .travisci/wait_for_dpkkg.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b57f947 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +dist: xenial +language: go +go: + - 1.14.1 + +services: + - docker + +before_script: + - docker pull openjdk:11.0.3-stretch + - docker run -w /workspace -v .:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch + +script: + - docker pull golang:1.14.1-stretch + - docker run -w /workspace -v .:/workspace --entrypoint /workspace/.travisci/build.sh --rm golang:1.14.1-stretch + +after_success: + - .travisci/start_spinnaker.sh + diff --git a/.travisci/.generate_swagger.sh.swp b/.travisci/.generate_swagger.sh.swp new file mode 100644 index 0000000000000000000000000000000000000000..7b8cf082f5bc806c681f5b84fa1f0b450c8b3b42 GIT binary patch literal 12288 zcmeI2&ui2`6vtmZs#Vc@owf_r!X({_R0}O^Wm&7(mTs-};xd~|lWaGckYslYwf;T` z{sA5YJ$drzQScwJ_UcK{e?WZ6CUwcWN^e$P;LCI;@6CJfGcyZiUwvwQ@fN$HO#wb< z0A9ZNa&Ld*IlNy02*jpn#`Ax95<9+TJKolcFnRg%)nv6kuLp^t?gy$NjVRPNn@X9M zh$N2!(RM;z>yCz_ThfyOzNv*BVOcWJLc4D{njiv1;7|mH;nH+5xt!x;qwL(-+lTTd zV>Y z5g-CYfCvzQBS=7)0AG&-JU)TRy=)sv>$ ztaY{#DvxoMHxj-B(y$d9tEA1gEOx``c+oiK7=R(7WR`biJRd~#5j+KkWFS$tKAOYNqpmqZQfDAmJC8R-Lrzxl)?kU%$JbQzqevc z-f|*lG?gcr9YuaPtLr#px9XaqTs`z1&l4Cb$z6+Wd7Tw@Dy6k@t+cXOTUaeEUAw-^ z=H~~7?Xt;OxotLR$8sABp)HDG%Vpdc8qmV zinjDL6 floodgate-$GATE_API_BRANCH.$BUILD_OS.$BUILD_ARCH.sha1sum + diff --git a/.travisci/floodgate-config.yaml b/.travisci/floodgate-config.yaml new file mode 100644 index 0000000..20345b5 --- /dev/null +++ b/.travisci/floodgate-config.yaml @@ -0,0 +1,13 @@ +endpoint: http://spinnaker/api/v1 +auth: + basic: + enabled: true + user: admin + password: GATE_PASS +libraries: + - /floodgate/libs/sponnet +resources: + - /floodgate/resources/examples/resources/applications + - /floodgate/resources/examples/resources/pipelines + - /floodgate/resources/examples/resources/pipelinetemplates + diff --git a/.travisci/gate-local.yml b/.travisci/gate-local.yml new file mode 100644 index 0000000..86be246 --- /dev/null +++ b/.travisci/gate-local.yml @@ -0,0 +1,15 @@ +server: + servlet: + context-path: /api/v1 + tomcat: + protocolHeader: X-Forwarded-Proto + remoteIpHeader: X-Forwarded-For + internalProxies: .* + httpsServerPort: X-Forwarded-Port + +security: + basicform: + enabled: true + user: + name: admin + password: GATE_PASS diff --git a/.travisci/generate_swagger.sh b/.travisci/generate_swagger.sh new file mode 100644 index 0000000..0c2c831 --- /dev/null +++ b/.travisci/generate_swagger.sh @@ -0,0 +1,30 @@ +#!/bin/bash -e + +GATE_API_BRANCH=$1 + +echo "Prepare extra directories" +sudo mkdir /floodgate +sudo chmod 777 /floodgate +mkdir /floodgate/bin + +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 + + diff --git a/.travisci/ingress-mandatory.yaml b/.travisci/ingress-mandatory.yaml new file mode 100644 index 0000000..60a23c2 --- /dev/null +++ b/.travisci/ingress-mandatory.yaml @@ -0,0 +1,295 @@ +--- +# source: https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml +apiVersion: v1 +kind: Namespace +metadata: + name: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + +--- + +kind: ConfigMap +apiVersion: v1 +metadata: + name: nginx-configuration + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: tcp-services + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: udp-services + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: nginx-ingress-serviceaccount + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: nginx-ingress-clusterrole + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +rules: + - apiGroups: + - "" + resources: + - configmaps + - endpoints + - nodes + - pods + - secrets + verbs: + - list + - watch + - apiGroups: + - "" + resources: + - nodes + verbs: + - get + - apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - patch + - apiGroups: + - "extensions" + - "networking.k8s.io" + resources: + - ingresses + verbs: + - get + - list + - watch + - apiGroups: + - "extensions" + - "networking.k8s.io" + resources: + - ingresses/status + verbs: + - update + +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: Role +metadata: + name: nginx-ingress-role + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +rules: + - apiGroups: + - "" + resources: + - configmaps + - pods + - secrets + - namespaces + verbs: + - get + - apiGroups: + - "" + resources: + - configmaps + resourceNames: + # Defaults to "-" + # Here: "-" + # This has to be adapted if you change either parameter + # when launching the nginx-ingress-controller. + - "ingress-controller-leader-nginx" + verbs: + - get + - update + - apiGroups: + - "" + resources: + - configmaps + verbs: + - create + - apiGroups: + - "" + resources: + - endpoints + verbs: + - get + +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: RoleBinding +metadata: + name: nginx-ingress-role-nisa-binding + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: nginx-ingress-role +subjects: + - kind: ServiceAccount + name: nginx-ingress-serviceaccount + namespace: ingress-nginx + +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: nginx-ingress-clusterrole-nisa-binding + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: nginx-ingress-clusterrole +subjects: + - kind: ServiceAccount + name: nginx-ingress-serviceaccount + namespace: ingress-nginx + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-ingress-controller + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + template: + metadata: + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + annotations: + prometheus.io/port: "10254" + prometheus.io/scrape: "true" + spec: + # wait up to five minutes for the drain of connections + terminationGracePeriodSeconds: 300 + serviceAccountName: nginx-ingress-serviceaccount + nodeSelector: + kubernetes.io/os: linux + containers: + - name: nginx-ingress-controller + image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0 + args: + - /nginx-ingress-controller + - --configmap=$(POD_NAMESPACE)/nginx-configuration + - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services + - --udp-services-configmap=$(POD_NAMESPACE)/udp-services + - --publish-service=$(POD_NAMESPACE)/ingress-nginx + - --annotations-prefix=nginx.ingress.kubernetes.io + securityContext: + allowPrivilegeEscalation: true + capabilities: + drop: + - ALL + add: + - NET_BIND_SERVICE + # www-data -> 101 + runAsUser: 101 + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + ports: + - name: http + containerPort: 80 + protocol: TCP + - name: https + containerPort: 443 + protocol: TCP + livenessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10254 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 10 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10254 + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 10 + lifecycle: + preStop: + exec: + command: + - /wait-shutdown + +--- + +apiVersion: v1 +kind: LimitRange +metadata: + name: ingress-nginx + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +spec: + limits: + - min: + memory: 90Mi + cpu: 100m + type: Container diff --git a/.travisci/ingress-service-nodeport.yaml b/.travisci/ingress-service-nodeport.yaml new file mode 100644 index 0000000..7f1e3bc --- /dev/null +++ b/.travisci/ingress-service-nodeport.yaml @@ -0,0 +1,27 @@ +--- +# source: https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml +apiVersion: v1 +kind: Service +metadata: + name: ingress-nginx + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +spec: + type: NodePort + ports: + - name: http + port: 80 + targetPort: 80 + protocol: TCP + - name: https + port: 443 + targetPort: 443 + protocol: TCP + selector: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + +--- + diff --git a/.travisci/install-and-run-spinnaker.sh b/.travisci/install-and-run-spinnaker.sh new file mode 100755 index 0000000..ec52c01 --- /dev/null +++ b/.travisci/install-and-run-spinnaker.sh @@ -0,0 +1,76 @@ +#!/bin/bash -xe + +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" +kubectl config use-context kind-kind +kubectl cluster-info + +# Configure Spinnaker installation +## Generate random password +GATE_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '') + +## Configure default provider +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" +mkdir -p ~/.hal/default/profiles +echo "spinnaker.s3.versioning: false" >> ~/.hal/default/profiles/front50-local.yml + +## Configure Spinnaker +export MINIO_ACCESS_KEY=minio +export MINIO_SECRET_KEY=minio123 +echo $MINIO_SECRET_KEY | hal -q config storage s3 edit --path-style-access=true --endpoint "http://minio-service:9000" --access-key-id $MINIO_ACCESS_KEY --secret-access-key +hal -q config storage edit --type s3 +hal -q config features edit --pipeline-templates true +export NEED_SPINNAKER_VERSION=${NEED_SPINNAKER_VERSION:-1.19} +hal -q version list +hal -q config version edit --version $(hal -q version list | grep "^ -" | awk '{ print $2 }' | grep ${NEED_SPINNAKER_VERSION}) +hal config security ui edit --override-base-url='http://spinnaker' +hal config security api edit --override-base-url='http://spinnaker/api/v1' + +### Extra parameters for Gate and Deck +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 + +# Install Spinnaker +hal -q deploy apply +until kubectl -n spinnaker wait --for=condition=Ready pod --all > /dev/null +do + kubectl -n spinnaker get pods +done + +# Install Ingress controller +kubectl apply -f "${EXEC_DIR}/ingress-mandatory.yaml" +kubectl apply -f "${EXEC_DIR}/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" + +# 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 diff --git a/.travisci/install-toolset.sh b/.travisci/install-toolset.sh new file mode 100644 index 0000000..3561ae7 --- /dev/null +++ b/.travisci/install-toolset.sh @@ -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/ diff --git a/.travisci/kind-cluster-config.yaml b/.travisci/kind-cluster-config.yaml new file mode 100644 index 0000000..cadf6dd --- /dev/null +++ b/.travisci/kind-cluster-config.yaml @@ -0,0 +1,21 @@ +--- +# source: https://kind.sigs.k8s.io/docs/user/ingress/ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + authorization-mode: "AlwaysAllow" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP + diff --git a/.travisci/minio-standalone.yaml b/.travisci/minio-standalone.yaml new file mode 100644 index 0000000..d8ad30d --- /dev/null +++ b/.travisci/minio-standalone.yaml @@ -0,0 +1,98 @@ +--- +# source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-pvc.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + # This name uniquely identifies the PVC. This is used in deployment. + name: minio-pv-claim +spec: + # Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes + accessModes: + # The volume is mounted as read-write by a single node + - ReadWriteOnce + resources: + # This is the request for storage. Should be available in the cluster. + requests: + storage: 10Gi +--- +# source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-service.yaml +apiVersion: v1 +kind: Service +metadata: + # This name uniquely identifies the service + name: minio-service +spec: + type: LoadBalancer + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + # Looks for labels `app:minio` in the namespace and applies the spec + app: minio +--- +# source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + # This name uniquely identifies the Deployment + name: minio +spec: + selector: + matchLabels: + app: minio # has to match .spec.template.metadata.labels + strategy: + # Specifies the strategy used to replace old Pods by new ones + # Refer: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy + type: Recreate + template: + metadata: + labels: + # This label is used as a selector in Service definition + app: minio + spec: + # Volumes used by this deployment + volumes: + - name: data + # This volume is based on PVC + persistentVolumeClaim: + # Name of the PVC created earlier + claimName: minio-pv-claim + containers: + - name: minio + # Volume mounts for this container + volumeMounts: + # Volume 'data' is mounted to path '/data' + - name: data + mountPath: "/data" + # Pulls the lastest Minio image from Docker Hub + image: minio/minio:RELEASE.2020-04-15T19-42-18Z + args: + - server + - /data + env: + # MinIO access key and secret key + - name: MINIO_ACCESS_KEY + value: "minio" + - name: MINIO_SECRET_KEY + value: "minio123" + ports: + - containerPort: 9000 + # Readiness probe detects situations when MinIO server instance + # is not ready to accept traffic. Kubernetes doesn't forward + # traffic to the pod while readiness checks fail. + readinessProbe: + httpGet: + path: /minio/health/ready + port: 9000 + initialDelaySeconds: 120 + periodSeconds: 20 + # Liveness probe detects situations where MinIO server instance + # is not working properly and needs restart. Kubernetes automatically + # restarts the pods if liveness checks fail. + livenessProbe: + httpGet: + path: /minio/health/live + port: 9000 + initialDelaySeconds: 120 + periodSeconds: 20 diff --git a/.travisci/spinnaker-ingress.yaml b/.travisci/spinnaker-ingress.yaml new file mode 100644 index 0000000..2edd69a --- /dev/null +++ b/.travisci/spinnaker-ingress.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + labels: + app: spin + name: spin-ingress + namespace: spinnaker +spec: + rules: + - http: + paths: + - backend: + serviceName: spin-deck + servicePort: 9000 + path: / + - backend: + serviceName: spin-gate + servicePort: 8084 + path: /api/v1 + diff --git a/.travisci/start_spinnaker.sh b/.travisci/start_spinnaker.sh new file mode 100644 index 0000000..be31c91 --- /dev/null +++ b/.travisci/start_spinnaker.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +GATE_API_BRANCH=$1 +FLOODGATE_EXTRA_PARAMS="" + +echo "Update submodules - sponnet" +git submodule init && git submodule update + +echo "Prepare directories" +sudo mkdir /floodgate +sudo chmod 777 /floodgate +mkdir -p /floodgate/bin +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 + +.travisci/install_toolset.sh + +echo "Update /etc/hosts" +sudo bash -c 'echo "127.1.2.3 spinnaker" >> /etc/hosts' + +.travisci/wait_for_dpkg.sh + +echo Install Spinnaker and configure Floodgate +export NEED_SPINNAKER_VERSION=$( echo $GATE_API_BRANCH | egrep -o "[0-9]\.[0-9]+" ) +.travisci/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 + +echo Test Floodgate against running Spinnaker instance +/floodgate/bin/floodgate --version +/floodgate/bin/floodgate version +/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare && exit 1 || echo "Found changes" +/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml sync +/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare + diff --git a/.travisci/trigger-pipelines.sh b/.travisci/trigger-pipelines.sh new file mode 100755 index 0000000..d7686ea --- /dev/null +++ b/.travisci/trigger-pipelines.sh @@ -0,0 +1,53 @@ +#!/bin/bash -e +for PIPELINE in $@ ; do + + PASS=`cat ~/.hal/default/profiles/gate-local.yml | grep password` + PASS=${PASS#*:\ } + USER=`cat ~/.hal/default/profiles/gate-local.yml | grep name` + USER=${USER#*:\ } + ALL_APPS=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications" | jq -r .[].name` + MAX_ATTEMPTS=20 + + echo "Triggering pipeline with source $PIPELINE" + EVENT_ID=`curl -s -X POST -H "content-type: application/json" -d "{ }" http://spinnaker/api/v1/webhooks/webhook/$PIPELINE | jq -r .eventId` + echo "eventId: $EVENT_ID" + + for APP in $ALL_APPS ; do + PIPELINE_NAME=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications/$APP/executions/search?triggerTypes=webhook&eventId=$EVENT_ID" | jq -r .[].name` + ATTEMPTS=0 + + while [[ $PIPELINE_NAME != "" ]] && [ $ATTEMPTS -lt $MAX_ATTEMPTS ] ; do + echo "Checking pipeline $PIPELINE_NAME status" + STATUS=`curl -s -X GET --user "$USER:$PASS" "http://spinnaker/api/v1/applications/$APP/executions/search?triggerTypes=webhook&eventId=$EVENT_ID" | jq -r .[].status` + + case $STATUS in + + "NOT_STARTED") + echo "Waiting for pipeline $PIPELINE_NAME to start" + sleep 3 + ;; + + "RUNNING") + echo "Waiting for pipeline $PIPELINE_NAME to finish" + sleep 3 + ;; + + "SUCCEEDED") + echo "$Pipeline PIPELINE_NAME succeded" + break + ;; + + *) + echo "Pipeline $PIPELINE_NAME exited with status $STATUS" + exit 1 + ;; + esac + ((++ATTEMPTS)) + done + + if [ $ATTEMPTS -ge $MAX_ATTEMPTS ] ; then + echo "Check timed out" + exit 1 + fi + done +done diff --git a/.travisci/wait_for_dpkkg.sh b/.travisci/wait_for_dpkkg.sh new file mode 100644 index 0000000..9df9407 --- /dev/null +++ b/.travisci/wait_for_dpkkg.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +sleep 10 +while systemctl status apt-daily >/dev/null || systemctl status apt-daily-upgrade >/dev/null || sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock; do +echo "waiting 30s for dpkg locks..." +sleep 30 +done From 12e305bffd3fbd8aef368e1203a87b9fda260b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 16 Jun 2020 11:09:04 +0200 Subject: [PATCH 02/18] fixed volume path --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b57f947..339e9b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,11 @@ services: before_script: - docker pull openjdk:11.0.3-stretch - - docker run -w /workspace -v .:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch + - docker run -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch script: - docker pull golang:1.14.1-stretch - - docker run -w /workspace -v .:/workspace --entrypoint /workspace/.travisci/build.sh --rm golang:1.14.1-stretch + - docker run -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/build.sh --rm golang:1.14.1-stretch after_success: - .travisci/start_spinnaker.sh From 03b7c2309348ffdfa2c4f0928d54fe1da460a699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 16 Jun 2020 11:13:09 +0200 Subject: [PATCH 03/18] +x permission on scripts --- .travisci/build.sh | 0 .travisci/generate_swagger.sh | 0 .travisci/start_spinnaker.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .travisci/build.sh mode change 100644 => 100755 .travisci/generate_swagger.sh mode change 100644 => 100755 .travisci/start_spinnaker.sh diff --git a/.travisci/build.sh b/.travisci/build.sh old mode 100644 new mode 100755 diff --git a/.travisci/generate_swagger.sh b/.travisci/generate_swagger.sh old mode 100644 new mode 100755 diff --git a/.travisci/start_spinnaker.sh b/.travisci/start_spinnaker.sh old mode 100644 new mode 100755 From e1370d6e69cc4f7c0d99e5764592f896f02f8059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 16 Jun 2020 15:22:15 +0200 Subject: [PATCH 04/18] execute docker as root --- .travis.yml | 5 +++-- .travisci/.generate_swagger.sh.swp | Bin 12288 -> 0 bytes .travisci/build.sh | 4 ++-- .travisci/generate_swagger.sh | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .travisci/.generate_swagger.sh.swp diff --git a/.travis.yml b/.travis.yml index 339e9b4..aae780e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,12 @@ services: before_script: - docker pull openjdk:11.0.3-stretch - - docker run -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch + - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch script: - docker pull golang:1.14.1-stretch - - docker run -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/build.sh --rm golang:1.14.1-stretch + - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/build.sh --rm golang:1.14.1-stretch + - sudo chown $SUDO_USER:$SUDO_USER -R . after_success: - .travisci/start_spinnaker.sh diff --git a/.travisci/.generate_swagger.sh.swp b/.travisci/.generate_swagger.sh.swp deleted file mode 100644 index 7b8cf082f5bc806c681f5b84fa1f0b450c8b3b42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&ui2`6vtmZs#Vc@owf_r!X({_R0}O^Wm&7(mTs-};xd~|lWaGckYslYwf;T` z{sA5YJ$drzQScwJ_UcK{e?WZ6CUwcWN^e$P;LCI;@6CJfGcyZiUwvwQ@fN$HO#wb< z0A9ZNa&Ld*IlNy02*jpn#`Ax95<9+TJKolcFnRg%)nv6kuLp^t?gy$NjVRPNn@X9M zh$N2!(RM;z>yCz_ThfyOzNv*BVOcWJLc4D{njiv1;7|mH;nH+5xt!x;qwL(-+lTTd zV>Y z5g-CYfCvzQBS=7)0AG&-JU)TRy=)sv>$ ztaY{#DvxoMHxj-B(y$d9tEA1gEOx``c+oiK7=R(7WR`biJRd~#5j+KkWFS$tKAOYNqpmqZQfDAmJC8R-Lrzxl)?kU%$JbQzqevc z-f|*lG?gcr9YuaPtLr#px9XaqTs`z1&l4Cb$z6+Wd7Tw@Dy6k@t+cXOTUaeEUAw-^ z=H~~7?Xt;OxotLR$8sABp)HDG%Vpdc8qmV zinjDL6 Date: Tue, 16 Jun 2020 15:57:54 +0200 Subject: [PATCH 05/18] Parametrize build (different workflow for cron and releases) --- .circleci/.config.yml.swp | Bin 0 -> 16384 bytes .travis.yml | 9 ++++---- .travisci/build.sh | 21 ++++++++++++++---- .travisci/generate_swagger.sh | 2 +- ...{install-toolset.sh => install_toolset.sh} | 0 .travisci/start_spinnaker.sh | 2 +- .../{wait_for_dpkkg.sh => wait_for_dpkg.sh} | 0 7 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 .circleci/.config.yml.swp rename .travisci/{install-toolset.sh => install_toolset.sh} (100%) mode change 100644 => 100755 rename .travisci/{wait_for_dpkkg.sh => wait_for_dpkg.sh} (100%) mode change 100644 => 100755 diff --git a/.circleci/.config.yml.swp b/.circleci/.config.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..0b1a019386d74ddfd4accfb683b24917a8521b46 GIT binary patch literal 16384 zcmeI3UyR&F9mfr{(3ZAA=>tJXXt;*_yV$p6}?eeG} z_}12FH~G(Gqyw}9T7eb??lO)ocU0%Rcj3L{p1qH>#L+=o0j+>mKr5gX&qfi%9w_%sUl=AwXZaeq_e{;%R%FT%aX^M4l4X%YVY#`Cune=ipIeMJUkK1Hy; zX$7mKr8THP=I0~zYlg_k_&O1|Cj6kKkqS&>)?0b zdGH+gA{c`;@b|k7VI7F+}$1{Qc1*to+mRsaEez}?_B@R!?>4*URo9$Wze^ua1P2yO+h z+-4XrfbW3MfiYMH&%Dhre)U$vxC+h#0`38Sz11+D1Q)=A-~@Ol_{S}V@onIPPl68k zIyO3<0vq5H;3T*g+yQ=qO_t}tH^8&tDhR=2U=1vR_ki2Mb=1eJK-SBPvTo*FL|rBc zM$~5xsXn0ac}OGQ=~$intd1cgdE6bc#8JQ1->grwFm(tWc_;3xg43-Sc0`&4kzWM% zvLN)jG;s$lsly=3HgBAoi!$x%szZ)=dFH12`eV!z5%5SEiD^PdEJcVz5TLSlP!-kX zF_8ulO_9JMD!G_Y-)D)nAqpFL+?b{VhirdjV#~;O5n26Vwxl#sbe=GjHVyg|U#XOC z=SEGHC5;24atJ^2&^B{2mULvwOu{*2-}cOqv80t)3L(;N%DWSu3`I;`R?pw%qY;ff zhiuR>CFTZAYF6xC5S7Id9=Swh9d_fGoFdlTD#{Jxc|yIA zO)6VXil#wKQ{DtQQaZMtH;*HDGNPNN6c#d*<-)-$bXh&otV!HE^TQZ95?%Nl0 z2b>(7m*Ai*)f``xu_;>4(?Poc-A4wrJ*TG}-&|;+bdve>^7hot;v)A<75#A1XUH8lY`8YRE3MJ6y9- zwfourv(C~iZfaH}ZF#MXhF;KoAJ#HLJIp-1ng%28k(HH|TBn$e)wETMv4g`8p>5HG z5w?l%840|>SB^Xhm}qm_ge%M)@+?(PMat0GtBB3voX0HM@PvOeL8Nf{+ohg;I~)G{l%o(@YQ=r=~}PaEqL>JvO$ZEDXt|OFKj~ zvsexTteHSobw3jf4Ps0a`(haM?2FQ&qsYS!G02L`M_r04uw{Up+XQ1KF5A-I_hYU! z3!As6n%6}qz>D0nhglEpGbDB<5?O2-&c3?y-mCX7HTNIN0wWW;6mK5Yx zF&TwbmO4h^!PINQME`np$vpY^;$znI{g9csdC1`h>`FKug$tu#~ykpsoAvH>cO8dD{QJW3YIlpSk%$=X~vS`X=*oC&!f zA>?sb6ImSdBxRmiP14G|u#`EVrq{(nr>vu55#&_f=6NdD2$@-kHN8c=5OY0|POYMl zSL@=6h5`DWth~Ythb&`dDA)hL#+vwRSU=14|6;Mud;x3xZ-J-46_9~*;7)KI>-k@R zm%+2(X>bNO;N9S7SkqqvUk1+r7n}uqz~8XO|0TEr67V2c0e{50{trN||9=Bs0$&1G z!5H+w1K})rJV>;0xx3`YuGi^{MuZs}y8{y;dT(h~=uin#dO!%CiBS3v{dS zawQ`@QKtaqUU;#sf(?!OK|!0dxfkk~!%$YR3@Q#i@;~Ljd8BgFrrZ*%S;qlHk@fbD zj!c;E>g0>Z082PS29{Tmk=m+IYi2@yDp!4KM_ukJk0_3THd}U-jnYPY4ahT(az7fI zP;F};X&^UW7x6!+lim8Kj+@#Rf3m`EqCR(i;(decp}kom8Oon`+w=dxu` literal 0 HcmV?d00001 diff --git a/.travis.yml b/.travis.yml index aae780e..cf6e3f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,19 +2,20 @@ dist: xenial language: go go: - 1.14.1 - +env: + - REALESE_BRANCHES="release-v[0-9]+\.[0-9]+\.x" RELEASE_TAGS="v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" BUILD_OS="(linux $([ $TRAVIS_EVENT_TYPE == cron ] || [[ $TRAVIS_BRANCH =~ $RELEASE_BRANCHES ]] || [[ $TRAVIS_TAG =~ $RELEASE_TAGS ]] && echo darwin))" BUILD_ARCH=amd64 GATE_API_BRANCH=release-1.20.x services: - docker before_script: - docker pull openjdk:11.0.3-stretch - - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch + - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch release-1.20.x script: - docker pull golang:1.14.1-stretch - - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/build.sh --rm golang:1.14.1-stretch + - env; for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate --entrypoint /go/src/github.com/codilime/floodgate/.travisci/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -1 $a; sudo mv floodgate floodgate-$g.$o.$a ; done; done - sudo chown $SUDO_USER:$SUDO_USER -R . after_success: - - .travisci/start_spinnaker.sh + - .travisci/start_spinnaker.sh $GATE_API_BRANCH diff --git a/.travisci/build.sh b/.travisci/build.sh index 9dd3a9a..383ec8e 100755 --- a/.travisci/build.sh +++ b/.travisci/build.sh @@ -1,11 +1,23 @@ -#!/bin/bash +#!/bin/bash -ex -GATE_VERSION=$1 +GATE_VERSION=release-1.20.x BUILD_OS=linux BUILD_ARCH=amd64 -echo "Remove gateapi dir" -rm -r gateapi + +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 echo "Get dependencies" go mod download @@ -60,6 +72,7 @@ done echo "Copy binaries for later use" mkdir -p /floodgate/bin chmod 777 /floodgate/bin +ls cp /go/src/github.com/codilime/floodgate/floodgate /floodgate/bin/floodgate echo "Generate checksum" diff --git a/.travisci/generate_swagger.sh b/.travisci/generate_swagger.sh index 2887b07..7e6c81c 100755 --- a/.travisci/generate_swagger.sh +++ b/.travisci/generate_swagger.sh @@ -16,7 +16,7 @@ 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 +git clone https://github.com/spinnaker/gate.git -b ${GATE_API_BRANCH} /floodgate/gate echo "Generate swagger.json" cd /floodgate/gate diff --git a/.travisci/install-toolset.sh b/.travisci/install_toolset.sh old mode 100644 new mode 100755 similarity index 100% rename from .travisci/install-toolset.sh rename to .travisci/install_toolset.sh diff --git a/.travisci/start_spinnaker.sh b/.travisci/start_spinnaker.sh index be31c91..9ca1dc3 100755 --- a/.travisci/start_spinnaker.sh +++ b/.travisci/start_spinnaker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e GATE_API_BRANCH=$1 FLOODGATE_EXTRA_PARAMS="" diff --git a/.travisci/wait_for_dpkkg.sh b/.travisci/wait_for_dpkg.sh old mode 100644 new mode 100755 similarity index 100% rename from .travisci/wait_for_dpkkg.sh rename to .travisci/wait_for_dpkg.sh From 170cfe66e4b623d8399895b545ab75b173fc994f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Thu, 18 Jun 2020 10:33:26 +0200 Subject: [PATCH 06/18] Add proper bash parameters --- .travisci/build.sh | 2 +- .travisci/install-and-run-spinnaker.sh | 2 +- .travisci/wait_for_dpkg.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travisci/build.sh b/.travisci/build.sh index 383ec8e..68b6971 100755 --- a/.travisci/build.sh +++ b/.travisci/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash -ex +#!/bin/bash -e GATE_VERSION=release-1.20.x BUILD_OS=linux diff --git a/.travisci/install-and-run-spinnaker.sh b/.travisci/install-and-run-spinnaker.sh index ec52c01..65da2ad 100755 --- a/.travisci/install-and-run-spinnaker.sh +++ b/.travisci/install-and-run-spinnaker.sh @@ -1,4 +1,4 @@ -#!/bin/bash -xe +#!/bin/bash -e EXEC_DIR=$(dirname "$0") HAL_VERSION=${HAL_VERSION:-1.35.0} diff --git a/.travisci/wait_for_dpkg.sh b/.travisci/wait_for_dpkg.sh index 9df9407..6e77cb4 100755 --- a/.travisci/wait_for_dpkg.sh +++ b/.travisci/wait_for_dpkg.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e sleep 10 while systemctl status apt-daily >/dev/null || systemctl status apt-daily-upgrade >/dev/null || sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock; do From 0fb87e6e694042e52ff6c0090f4f1b4df7a0b344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Thu, 18 Jun 2020 10:45:54 +0200 Subject: [PATCH 07/18] rm swp file --- .circleci/.config.yml.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .circleci/.config.yml.swp diff --git a/.circleci/.config.yml.swp b/.circleci/.config.yml.swp deleted file mode 100644 index 0b1a019386d74ddfd4accfb683b24917a8521b46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3UyR&F9mfr{(3ZAA=>tJXXt;*_yV$p6}?eeG} z_}12FH~G(Gqyw}9T7eb??lO)ocU0%Rcj3L{p1qH>#L+=o0j+>mKr5gX&qfi%9w_%sUl=AwXZaeq_e{;%R%FT%aX^M4l4X%YVY#`Cune=ipIeMJUkK1Hy; zX$7mKr8THP=I0~zYlg_k_&O1|Cj6kKkqS&>)?0b zdGH+gA{c`;@b|k7VI7F+}$1{Qc1*to+mRsaEez}?_B@R!?>4*URo9$Wze^ua1P2yO+h z+-4XrfbW3MfiYMH&%Dhre)U$vxC+h#0`38Sz11+D1Q)=A-~@Ol_{S}V@onIPPl68k zIyO3<0vq5H;3T*g+yQ=qO_t}tH^8&tDhR=2U=1vR_ki2Mb=1eJK-SBPvTo*FL|rBc zM$~5xsXn0ac}OGQ=~$intd1cgdE6bc#8JQ1->grwFm(tWc_;3xg43-Sc0`&4kzWM% zvLN)jG;s$lsly=3HgBAoi!$x%szZ)=dFH12`eV!z5%5SEiD^PdEJcVz5TLSlP!-kX zF_8ulO_9JMD!G_Y-)D)nAqpFL+?b{VhirdjV#~;O5n26Vwxl#sbe=GjHVyg|U#XOC z=SEGHC5;24atJ^2&^B{2mULvwOu{*2-}cOqv80t)3L(;N%DWSu3`I;`R?pw%qY;ff zhiuR>CFTZAYF6xC5S7Id9=Swh9d_fGoFdlTD#{Jxc|yIA zO)6VXil#wKQ{DtQQaZMtH;*HDGNPNN6c#d*<-)-$bXh&otV!HE^TQZ95?%Nl0 z2b>(7m*Ai*)f``xu_;>4(?Poc-A4wrJ*TG}-&|;+bdve>^7hot;v)A<75#A1XUH8lY`8YRE3MJ6y9- zwfourv(C~iZfaH}ZF#MXhF;KoAJ#HLJIp-1ng%28k(HH|TBn$e)wETMv4g`8p>5HG z5w?l%840|>SB^Xhm}qm_ge%M)@+?(PMat0GtBB3voX0HM@PvOeL8Nf{+ohg;I~)G{l%o(@YQ=r=~}PaEqL>JvO$ZEDXt|OFKj~ zvsexTteHSobw3jf4Ps0a`(haM?2FQ&qsYS!G02L`M_r04uw{Up+XQ1KF5A-I_hYU! z3!As6n%6}qz>D0nhglEpGbDB<5?O2-&c3?y-mCX7HTNIN0wWW;6mK5Yx zF&TwbmO4h^!PINQME`np$vpY^;$znI{g9csdC1`h>`FKug$tu#~ykpsoAvH>cO8dD{QJW3YIlpSk%$=X~vS`X=*oC&!f zA>?sb6ImSdBxRmiP14G|u#`EVrq{(nr>vu55#&_f=6NdD2$@-kHN8c=5OY0|POYMl zSL@=6h5`DWth~Ythb&`dDA)hL#+vwRSU=14|6;Mud;x3xZ-J-46_9~*;7)KI>-k@R zm%+2(X>bNO;N9S7SkqqvUk1+r7n}uqz~8XO|0TEr67V2c0e{50{trN||9=Bs0$&1G z!5H+w1K})rJV>;0xx3`YuGi^{MuZs}y8{y;dT(h~=uin#dO!%CiBS3v{dS zawQ`@QKtaqUU;#sf(?!OK|!0dxfkk~!%$YR3@Q#i@;~Ljd8BgFrrZ*%S;qlHk@fbD zj!c;E>g0>Z082PS29{Tmk=m+IYi2@yDp!4KM_ukJk0_3THd}U-jnYPY4ahT(az7fI zP;F};X&^UW7x6!+lim8Kj+@#Rf3m`EqCR(i;(decp}kom8Oon`+w=dxu` From 7b88bff4ba27fb8326017eebcb82028116ca0497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Mon, 22 Jun 2020 09:48:15 +0200 Subject: [PATCH 08/18] Unified circleci and travis scripts --- .cilibs/build.sh | 40 +++ .cilibs/calculate_code_coverage.sh | 29 ++ .cilibs/check_linting.sh | 8 + .cilibs/compile_code.sh | 36 +++ .cilibs/copy_binaries_for_later_use.sh | 7 + .cilibs/examine_source_code_with_go_get.sh | 4 + .cilibs/execute_go_tests.sh | 4 + .../libs => .cilibs}/floodgate-config.yaml | 0 {.circleci/libs => .cilibs}/gate-local.yml | 0 .cilibs/generate_checksum.sh | 26 ++ .cilibs/generate_gateapi_go_code.sh | 6 + .cilibs/generate_swagger.sh | 14 + .cilibs/generate_swagger_json.sh | 7 + .cilibs/get_dependencies.sh | 5 + .cilibs/get_gate_code.sh | 7 + .../libs => .cilibs}/ingress-mandatory.yaml | 0 .../ingress-service-nodeport.yaml | 0 .../install-and-run-spinnaker.sh | 0 ...stall_spinnaker_and_configure_floodgate.sh | 13 + {.travisci => .cilibs}/install_toolset.sh | 0 .../libs => .cilibs}/kind-cluster-config.yaml | 0 .../libs => .cilibs}/minio-standalone.yaml | 0 .cilibs/prepare_directories.sh | 16 + .cilibs/prepare_extra_directories.sh | 6 + .../setup_swagger_codegen.sh | 21 -- .../libs => .cilibs}/spinnaker-ingress.yaml | 0 .cilibs/start_spinnaker.sh | 31 ++ ...gate_against_running_spinnaker_instance.sh | 11 + {.travisci => .cilibs}/trigger-pipelines.sh | 0 .cilibs/update_hosts.sh | 5 + {.travisci => .cilibs}/wait_for_dpkg.sh | 0 .circleci/config.yml | 135 ++------ .circleci/libs/install-and-run-spinnaker.sh | 68 ---- .travis.yml | 8 +- .travisci/build.sh | 82 ----- .travisci/floodgate-config.yaml | 13 - .travisci/gate-local.yml | 15 - .travisci/ingress-mandatory.yaml | 295 ------------------ .travisci/ingress-service-nodeport.yaml | 27 -- .travisci/kind-cluster-config.yaml | 21 -- .travisci/minio-standalone.yaml | 98 ------ .travisci/spinnaker-ingress.yaml | 21 -- .travisci/start_spinnaker.sh | 42 --- 43 files changed, 298 insertions(+), 823 deletions(-) create mode 100755 .cilibs/build.sh create mode 100755 .cilibs/calculate_code_coverage.sh create mode 100755 .cilibs/check_linting.sh create mode 100755 .cilibs/compile_code.sh create mode 100755 .cilibs/copy_binaries_for_later_use.sh create mode 100755 .cilibs/examine_source_code_with_go_get.sh create mode 100755 .cilibs/execute_go_tests.sh rename {.circleci/libs => .cilibs}/floodgate-config.yaml (100%) rename {.circleci/libs => .cilibs}/gate-local.yml (100%) create mode 100755 .cilibs/generate_checksum.sh create mode 100755 .cilibs/generate_gateapi_go_code.sh create mode 100755 .cilibs/generate_swagger.sh create mode 100755 .cilibs/generate_swagger_json.sh create mode 100755 .cilibs/get_dependencies.sh create mode 100755 .cilibs/get_gate_code.sh rename {.circleci/libs => .cilibs}/ingress-mandatory.yaml (100%) rename {.circleci/libs => .cilibs}/ingress-service-nodeport.yaml (100%) rename {.travisci => .cilibs}/install-and-run-spinnaker.sh (100%) create mode 100755 .cilibs/install_spinnaker_and_configure_floodgate.sh rename {.travisci => .cilibs}/install_toolset.sh (100%) rename {.circleci/libs => .cilibs}/kind-cluster-config.yaml (100%) rename {.circleci/libs => .cilibs}/minio-standalone.yaml (100%) create mode 100755 .cilibs/prepare_directories.sh create mode 100755 .cilibs/prepare_extra_directories.sh rename .travisci/generate_swagger.sh => .cilibs/setup_swagger_codegen.sh (50%) rename {.circleci/libs => .cilibs}/spinnaker-ingress.yaml (100%) create mode 100755 .cilibs/start_spinnaker.sh create mode 100755 .cilibs/test_floodgate_against_running_spinnaker_instance.sh rename {.travisci => .cilibs}/trigger-pipelines.sh (100%) create mode 100755 .cilibs/update_hosts.sh rename {.travisci => .cilibs}/wait_for_dpkg.sh (100%) delete mode 100755 .circleci/libs/install-and-run-spinnaker.sh delete mode 100755 .travisci/build.sh delete mode 100644 .travisci/floodgate-config.yaml delete mode 100644 .travisci/gate-local.yml delete mode 100644 .travisci/ingress-mandatory.yaml delete mode 100644 .travisci/ingress-service-nodeport.yaml delete mode 100644 .travisci/kind-cluster-config.yaml delete mode 100644 .travisci/minio-standalone.yaml delete mode 100644 .travisci/spinnaker-ingress.yaml delete mode 100755 .travisci/start_spinnaker.sh diff --git a/.cilibs/build.sh b/.cilibs/build.sh new file mode 100755 index 0000000..46a2085 --- /dev/null +++ b/.cilibs/build.sh @@ -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} + diff --git a/.cilibs/calculate_code_coverage.sh b/.cilibs/calculate_code_coverage.sh new file mode 100755 index 0000000..08a88dc --- /dev/null +++ b/.cilibs/calculate_code_coverage.sh @@ -0,0 +1,29 @@ +#!/bin/bash -e + +SEND_COVERITY=$1 + +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\":\"${CIRCLE_SHA1}\"}" \ + 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 diff --git a/.cilibs/check_linting.sh b/.cilibs/check_linting.sh new file mode 100755 index 0000000..c20fbbc --- /dev/null +++ b/.cilibs/check_linting.sh @@ -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 + diff --git a/.cilibs/compile_code.sh b/.cilibs/compile_code.sh new file mode 100755 index 0000000..09f01e3 --- /dev/null +++ b/.cilibs/compile_code.sh @@ -0,0 +1,36 @@ +#!/bin/bash -e + +GATE_VERSION=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_VERSION=${OPTARG} + ;; + esac +done + +echo "Compile code" +if [ -z "$TRAVIS_BRANCH" ] +then + export RELEASE=$(echo $CIRCLE_TAG | sed 's/^v[0-9]\+\.[0-9]\+\.[0-9]\+-\?//') +else + export RELEASE=$CIRCLE_BRANCH +fi +env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} go build -ldflags \ +"-X github.com/codilime/floodgate/version.GitCommit=$TRAVIS_COMMIT \ +-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-//') \ +" + diff --git a/.cilibs/copy_binaries_for_later_use.sh b/.cilibs/copy_binaries_for_later_use.sh new file mode 100755 index 0000000..8e6f02f --- /dev/null +++ b/.cilibs/copy_binaries_for_later_use.sh @@ -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 + diff --git a/.cilibs/examine_source_code_with_go_get.sh b/.cilibs/examine_source_code_with_go_get.sh new file mode 100755 index 0000000..a0456e2 --- /dev/null +++ b/.cilibs/examine_source_code_with_go_get.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e + +echo "Examine source code with go vet" +go vet -v ./... diff --git a/.cilibs/execute_go_tests.sh b/.cilibs/execute_go_tests.sh new file mode 100755 index 0000000..831f3ae --- /dev/null +++ b/.cilibs/execute_go_tests.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e + +echo "Execute go tests" +go test -v ./... -coverprofile cover.out diff --git a/.circleci/libs/floodgate-config.yaml b/.cilibs/floodgate-config.yaml similarity index 100% rename from .circleci/libs/floodgate-config.yaml rename to .cilibs/floodgate-config.yaml diff --git a/.circleci/libs/gate-local.yml b/.cilibs/gate-local.yml similarity index 100% rename from .circleci/libs/gate-local.yml rename to .cilibs/gate-local.yml diff --git a/.cilibs/generate_checksum.sh b/.cilibs/generate_checksum.sh new file mode 100755 index 0000000..32a4153 --- /dev/null +++ b/.cilibs/generate_checksum.sh @@ -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 + diff --git a/.cilibs/generate_gateapi_go_code.sh b/.cilibs/generate_gateapi_go_code.sh new file mode 100755 index 0000000..8b84535 --- /dev/null +++ b/.cilibs/generate_gateapi_go_code.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e + +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 + + diff --git a/.cilibs/generate_swagger.sh b/.cilibs/generate_swagger.sh new file mode 100755 index 0000000..dd794a4 --- /dev/null +++ b/.cilibs/generate_swagger.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +GATE_API_BRANCH=$1 + +.cilibs/prepare_extra_directories.sh + +.cilibs/setup_swagger_codegen.sh + +.cilibs/get_gate_code.sh $GATE_API_BRANCH + +.cilibs/generate_swagger_json.sh + +.cilibs/generate_gateapi_go_code.sh + diff --git a/.cilibs/generate_swagger_json.sh b/.cilibs/generate_swagger_json.sh new file mode 100755 index 0000000..c911245 --- /dev/null +++ b/.cilibs/generate_swagger_json.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +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 diff --git a/.cilibs/get_dependencies.sh b/.cilibs/get_dependencies.sh new file mode 100755 index 0000000..b6a6122 --- /dev/null +++ b/.cilibs/get_dependencies.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +echo "Get dependencies" +go mod download +go get -u golang.org/x/lint/golint diff --git a/.cilibs/get_gate_code.sh b/.cilibs/get_gate_code.sh new file mode 100755 index 0000000..391e32f --- /dev/null +++ b/.cilibs/get_gate_code.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +GATE_API_BRANCH=$1 + +echo "Get gate code" +git clone https://github.com/spinnaker/gate.git -b ${GATE_API_BRANCH} /floodgate/gate + diff --git a/.circleci/libs/ingress-mandatory.yaml b/.cilibs/ingress-mandatory.yaml similarity index 100% rename from .circleci/libs/ingress-mandatory.yaml rename to .cilibs/ingress-mandatory.yaml diff --git a/.circleci/libs/ingress-service-nodeport.yaml b/.cilibs/ingress-service-nodeport.yaml similarity index 100% rename from .circleci/libs/ingress-service-nodeport.yaml rename to .cilibs/ingress-service-nodeport.yaml diff --git a/.travisci/install-and-run-spinnaker.sh b/.cilibs/install-and-run-spinnaker.sh similarity index 100% rename from .travisci/install-and-run-spinnaker.sh rename to .cilibs/install-and-run-spinnaker.sh diff --git a/.cilibs/install_spinnaker_and_configure_floodgate.sh b/.cilibs/install_spinnaker_and_configure_floodgate.sh new file mode 100755 index 0000000..a253fcb --- /dev/null +++ b/.cilibs/install_spinnaker_and_configure_floodgate.sh @@ -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 + diff --git a/.travisci/install_toolset.sh b/.cilibs/install_toolset.sh similarity index 100% rename from .travisci/install_toolset.sh rename to .cilibs/install_toolset.sh diff --git a/.circleci/libs/kind-cluster-config.yaml b/.cilibs/kind-cluster-config.yaml similarity index 100% rename from .circleci/libs/kind-cluster-config.yaml rename to .cilibs/kind-cluster-config.yaml diff --git a/.circleci/libs/minio-standalone.yaml b/.cilibs/minio-standalone.yaml similarity index 100% rename from .circleci/libs/minio-standalone.yaml rename to .cilibs/minio-standalone.yaml diff --git a/.cilibs/prepare_directories.sh b/.cilibs/prepare_directories.sh new file mode 100755 index 0000000..cfd2b6e --- /dev/null +++ b/.cilibs/prepare_directories.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e + +BUILD_OS=linux +BUILD_ARCH=amd64 + +echo "Prepare directories" +sudo mkdir /floodgate +sudo chmod 777 /floodgate +mkdir -p /floodgate/bin +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 + diff --git a/.cilibs/prepare_extra_directories.sh b/.cilibs/prepare_extra_directories.sh new file mode 100755 index 0000000..780b75e --- /dev/null +++ b/.cilibs/prepare_extra_directories.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e + +echo "Prepare extra directories" +mkdir /floodgate +chmod 777 /floodgate +mkdir /floodgate/bin diff --git a/.travisci/generate_swagger.sh b/.cilibs/setup_swagger_codegen.sh similarity index 50% rename from .travisci/generate_swagger.sh rename to .cilibs/setup_swagger_codegen.sh index 7e6c81c..4a72b75 100755 --- a/.travisci/generate_swagger.sh +++ b/.cilibs/setup_swagger_codegen.sh @@ -1,12 +1,5 @@ #!/bin/bash -e -GATE_API_BRANCH=$1 - -echo "Prepare extra directories" -mkdir /floodgate -chmod 777 /floodgate -mkdir /floodgate/bin - 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 @@ -14,17 +7,3 @@ wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_VER 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 - - diff --git a/.circleci/libs/spinnaker-ingress.yaml b/.cilibs/spinnaker-ingress.yaml similarity index 100% rename from .circleci/libs/spinnaker-ingress.yaml rename to .cilibs/spinnaker-ingress.yaml diff --git a/.cilibs/start_spinnaker.sh b/.cilibs/start_spinnaker.sh new file mode 100755 index 0000000..2e2adea --- /dev/null +++ b/.cilibs/start_spinnaker.sh @@ -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 diff --git a/.cilibs/test_floodgate_against_running_spinnaker_instance.sh b/.cilibs/test_floodgate_against_running_spinnaker_instance.sh new file mode 100755 index 0000000..110fc92 --- /dev/null +++ b/.cilibs/test_floodgate_against_running_spinnaker_instance.sh @@ -0,0 +1,11 @@ +#!/bin/bash -e + +FLOODGATE_EXTRA_PARAMS=$1 + +echo Test Floodgate against running Spinnaker instance +/floodgate/bin/floodgate --version +/floodgate/bin/floodgate version +/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare && exit 1 || echo "Found changes" +/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml sync +/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare + diff --git a/.travisci/trigger-pipelines.sh b/.cilibs/trigger-pipelines.sh similarity index 100% rename from .travisci/trigger-pipelines.sh rename to .cilibs/trigger-pipelines.sh diff --git a/.cilibs/update_hosts.sh b/.cilibs/update_hosts.sh new file mode 100755 index 0000000..9cc58b2 --- /dev/null +++ b/.cilibs/update_hosts.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +echo "Update /etc/hosts" +sudo bash -c 'echo "127.1.2.3 spinnaker" >> /etc/hosts' + diff --git a/.travisci/wait_for_dpkg.sh b/.cilibs/wait_for_dpkg.sh similarity index 100% rename from .travisci/wait_for_dpkg.sh rename to .cilibs/wait_for_dpkg.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index deb6e6b..7ada5ef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,25 +24,14 @@ commands: steps: - run: name: Install tools - command: | - 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/ + command: .cilibs/install_toolset.sh wait_for_dpkg: description: "Wait for packaging operations to finish" steps: - run: name: Wait for packaging operations to finish - command: | - sleep 10 - while systemctl status apt-daily >/dev/null || systemctl status apt-daily-upgrade >/dev/null || sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock; do - echo "waiting 30s for dpkg locks..." - sleep 30 - done + command: .cilibs/wait_for_dpkg.sh jobs: generate_swagger: @@ -53,32 +42,19 @@ jobs: - checkout - run: name: Prepare extra directories - command: | - sudo mkdir /floodgate - sudo chmod 777 /floodgate - mkdir /floodgate/bin + command: sudo .cilibs/prepare_extra_directories.sh - run: name: Setup swagger-codegen - command: | - 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/ + command: sudo .cilibs/setup_swagger_codegen.sh - run: name: Get gate code - command: git clone https://github.com/spinnaker/gate.git -b << parameters.gate_api_branch >> /floodgate/gate + command: .cilibs/get_gate_code.sh << parameters.gate_api_branch >> - run: name: Generate swagger.json - command: | - cd /floodgate/gate - ./gradlew clean - ./gradlew gate-web:test --tests *GenerateSwagger* --max-workers 2 - cat gate-web/swagger.json | json_pp > ./gate-swagger.json + command: .cilibs/generate_swagger_json.sh - run: name: Generate gateapi go code - command: java -jar /floodgate/bin/swagger-codegen-cli.jar generate -l go -i /floodgate/gate/gate-swagger.json -o /floodgate/gateapi + command: .cilibs/generate_gateapi_go_code.sh - persist_to_workspace: root: /floodgate paths: @@ -117,77 +93,30 @@ jobs: at: ./ - run: name: Get dependencies - command: | - go mod download - go get -u golang.org/x/lint/golint + command: .cilibs/get_dependencies.sh - run: name: Examine source code with go vet - command: go vet -v ./... + command: .cilibs/examine_source_code_with_go_get.sh - run: name: Execute go tests - command: go test -v ./... -coverprofile cover.out + command: .cilibs/execute_go_tests.sh - run: name: Compile code - command: | - if [ -z "$CIRCLE_BRANCH" ] - then - export RELEASE=$(echo $CIRCLE_TAG | sed 's/^v[0-9]\+\.[0-9]\+\.[0-9]\+-\?//') - else - export RELEASE=$CIRCLE_BRANCH - fi - env GOOS=<< parameters.build_os >> GOARCH=<< parameters.build_arch >> go build -ldflags \ - "-X github.com/codilime/floodgate/version.GitCommit=$CIRCLE_SHA1 \ - -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 '<< parameters.gate_api_branch >>' | sed 's/release-//') \ - " + command: .cilibs/compile_code.sh -o << parameters.build_os >> -a << parameters.build_arch >> -g << parameters.gate_api_branch >> - run: name: Calculate code coverage environment: REQUIREDCODECOVERAGE: 60 - command: | - 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 [[ "<< parameters.send_coverity >>" == "send" ]] - then - curl \ - --header "Authorization: Token ${SERIESCI_TOKEN}" \ - --header "Content-Type: application/json" \ - --data "{\"value\":\"${CURRENTCODECOVERAGE} %\",\"sha\":\"${CIRCLE_SHA1}\"}" \ - 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 + command: .cilibs/calculate_code_coverage.sh << parameters.send_coverity >> - run: name: Check linting - command: | - for GOSRCFILE in $( find . -type f -name '*.go' -not -path './gateapi/*') - do - golint -set_exit_status $GOSRCFILE - done + command: .cilibs/check_linting.sh - run: name: Copy binaries for later use - command: | - sudo mkdir -p /floodgate/bin - sudo chmod 777 /floodgate/bin - cp /go/src/github.com/codilime/floodgate/floodgate /floodgate/bin/floodgate + command: sudo .cilibs/copy_binaries_for_later_use.sh - run: name: Generate checksum - command: | - cd /go/src/github.com/codilime/floodgate/ - cp floodgate floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >> - sha1sum floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >> > floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >>.sha1sum + command: .cilibs/generate_checksum.sh -o << parameters.build_os >> -a << parameters.build_arch >> -g << parameters.gate_api_branch >> - persist_to_workspace: root: /floodgate/bin paths: @@ -216,44 +145,18 @@ jobs: at: ./ - run: name: Prepare directories - command: | - sudo mkdir /floodgate - sudo chmod 777 /floodgate - mkdir -p /floodgate/bin - 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 + command: .cilibs/prepare_directories.sh - install_toolset - run: name: Update /etc/hosts - command: sudo bash -c 'echo "127.1.2.3 spinnaker" >> /etc/hosts' + command: .cilibs/update_hosts.sh - wait_for_dpkg - run: name: Install Spinnaker and configure Floodgate - command: | - export NEED_SPINNAKER_VERSION=$( echo << parameters.gate_api_branch >> | egrep -o "[0-9]\.[0-9]+" ) - .circleci/libs/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 + command: .cilibs/install_spinnaker_and_configure_floodgate.sh << parameters.gate_api_branch >> - run: name: Test Floodgate against running Spinnaker instance - command: | - echo "Print version using version flag" - /floodgate/bin/floodgate --version - echo "Print version using version command" - /floodgate/bin/floodgate version - echo "Comare changes - clean Spinnaker" - /floodgate/bin/floodgate << parameters.floodgate_extra_params >> --config ~/floodgate.yaml compare && exit 1 || echo "Found changes" - echo "Apply local resources" - /floodgate/bin/floodgate << parameters.floodgate_extra_params >> --config ~/floodgate.yaml sync - echo "Compare changes - synced resources" - /floodgate/bin/floodgate << parameters.floodgate_extra_params >> --config ~/floodgate.yaml compare + command: .cilibs/test_floodgate_against_running_spinnaker_instance.sh << parameters.floodgate_extra_params >> workflows: periodic: diff --git a/.circleci/libs/install-and-run-spinnaker.sh b/.circleci/libs/install-and-run-spinnaker.sh deleted file mode 100755 index d22373d..0000000 --- a/.circleci/libs/install-and-run-spinnaker.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -xe - -EXEC_DIR=$(dirname "$0") -HAL_VERSION=${HAL_VERSION:-1.35.0} - -# 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" -kubectl config use-context kind-kind -kubectl cluster-info - -# Configure Spinnaker installation -## Generate random password -GATE_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '') - -## Configure default provider -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 -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" -mkdir -p ~/.hal/default/profiles -echo "spinnaker.s3.versioning: false" >> ~/.hal/default/profiles/front50-local.yml - -## Configure Spinnaker -export MINIO_ACCESS_KEY=minio -export MINIO_SECRET_KEY=minio123 -echo $MINIO_SECRET_KEY | hal -q config storage s3 edit --path-style-access=true --endpoint "http://minio-service:9000" --access-key-id $MINIO_ACCESS_KEY --secret-access-key -hal -q config storage edit --type s3 -hal -q config features edit --pipeline-templates true -export NEED_SPINNAKER_VERSION=${NEED_SPINNAKER_VERSION:-1.19} -hal -q version list -hal -q config version edit --version $(hal -q version list | grep "^ -" | awk '{ print $2 }' | grep ${NEED_SPINNAKER_VERSION}) -hal config security ui edit --override-base-url='http://spinnaker' -hal config security api edit --override-base-url='http://spinnaker/api/v1' - -### Extra parameters for Gate and Deck -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 - -# Install Spinnaker -hal -q deploy apply -until kubectl -n spinnaker wait --for=condition=Ready pod --all > /dev/null -do - kubectl -n spinnaker get pods -done - -# Install Ingress controller -kubectl apply -f "${EXEC_DIR}/ingress-mandatory.yaml" -kubectl apply -f "${EXEC_DIR}/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" - -# 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 diff --git a/.travis.yml b/.travis.yml index cf6e3f0..b0fc998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,19 +3,19 @@ language: go go: - 1.14.1 env: - - REALESE_BRANCHES="release-v[0-9]+\.[0-9]+\.x" RELEASE_TAGS="v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" BUILD_OS="(linux $([ $TRAVIS_EVENT_TYPE == cron ] || [[ $TRAVIS_BRANCH =~ $RELEASE_BRANCHES ]] || [[ $TRAVIS_TAG =~ $RELEASE_TAGS ]] && echo darwin))" BUILD_ARCH=amd64 GATE_API_BRANCH=release-1.20.x + - REALESE_BRANCHES="release-v[0-9]+\.[0-9]+\.x" RELEASE_TAGS="v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" BUILD_OS="$([ $TRAVIS_EVENT_TYPE == cron ] || [[ $TRAVIS_BRANCH =~ $RELEASE_BRANCHES ]] || [[ $TRAVIS_TAG =~ $RELEASE_TAGS ]] && echo darwin) linux" BUILD_ARCH=amd64 GATE_API_BRANCH=release-1.20.x SEND_COVERITY=send services: - docker before_script: - docker pull openjdk:11.0.3-stretch - - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.travisci/generate_swagger.sh --rm openjdk:11.0.3-stretch release-1.20.x + - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.cilibs/generate_swagger.sh --rm openjdk:11.0.3-stretch release-1.20.x script: - docker pull golang:1.14.1-stretch - - env; for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate --entrypoint /go/src/github.com/codilime/floodgate/.travisci/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -1 $a; sudo mv floodgate floodgate-$g.$o.$a ; done; done + - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate -e SERIESCI_TOKEN=$SERIESCI_TOKEN --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done - sudo chown $SUDO_USER:$SUDO_USER -R . after_success: - - .travisci/start_spinnaker.sh $GATE_API_BRANCH + - .cilibs/start_spinnaker.sh -a `echo $BUILD_ARCH | cut -d" " -f1` -o `echo $BUILD_OS | cut -d" " -f1` -g $GATE_API_BRANCH -e $FLOODGATE_EXTRA_PARAMS diff --git a/.travisci/build.sh b/.travisci/build.sh deleted file mode 100755 index 68b6971..0000000 --- a/.travisci/build.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -e - -GATE_VERSION=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_VERSION=${OPTARG} - ;; - esac -done - -echo "Get dependencies" -go mod download -go get -u golang.org/x/lint/golint - -echo "Examine source code with go vet" -go vet -v ./... - -echo "Execute go tests" -go test -v ./... -coverprofile cover.out - -echo "Compile code" -if [ -z "$TRAVIS_BRANCH" ] -then - export RELEASE=$(echo $CIRCLE_TAG | sed 's/^v[0-9]\+\.[0-9]\+\.[0-9]\+-\?//') -else - export RELEASE=$CIRCLE_BRANCH -fi -env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} go build -ldflags \ -"-X github.com/codilime/floodgate/version.GitCommit=$TRAVIS_COMMIT \ --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-//') \ -" - -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)}') -curl \ - --header "Authorization: Token ${SERIESCI_TOKEN}" \ - --header "Content-Type: application/json" \ - --data "{\"value\":\"${CURRENTCODECOVERAGE} %\",\"sha\":\"${CIRCLE_SHA1}\"}" \ - https://seriesci.com/api/codilime/floodgate/coverage/one -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 - -echo "Check linting" -for GOSRCFILE in $( find . -type f -name '*.go' -not -path './gateapi/*') -do - golint -set_exit_status $GOSRCFILE -done - -echo "Copy binaries for later use" -mkdir -p /floodgate/bin -chmod 777 /floodgate/bin -ls -cp /go/src/github.com/codilime/floodgate/floodgate /floodgate/bin/floodgate - -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 - diff --git a/.travisci/floodgate-config.yaml b/.travisci/floodgate-config.yaml deleted file mode 100644 index 20345b5..0000000 --- a/.travisci/floodgate-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -endpoint: http://spinnaker/api/v1 -auth: - basic: - enabled: true - user: admin - password: GATE_PASS -libraries: - - /floodgate/libs/sponnet -resources: - - /floodgate/resources/examples/resources/applications - - /floodgate/resources/examples/resources/pipelines - - /floodgate/resources/examples/resources/pipelinetemplates - diff --git a/.travisci/gate-local.yml b/.travisci/gate-local.yml deleted file mode 100644 index 86be246..0000000 --- a/.travisci/gate-local.yml +++ /dev/null @@ -1,15 +0,0 @@ -server: - servlet: - context-path: /api/v1 - tomcat: - protocolHeader: X-Forwarded-Proto - remoteIpHeader: X-Forwarded-For - internalProxies: .* - httpsServerPort: X-Forwarded-Port - -security: - basicform: - enabled: true - user: - name: admin - password: GATE_PASS diff --git a/.travisci/ingress-mandatory.yaml b/.travisci/ingress-mandatory.yaml deleted file mode 100644 index 60a23c2..0000000 --- a/.travisci/ingress-mandatory.yaml +++ /dev/null @@ -1,295 +0,0 @@ ---- -# source: https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml -apiVersion: v1 -kind: Namespace -metadata: - name: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - ---- - -kind: ConfigMap -apiVersion: v1 -metadata: - name: nginx-configuration - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - ---- -kind: ConfigMap -apiVersion: v1 -metadata: - name: tcp-services - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - ---- -kind: ConfigMap -apiVersion: v1 -metadata: - name: udp-services - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: nginx-ingress-serviceaccount - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole -metadata: - name: nginx-ingress-clusterrole - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -rules: - - apiGroups: - - "" - resources: - - configmaps - - endpoints - - nodes - - pods - - secrets - verbs: - - list - - watch - - apiGroups: - - "" - resources: - - nodes - verbs: - - get - - apiGroups: - - "" - resources: - - services - verbs: - - get - - list - - watch - - apiGroups: - - "" - resources: - - events - verbs: - - create - - patch - - apiGroups: - - "extensions" - - "networking.k8s.io" - resources: - - ingresses - verbs: - - get - - list - - watch - - apiGroups: - - "extensions" - - "networking.k8s.io" - resources: - - ingresses/status - verbs: - - update - ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role -metadata: - name: nginx-ingress-role - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -rules: - - apiGroups: - - "" - resources: - - configmaps - - pods - - secrets - - namespaces - verbs: - - get - - apiGroups: - - "" - resources: - - configmaps - resourceNames: - # Defaults to "-" - # Here: "-" - # This has to be adapted if you change either parameter - # when launching the nginx-ingress-controller. - - "ingress-controller-leader-nginx" - verbs: - - get - - update - - apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - apiGroups: - - "" - resources: - - endpoints - verbs: - - get - ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding -metadata: - name: nginx-ingress-role-nisa-binding - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: nginx-ingress-role -subjects: - - kind: ServiceAccount - name: nginx-ingress-serviceaccount - namespace: ingress-nginx - ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: nginx-ingress-clusterrole-nisa-binding - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: nginx-ingress-clusterrole -subjects: - - kind: ServiceAccount - name: nginx-ingress-serviceaccount - namespace: ingress-nginx - ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-ingress-controller - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -spec: - replicas: 1 - selector: - matchLabels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - template: - metadata: - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - annotations: - prometheus.io/port: "10254" - prometheus.io/scrape: "true" - spec: - # wait up to five minutes for the drain of connections - terminationGracePeriodSeconds: 300 - serviceAccountName: nginx-ingress-serviceaccount - nodeSelector: - kubernetes.io/os: linux - containers: - - name: nginx-ingress-controller - image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0 - args: - - /nginx-ingress-controller - - --configmap=$(POD_NAMESPACE)/nginx-configuration - - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services - - --udp-services-configmap=$(POD_NAMESPACE)/udp-services - - --publish-service=$(POD_NAMESPACE)/ingress-nginx - - --annotations-prefix=nginx.ingress.kubernetes.io - securityContext: - allowPrivilegeEscalation: true - capabilities: - drop: - - ALL - add: - - NET_BIND_SERVICE - # www-data -> 101 - runAsUser: 101 - env: - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - ports: - - name: http - containerPort: 80 - protocol: TCP - - name: https - containerPort: 443 - protocol: TCP - livenessProbe: - failureThreshold: 3 - httpGet: - path: /healthz - port: 10254 - scheme: HTTP - initialDelaySeconds: 10 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 10 - readinessProbe: - failureThreshold: 3 - httpGet: - path: /healthz - port: 10254 - scheme: HTTP - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 10 - lifecycle: - preStop: - exec: - command: - - /wait-shutdown - ---- - -apiVersion: v1 -kind: LimitRange -metadata: - name: ingress-nginx - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -spec: - limits: - - min: - memory: 90Mi - cpu: 100m - type: Container diff --git a/.travisci/ingress-service-nodeport.yaml b/.travisci/ingress-service-nodeport.yaml deleted file mode 100644 index 7f1e3bc..0000000 --- a/.travisci/ingress-service-nodeport.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -# source: https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml -apiVersion: v1 -kind: Service -metadata: - name: ingress-nginx - namespace: ingress-nginx - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -spec: - type: NodePort - ports: - - name: http - port: 80 - targetPort: 80 - protocol: TCP - - name: https - port: 443 - targetPort: 443 - protocol: TCP - selector: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx - ---- - diff --git a/.travisci/kind-cluster-config.yaml b/.travisci/kind-cluster-config.yaml deleted file mode 100644 index cadf6dd..0000000 --- a/.travisci/kind-cluster-config.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -# source: https://kind.sigs.k8s.io/docs/user/ingress/ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: -- role: control-plane - kubeadmConfigPatches: - - | - kind: InitConfiguration - nodeRegistration: - kubeletExtraArgs: - node-labels: "ingress-ready=true" - authorization-mode: "AlwaysAllow" - extraPortMappings: - - containerPort: 80 - hostPort: 80 - protocol: TCP - - containerPort: 443 - hostPort: 443 - protocol: TCP - diff --git a/.travisci/minio-standalone.yaml b/.travisci/minio-standalone.yaml deleted file mode 100644 index d8ad30d..0000000 --- a/.travisci/minio-standalone.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- -# source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-pvc.yaml -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - # This name uniquely identifies the PVC. This is used in deployment. - name: minio-pv-claim -spec: - # Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes - accessModes: - # The volume is mounted as read-write by a single node - - ReadWriteOnce - resources: - # This is the request for storage. Should be available in the cluster. - requests: - storage: 10Gi ---- -# source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-service.yaml -apiVersion: v1 -kind: Service -metadata: - # This name uniquely identifies the service - name: minio-service -spec: - type: LoadBalancer - ports: - - port: 9000 - targetPort: 9000 - protocol: TCP - selector: - # Looks for labels `app:minio` in the namespace and applies the spec - app: minio ---- -# source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-deployment.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - # This name uniquely identifies the Deployment - name: minio -spec: - selector: - matchLabels: - app: minio # has to match .spec.template.metadata.labels - strategy: - # Specifies the strategy used to replace old Pods by new ones - # Refer: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy - type: Recreate - template: - metadata: - labels: - # This label is used as a selector in Service definition - app: minio - spec: - # Volumes used by this deployment - volumes: - - name: data - # This volume is based on PVC - persistentVolumeClaim: - # Name of the PVC created earlier - claimName: minio-pv-claim - containers: - - name: minio - # Volume mounts for this container - volumeMounts: - # Volume 'data' is mounted to path '/data' - - name: data - mountPath: "/data" - # Pulls the lastest Minio image from Docker Hub - image: minio/minio:RELEASE.2020-04-15T19-42-18Z - args: - - server - - /data - env: - # MinIO access key and secret key - - name: MINIO_ACCESS_KEY - value: "minio" - - name: MINIO_SECRET_KEY - value: "minio123" - ports: - - containerPort: 9000 - # Readiness probe detects situations when MinIO server instance - # is not ready to accept traffic. Kubernetes doesn't forward - # traffic to the pod while readiness checks fail. - readinessProbe: - httpGet: - path: /minio/health/ready - port: 9000 - initialDelaySeconds: 120 - periodSeconds: 20 - # Liveness probe detects situations where MinIO server instance - # is not working properly and needs restart. Kubernetes automatically - # restarts the pods if liveness checks fail. - livenessProbe: - httpGet: - path: /minio/health/live - port: 9000 - initialDelaySeconds: 120 - periodSeconds: 20 diff --git a/.travisci/spinnaker-ingress.yaml b/.travisci/spinnaker-ingress.yaml deleted file mode 100644 index 2edd69a..0000000 --- a/.travisci/spinnaker-ingress.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - labels: - app: spin - name: spin-ingress - namespace: spinnaker -spec: - rules: - - http: - paths: - - backend: - serviceName: spin-deck - servicePort: 9000 - path: / - - backend: - serviceName: spin-gate - servicePort: 8084 - path: /api/v1 - diff --git a/.travisci/start_spinnaker.sh b/.travisci/start_spinnaker.sh deleted file mode 100755 index 9ca1dc3..0000000 --- a/.travisci/start_spinnaker.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -e - -GATE_API_BRANCH=$1 -FLOODGATE_EXTRA_PARAMS="" - -echo "Update submodules - sponnet" -git submodule init && git submodule update - -echo "Prepare directories" -sudo mkdir /floodgate -sudo chmod 777 /floodgate -mkdir -p /floodgate/bin -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 - -.travisci/install_toolset.sh - -echo "Update /etc/hosts" -sudo bash -c 'echo "127.1.2.3 spinnaker" >> /etc/hosts' - -.travisci/wait_for_dpkg.sh - -echo Install Spinnaker and configure Floodgate -export NEED_SPINNAKER_VERSION=$( echo $GATE_API_BRANCH | egrep -o "[0-9]\.[0-9]+" ) -.travisci/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 - -echo Test Floodgate against running Spinnaker instance -/floodgate/bin/floodgate --version -/floodgate/bin/floodgate version -/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare && exit 1 || echo "Found changes" -/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml sync -/floodgate/bin/floodgate $FLOODGATE_EXTRA_PARAMS --config ~/floodgate.yaml compare - From 862b1b5ca01d7a263ba6ec420967dfa7d6053f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 23 Jun 2020 12:12:43 +0200 Subject: [PATCH 09/18] positive spiannaker test is obligatory to job success --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0fc998..ba2e04c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,5 @@ script: - docker pull golang:1.14.1-stretch - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate -e SERIESCI_TOKEN=$SERIESCI_TOKEN --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done - sudo chown $SUDO_USER:$SUDO_USER -R . - -after_success: - .cilibs/start_spinnaker.sh -a `echo $BUILD_ARCH | cut -d" " -f1` -o `echo $BUILD_OS | cut -d" " -f1` -g $GATE_API_BRANCH -e $FLOODGATE_EXTRA_PARAMS From 2f7820c651f496bc5c1c2a2876f488aec6816c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 23 Jun 2020 14:02:43 +0200 Subject: [PATCH 10/18] commit id var can be obtained from circleCi or travis --- .cilibs/calculate_code_coverage.sh | 4 +++- .travis.yml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.cilibs/calculate_code_coverage.sh b/.cilibs/calculate_code_coverage.sh index 08a88dc..9829e1f 100755 --- a/.cilibs/calculate_code_coverage.sh +++ b/.cilibs/calculate_code_coverage.sh @@ -1,6 +1,8 @@ #!/bin/bash -e SEND_COVERITY=$1 +COMMIT_ID="${CIRCLE_SHA1:-$TRAVIS_COMMIT}" + echo "Calculate code coverage" REQUIREDCODECOVERAGE=60 @@ -13,7 +15,7 @@ then curl \ --header "Authorization: Token ${SERIESCI_TOKEN}" \ --header "Content-Type: application/json" \ - --data "{\"value\":\"${CURRENTCODECOVERAGE} %\",\"sha\":\"${CIRCLE_SHA1}\"}" \ + --data "{\"value\":\"${CURRENTCODECOVERAGE} %\",\"sha\":\"${COMMIT_ID}\"}" \ https://seriesci.com/api/codilime/floodgate/coverage/one else echo "Skipping" diff --git a/.travis.yml b/.travis.yml index ba2e04c..b62e5e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_script: script: - docker pull golang:1.14.1-stretch - - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate -e SERIESCI_TOKEN=$SERIESCI_TOKEN --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done + - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done - sudo chown $SUDO_USER:$SUDO_USER -R . - .cilibs/start_spinnaker.sh -a `echo $BUILD_ARCH | cut -d" " -f1` -o `echo $BUILD_OS | cut -d" " -f1` -g $GATE_API_BRANCH -e $FLOODGATE_EXTRA_PARAMS From c90457da55030c3cd07b7e80924d6caa1cd9e792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 23 Jun 2020 14:38:06 +0200 Subject: [PATCH 11/18] pass TRAVIS variables to docker --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b62e5e9..b2346bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_script: script: - docker pull golang:1.14.1-stretch - - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done + - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -e SERIESCI_TOKEN=$SERIESCI_TOKEN -e TRAVIS_COMMIT=$TRAVIS_COMMIT -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done - sudo chown $SUDO_USER:$SUDO_USER -R . - .cilibs/start_spinnaker.sh -a `echo $BUILD_ARCH | cut -d" " -f1` -o `echo $BUILD_OS | cut -d" " -f1` -g $GATE_API_BRANCH -e $FLOODGATE_EXTRA_PARAMS From feca96bd48fbdf2fe7104308afe82199fc5527c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Wed, 15 Jul 2020 13:14:15 +0200 Subject: [PATCH 12/18] merged generating swagger into one script --- .cilibs/generate_gateapi_go_code.sh | 6 - .cilibs/generate_swagger.sh | 8 +- .cilibs/generate_swagger_json.sh | 7 - .cilibs/get_gate_code.sh | 7 - ...up_swagger_codegen.sh => setup_swagger.sh} | 14 ++ .circleci/config.yml | 231 ------------------ 6 files changed, 15 insertions(+), 258 deletions(-) delete mode 100755 .cilibs/generate_gateapi_go_code.sh delete mode 100755 .cilibs/generate_swagger_json.sh delete mode 100755 .cilibs/get_gate_code.sh rename .cilibs/{setup_swagger_codegen.sh => setup_swagger.sh} (54%) delete mode 100644 .circleci/config.yml diff --git a/.cilibs/generate_gateapi_go_code.sh b/.cilibs/generate_gateapi_go_code.sh deleted file mode 100755 index 8b84535..0000000 --- a/.cilibs/generate_gateapi_go_code.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -e - -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 - - diff --git a/.cilibs/generate_swagger.sh b/.cilibs/generate_swagger.sh index dd794a4..52583df 100755 --- a/.cilibs/generate_swagger.sh +++ b/.cilibs/generate_swagger.sh @@ -4,11 +4,5 @@ GATE_API_BRANCH=$1 .cilibs/prepare_extra_directories.sh -.cilibs/setup_swagger_codegen.sh - -.cilibs/get_gate_code.sh $GATE_API_BRANCH - -.cilibs/generate_swagger_json.sh - -.cilibs/generate_gateapi_go_code.sh +.cilibs/setup_swagger.sh $GATE_API_BRANCH diff --git a/.cilibs/generate_swagger_json.sh b/.cilibs/generate_swagger_json.sh deleted file mode 100755 index c911245..0000000 --- a/.cilibs/generate_swagger_json.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e - -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 diff --git a/.cilibs/get_gate_code.sh b/.cilibs/get_gate_code.sh deleted file mode 100755 index 391e32f..0000000 --- a/.cilibs/get_gate_code.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e - -GATE_API_BRANCH=$1 - -echo "Get gate code" -git clone https://github.com/spinnaker/gate.git -b ${GATE_API_BRANCH} /floodgate/gate - diff --git a/.cilibs/setup_swagger_codegen.sh b/.cilibs/setup_swagger.sh similarity index 54% rename from .cilibs/setup_swagger_codegen.sh rename to .cilibs/setup_swagger.sh index 4a72b75..fc7e37e 100755 --- a/.cilibs/setup_swagger_codegen.sh +++ b/.cilibs/setup_swagger.sh @@ -1,5 +1,7 @@ #!/bin/bash -e +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 @@ -7,3 +9,15 @@ wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_VER 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 diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 7ada5ef..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,231 +0,0 @@ -version: 2.1 - -aliases: - latest-gate-version: &default-gate-version - gate_api_branch: - type: string - default: release-1.20.x - supported-spinnaker-releases: &gate-versions - gate_api_branch: [ "release-1.20.x", "release-1.19.x", "release-1.18.x" ] - supported-client-os: &build-os-type - build_os: [ "linux", "darwin" ] - release-filters: &filters-release - filters: - branches: - only: - - /release-v[0-9]+\.[0-9]+\.x/ - tags: - only: - - /v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?/ - -commands: - install_toolset: - description: "Install needed extra tools" - steps: - - run: - name: Install tools - command: .cilibs/install_toolset.sh - - wait_for_dpkg: - description: "Wait for packaging operations to finish" - steps: - - run: - name: Wait for packaging operations to finish - command: .cilibs/wait_for_dpkg.sh - -jobs: - generate_swagger: - parameters: *default-gate-version - docker: - - image: circleci/openjdk:11.0.3-jdk-stretch - steps: - - checkout - - run: - name: Prepare extra directories - command: sudo .cilibs/prepare_extra_directories.sh - - run: - name: Setup swagger-codegen - command: sudo .cilibs/setup_swagger_codegen.sh - - run: - name: Get gate code - command: .cilibs/get_gate_code.sh << parameters.gate_api_branch >> - - run: - name: Generate swagger.json - command: .cilibs/generate_swagger_json.sh - - run: - name: Generate gateapi go code - command: .cilibs/generate_gateapi_go_code.sh - - persist_to_workspace: - root: /floodgate - paths: - - gate-swagger.json - - gateapi - - store_artifacts: - path: /floodgate/gate/swagger/gate-swagger.json - destination: gate-swagger.json - - build: - parameters: - <<: *default-gate-version - build_os: - type: string - default: linux - build_arch: - type: string - default: amd64 - send_coverity: - type: enum - default: send - enum: ["send", "dont-send"] - docker: - - image: circleci/golang:1.14.1 - environment: - GO111MODULE: "on" - working_directory: /go/src/github.com/codilime/floodgate - steps: - - checkout - - run: git submodule sync - - run: git submodule update --init - - run: - name: Remove gateapi dir - command: rm -r gateapi - - attach_workspace: - at: ./ - - run: - name: Get dependencies - command: .cilibs/get_dependencies.sh - - run: - name: Examine source code with go vet - command: .cilibs/examine_source_code_with_go_get.sh - - run: - name: Execute go tests - command: .cilibs/execute_go_tests.sh - - run: - name: Compile code - command: .cilibs/compile_code.sh -o << parameters.build_os >> -a << parameters.build_arch >> -g << parameters.gate_api_branch >> - - run: - name: Calculate code coverage - environment: - REQUIREDCODECOVERAGE: 60 - command: .cilibs/calculate_code_coverage.sh << parameters.send_coverity >> - - run: - name: Check linting - command: .cilibs/check_linting.sh - - run: - name: Copy binaries for later use - command: sudo .cilibs/copy_binaries_for_later_use.sh - - run: - name: Generate checksum - command: .cilibs/generate_checksum.sh -o << parameters.build_os >> -a << parameters.build_arch >> -g << parameters.gate_api_branch >> - - persist_to_workspace: - root: /floodgate/bin - paths: - - floodgate - - store_artifacts: - path: /go/src/github.com/codilime/floodgate/floodgate - destination: floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >> - - store_artifacts: - path: /go/src/github.com/codilime/floodgate/floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >>.sha1sum - destination: floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >>.sha1sum - - start_spinnaker: - parameters: - <<: *default-gate-version - floodgate_extra_params: - type: string - default: "" - machine: - image: ubuntu-1604:202004-01 - steps: - - checkout - - run: - name: Update submodules - sponnet - command: git submodule init && git submodule update - - attach_workspace: - at: ./ - - run: - name: Prepare directories - command: .cilibs/prepare_directories.sh - - install_toolset - - run: - name: Update /etc/hosts - command: .cilibs/update_hosts.sh - - wait_for_dpkg - - run: - name: Install Spinnaker and configure Floodgate - command: .cilibs/install_spinnaker_and_configure_floodgate.sh << parameters.gate_api_branch >> - - run: - name: Test Floodgate against running Spinnaker instance - command: .cilibs/test_floodgate_against_running_spinnaker_instance.sh << parameters.floodgate_extra_params >> - -workflows: - periodic: - triggers: - - schedule: - cron: "15 2 * * *" - filters: - branches: - only: - - master - jobs: - - generate_swagger: - name: generate swagger api << matrix.gate_api_branch >> - matrix: - parameters: *gate-versions - - build: - name: build for << matrix.build_os >> against gate << matrix.gate_api_branch >> - build_arch: amd64 - send_coverity: dont-send - matrix: - parameters: - <<: *gate-versions - <<: *build-os-type - requires: - - generate swagger api << matrix.gate_api_branch >> - - start_spinnaker: - name: test floodgate with working spinnaker << matrix.gate_api_branch >> - matrix: - parameters: *gate-versions - requires: - - build for linux against gate << matrix.gate_api_branch >> - - release: - jobs: - - generate_swagger: - <<: *filters-release - name: generate swagger api << matrix.gate_api_branch >> - matrix: - parameters: *gate-versions - - - build: - <<: *filters-release - name: build for << matrix.build_os >> against gate << matrix.gate_api_branch >> - build_arch: amd64 - send_coverity: dont-send - matrix: - parameters: - <<: *gate-versions - <<: *build-os-type - requires: - - generate swagger api << matrix.gate_api_branch >> - - start_spinnaker: - <<: *filters-release - name: test floodgate with working spinnaker << matrix.gate_api_branch >> - matrix: - parameters: *gate-versions - requires: - - build for linux against gate << matrix.gate_api_branch >> - - commit: - jobs: - - generate_swagger: - name: generate swagger api - - build: - name: build - requires: - - generate swagger api - - start_spinnaker: - name: test floodgate with working spinnaker - floodgate_extra_params: "-q" - requires: - - build From 88c41c756630d42efb10f8008be0652e79c02992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Wed, 15 Jul 2020 13:32:25 +0200 Subject: [PATCH 13/18] moved yaml files to separate directory --- .cilibs/install-and-run-spinnaker.sh | 20 +- .cilibs/{ => templates}/floodgate-config.yaml | 0 .cilibs/{ => templates}/gate-local.yml | 0 .../{ => templates}/ingress-mandatory.yaml | 0 .../ingress-service-nodeport.yaml | 0 .../{ => templates}/kind-cluster-config.yaml | 0 .cilibs/{ => templates}/minio-standalone.yaml | 0 .../{ => templates}/spinnaker-ingress.yaml | 0 .circleci/config.yml | 222 ++++++++++++++++++ 9 files changed, 232 insertions(+), 10 deletions(-) rename .cilibs/{ => templates}/floodgate-config.yaml (100%) rename .cilibs/{ => templates}/gate-local.yml (100%) rename .cilibs/{ => templates}/ingress-mandatory.yaml (100%) rename .cilibs/{ => templates}/ingress-service-nodeport.yaml (100%) rename .cilibs/{ => templates}/kind-cluster-config.yaml (100%) rename .cilibs/{ => templates}/minio-standalone.yaml (100%) rename .cilibs/{ => templates}/spinnaker-ingress.yaml (100%) create mode 100644 .circleci/config.yml diff --git a/.cilibs/install-and-run-spinnaker.sh b/.cilibs/install-and-run-spinnaker.sh index 65da2ad..7eeabc5 100755 --- a/.cilibs/install-and-run-spinnaker.sh +++ b/.cilibs/install-and-run-spinnaker.sh @@ -14,7 +14,7 @@ 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 @@ -34,8 +34,8 @@ 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 @@ -55,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 @@ -66,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}/templastes/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 diff --git a/.cilibs/floodgate-config.yaml b/.cilibs/templates/floodgate-config.yaml similarity index 100% rename from .cilibs/floodgate-config.yaml rename to .cilibs/templates/floodgate-config.yaml diff --git a/.cilibs/gate-local.yml b/.cilibs/templates/gate-local.yml similarity index 100% rename from .cilibs/gate-local.yml rename to .cilibs/templates/gate-local.yml diff --git a/.cilibs/ingress-mandatory.yaml b/.cilibs/templates/ingress-mandatory.yaml similarity index 100% rename from .cilibs/ingress-mandatory.yaml rename to .cilibs/templates/ingress-mandatory.yaml diff --git a/.cilibs/ingress-service-nodeport.yaml b/.cilibs/templates/ingress-service-nodeport.yaml similarity index 100% rename from .cilibs/ingress-service-nodeport.yaml rename to .cilibs/templates/ingress-service-nodeport.yaml diff --git a/.cilibs/kind-cluster-config.yaml b/.cilibs/templates/kind-cluster-config.yaml similarity index 100% rename from .cilibs/kind-cluster-config.yaml rename to .cilibs/templates/kind-cluster-config.yaml diff --git a/.cilibs/minio-standalone.yaml b/.cilibs/templates/minio-standalone.yaml similarity index 100% rename from .cilibs/minio-standalone.yaml rename to .cilibs/templates/minio-standalone.yaml diff --git a/.cilibs/spinnaker-ingress.yaml b/.cilibs/templates/spinnaker-ingress.yaml similarity index 100% rename from .cilibs/spinnaker-ingress.yaml rename to .cilibs/templates/spinnaker-ingress.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6f564ca --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,222 @@ +version: 2.1 + +aliases: + latest-gate-version: &default-gate-version + gate_api_branch: + type: string + default: release-1.20.x + supported-spinnaker-releases: &gate-versions + gate_api_branch: [ "release-1.20.x", "release-1.19.x", "release-1.18.x" ] + supported-client-os: &build-os-type + build_os: [ "linux", "darwin" ] + release-filters: &filters-release + filters: + branches: + only: + - /release-v[0-9]+\.[0-9]+\.x/ + tags: + only: + - /v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?/ + +commands: + install_toolset: + description: "Install needed extra tools" + steps: + - run: + name: Install tools + command: .cilibs/install_toolset.sh + + wait_for_dpkg: + description: "Wait for packaging operations to finish" + steps: + - run: + name: Wait for packaging operations to finish + command: .cilibs/wait_for_dpkg.sh + +jobs: + generate_swagger: + parameters: *default-gate-version + docker: + - image: circleci/openjdk:11.0.3-jdk-stretch + steps: + - checkout + - run: + name: Prepare extra directories + command: sudo .cilibs/prepare_extra_directories.sh + - run: + name: Setup swagger + command: sudo .cilibs/setup_swagger.sh << parameters.gate_api_branch >> + - persist_to_workspace: + root: /floodgate + paths: + - gate-swagger.json + - gateapi + - store_artifacts: + path: /floodgate/gate/swagger/gate-swagger.json + destination: gate-swagger.json + + build: + parameters: + <<: *default-gate-version + build_os: + type: string + default: linux + build_arch: + type: string + default: amd64 + send_coverity: + type: enum + default: send + enum: ["send", "dont-send"] + docker: + - image: circleci/golang:1.14.1 + environment: + GO111MODULE: "on" + working_directory: /go/src/github.com/codilime/floodgate + steps: + - checkout + - run: git submodule sync + - run: git submodule update --init + - run: + name: Remove gateapi dir + command: rm -r gateapi + - attach_workspace: + at: ./ + - run: + name: Get dependencies + command: .cilibs/get_dependencies.sh + - run: + name: Examine source code with go vet + command: .cilibs/examine_source_code_with_go_get.sh + - run: + name: Execute go tests + command: .cilibs/execute_go_tests.sh + - run: + name: Compile code + command: .cilibs/compile_code.sh -o << parameters.build_os >> -a << parameters.build_arch >> -g << parameters.gate_api_branch >> + - run: + name: Calculate code coverage + environment: + REQUIREDCODECOVERAGE: 60 + command: .cilibs/calculate_code_coverage.sh << parameters.send_coverity >> + - run: + name: Check linting + command: .cilibs/check_linting.sh + - run: + name: Copy binaries for later use + command: sudo .cilibs/copy_binaries_for_later_use.sh + - run: + name: Generate checksum + command: .cilibs/generate_checksum.sh -o << parameters.build_os >> -a << parameters.build_arch >> -g << parameters.gate_api_branch >> + - persist_to_workspace: + root: /floodgate/bin + paths: + - floodgate + - store_artifacts: + path: /go/src/github.com/codilime/floodgate/floodgate + destination: floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >> + - store_artifacts: + path: /go/src/github.com/codilime/floodgate/floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >>.sha1sum + destination: floodgate-<< parameters.gate_api_branch >>.<< parameters.build_os >>.<< parameters.build_arch >>.sha1sum + + start_spinnaker: + parameters: + <<: *default-gate-version + floodgate_extra_params: + type: string + default: "" + machine: + image: ubuntu-1604:202004-01 + steps: + - checkout + - run: + name: Update submodules - sponnet + command: git submodule init && git submodule update + - attach_workspace: + at: ./ + - run: + name: Prepare directories + command: .cilibs/prepare_directories.sh + - install_toolset + - run: + name: Update /etc/hosts + command: .cilibs/update_hosts.sh + - wait_for_dpkg + - run: + name: Install Spinnaker and configure Floodgate + command: .cilibs/install_spinnaker_and_configure_floodgate.sh << parameters.gate_api_branch >> + - run: + name: Test Floodgate against running Spinnaker instance + command: .cilibs/test_floodgate_against_running_spinnaker_instance.sh << parameters.floodgate_extra_params >> + +workflows: + periodic: + triggers: + - schedule: + cron: "15 2 * * *" + filters: + branches: + only: + - master + jobs: + - generate_swagger: + name: generate swagger api << matrix.gate_api_branch >> + matrix: + parameters: *gate-versions + - build: + name: build for << matrix.build_os >> against gate << matrix.gate_api_branch >> + build_arch: amd64 + send_coverity: dont-send + matrix: + parameters: + <<: *gate-versions + <<: *build-os-type + requires: + - generate swagger api << matrix.gate_api_branch >> + - start_spinnaker: + name: test floodgate with working spinnaker << matrix.gate_api_branch >> + matrix: + parameters: *gate-versions + requires: + - build for linux against gate << matrix.gate_api_branch >> + + release: + jobs: + - generate_swagger: + <<: *filters-release + name: generate swagger api << matrix.gate_api_branch >> + matrix: + parameters: *gate-versions + + - build: + <<: *filters-release + name: build for << matrix.build_os >> against gate << matrix.gate_api_branch >> + build_arch: amd64 + send_coverity: dont-send + matrix: + parameters: + <<: *gate-versions + <<: *build-os-type + requires: + - generate swagger api << matrix.gate_api_branch >> + - start_spinnaker: + <<: *filters-release + name: test floodgate with working spinnaker << matrix.gate_api_branch >> + matrix: + parameters: *gate-versions + requires: + - build for linux against gate << matrix.gate_api_branch >> + + commit: + jobs: + - generate_swagger: + name: generate swagger api + - build: + name: build + requires: + - generate swagger api + - start_spinnaker: + name: test floodgate with working spinnaker + floodgate_extra_params: "-q" + requires: + - build From 0013bef11370cb9592da4b560a31815642975b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 21 Jul 2020 13:47:07 +0200 Subject: [PATCH 14/18] make RELEASE and COMMIT_ID variables universal --- .cilibs/compile_code.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.cilibs/compile_code.sh b/.cilibs/compile_code.sh index 09f01e3..0971101 100755 --- a/.cilibs/compile_code.sh +++ b/.cilibs/compile_code.sh @@ -3,6 +3,7 @@ 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 @@ -19,15 +20,20 @@ while getopts "o:a:g:" opt; do esac done -echo "Compile code" -if [ -z "$TRAVIS_BRANCH" ] +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=$TRAVIS_COMMIT \ +"-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 \ From 72df636b2c442adc5769045b4ab41474d1ec3e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 21 Jul 2020 13:54:06 +0200 Subject: [PATCH 15/18] added missing descriptions of executed commands --- .../test_floodgate_against_running_spinnaker_instance.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cilibs/test_floodgate_against_running_spinnaker_instance.sh b/.cilibs/test_floodgate_against_running_spinnaker_instance.sh index 110fc92..c1eb28d 100755 --- a/.cilibs/test_floodgate_against_running_spinnaker_instance.sh +++ b/.cilibs/test_floodgate_against_running_spinnaker_instance.sh @@ -3,9 +3,15 @@ FLOODGATE_EXTRA_PARAMS=$1 echo Test Floodgate against running Spinnaker instance + +echo "Print version using version flag" /floodgate/bin/floodgate --version +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 From 654ea91b7631df0190de6bf68ea5f23b435734b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 21 Jul 2020 14:17:07 +0200 Subject: [PATCH 16/18] Make travis.yml more readable --- .cilibs/prepare_extra_directories.sh | 5 ++-- .cilibs/setup_swagger.sh | 2 +- .circleci/config.yml | 2 +- .travis.yml | 35 ++++++++++++++++++++++------ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.cilibs/prepare_extra_directories.sh b/.cilibs/prepare_extra_directories.sh index 780b75e..5148d25 100755 --- a/.cilibs/prepare_extra_directories.sh +++ b/.cilibs/prepare_extra_directories.sh @@ -1,6 +1,5 @@ #!/bin/bash -e echo "Prepare extra directories" -mkdir /floodgate -chmod 777 /floodgate -mkdir /floodgate/bin +mkdir -p /floodgate/bin +chmod 777 -R /floodgate diff --git a/.cilibs/setup_swagger.sh b/.cilibs/setup_swagger.sh index fc7e37e..fc457ca 100755 --- a/.cilibs/setup_swagger.sh +++ b/.cilibs/setup_swagger.sh @@ -1,5 +1,5 @@ #!/bin/bash -e - +export TERM=${TERM:-dumb} #Needed because sudo is used in CircleCi GATE_API_BRANCH=$1 echo "Setup swagger-codegen" diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f564ca..8a8f930 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,7 @@ jobs: command: sudo .cilibs/prepare_extra_directories.sh - run: name: Setup swagger - command: sudo .cilibs/setup_swagger.sh << parameters.gate_api_branch >> + command: .cilibs/setup_swagger.sh << parameters.gate_api_branch >> - persist_to_workspace: root: /floodgate paths: diff --git a/.travis.yml b/.travis.yml index b2346bd..21604d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,13 @@ dist: xenial language: go go: - 1.14.1 -env: - - REALESE_BRANCHES="release-v[0-9]+\.[0-9]+\.x" RELEASE_TAGS="v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" BUILD_OS="$([ $TRAVIS_EVENT_TYPE == cron ] || [[ $TRAVIS_BRANCH =~ $RELEASE_BRANCHES ]] || [[ $TRAVIS_TAG =~ $RELEASE_TAGS ]] && echo darwin) linux" BUILD_ARCH=amd64 GATE_API_BRANCH=release-1.20.x SEND_COVERITY=send +env: | + REALESE_BRANCHES="release-v[0-9]+\.[0-9]+\.x" + RELEASE_TAGS="v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" + BUILD_OS="$([ $TRAVIS_EVENT_TYPE == cron ] || [[ $TRAVIS_BRANCH =~ $RELEASE_BRANCHES ]] || [[ $TRAVIS_TAG =~ $RELEASE_TAGS ]] && echo darwin) linux" + BUILD_ARCH=amd64 + GATE_API_BRANCH=release-1.20.x + SEND_COVERITY=send services: - docker @@ -11,9 +16,25 @@ before_script: - docker pull openjdk:11.0.3-stretch - docker run -u root -w /workspace -v `pwd`:/workspace --entrypoint /workspace/.cilibs/generate_swagger.sh --rm openjdk:11.0.3-stretch release-1.20.x -script: - - docker pull golang:1.14.1-stretch - - for o in $BUILD_OS; do for a in $BUILD_ARCH; do docker run -e SERIESCI_TOKEN=$SERIESCI_TOKEN -e TRAVIS_COMMIT=$TRAVIS_COMMIT -u root -w /go/src/github.com/codilime/floodgate -v `pwd`:/go/src/github.com/codilime/floodgate --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh --rm golang:1.14.1-stretch -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY ; done; done - - sudo chown $SUDO_USER:$SUDO_USER -R . - - .cilibs/start_spinnaker.sh -a `echo $BUILD_ARCH | cut -d" " -f1` -o `echo $BUILD_OS | cut -d" " -f1` -g $GATE_API_BRANCH -e $FLOODGATE_EXTRA_PARAMS +script: | + docker pull golang:1.14.1-stretch + for o in $BUILD_OS + do + for a in $BUILD_ARCH + do + docker run -e SERIESCI_TOKEN=$SERIESCI_TOKEN \ + -e TRAVIS_COMMIT=$TRAVIS_COMMIT \ + -u root \ + -w /go/src/github.com/codilime/floodgate \ + -v `pwd`:/go/src/github.com/codilime/floodgate \ + --entrypoint /go/src/github.com/codilime/floodgate/.cilibs/build.sh \ + --rm golang:1.14.1-stretch \ + -g $GATE_API_BRANCH -o $o -a $a -c $SEND_COVERITY + done + done + sudo chown $SUDO_USER:$SUDO_USER -R . + .cilibs/start_spinnaker.sh -a `echo $BUILD_ARCH | cut -d" " -f1` \ + -o `echo $BUILD_OS | cut -d" " -f1` \ + -g $GATE_API_BRANCH \ + -e $FLOODGATE_EXTRA_PARAMS From b1b8281bbad33338c8f58de8a75c61a854c83125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Tue, 21 Jul 2020 14:42:45 +0200 Subject: [PATCH 17/18] reduce code in preparing directories --- .cilibs/prepare_directories.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.cilibs/prepare_directories.sh b/.cilibs/prepare_directories.sh index cfd2b6e..89a882b 100755 --- a/.cilibs/prepare_directories.sh +++ b/.cilibs/prepare_directories.sh @@ -3,10 +3,7 @@ BUILD_OS=linux BUILD_ARCH=amd64 -echo "Prepare directories" -sudo mkdir /floodgate -sudo chmod 777 /floodgate -mkdir -p /floodgate/bin +sudo bash -c "source .cilibs/prepare_extra_directories.sh" mkdir -p /floodgate/libs mkdir -p /floodgate/resources cp -r sponnet /floodgate/libs/ From 58bbec4b2998b0df9d133253502e8c1178f5f833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paradowski?= Date: Wed, 22 Jul 2020 15:30:41 +0200 Subject: [PATCH 18/18] typo --- .cilibs/install-and-run-spinnaker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cilibs/install-and-run-spinnaker.sh b/.cilibs/install-and-run-spinnaker.sh index 7eeabc5..9f457d6 100755 --- a/.cilibs/install-and-run-spinnaker.sh +++ b/.cilibs/install-and-run-spinnaker.sh @@ -66,7 +66,7 @@ do done # Install Ingress controller -kubectl apply -f "${EXEC_DIR}/templastes/ingress-mandatory.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}/templates/spinnaker-ingress.yaml"