Skip to content

Commit

Permalink
pipe: improve pipeline - add ability to release, upgrade some tools (#7)
Browse files Browse the repository at this point in the history
* pipe: improve pipeline - add ability to release, upgrade some tools

* Fix

* Fix

* Fix

* Fix

Co-authored-by: Eriks Zelenka <isindir@users.sf.net>
  • Loading branch information
isindir and isindir committed May 31, 2020
1 parent aeccbc2 commit 03bd87f
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 63 deletions.
40 changes: 0 additions & 40 deletions .circleci/Dockerfile

This file was deleted.

121 changes: 98 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,94 @@
# based on https://github.com/gavinzhou/ci-minikube
# https://github.com/kubernetes/minikube#linux-continuous-integration-without-vm-support
version: 2

jobs:
##################################################
# release
##################################################
release:
working_directory: /home/circleci/gogo/src/github.com/isindir/eks-ebs-node-operator
machine:
image: ubuntu-1604:202004-01
environment:
GOLANG_VERSION: 1.14.2
# https://github.com/operator-framework/operator-sdk/releases
OPERATOR_SDK_VERSION: v0.13.0
# https://github.com/github/hub/releases
HUB_VERSION: 2.14.2
# https://github.com/git-chglog/git-chglog/releases
GIT_CHGLOG_VERSION: 0.9.1
steps:
- checkout
- run:
name: install golang
command: |
sudo rm -fr /usr/local/go
curl -sSLO https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz
tar -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz
sudo mv go /usr/local
rm -fr go${GOLANG_VERSION}.linux-amd64.tar.gz
mkdir -p $GOPATH/{src/github.com/isindir,bin,pkg}
go get -u golang.org/x/lint/golint
go version
go env
- restore-cache:
keys:
- v2-modules-{{ .Branch }}-{{ checksum "go.sum" }}
- v2-modules-{{ .Branch }}-
- v2-modules-
- run:
name: install operator-sdk
command: |
curl -sSLo operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu
chmod +x operator-sdk
sudo mv operator-sdk /usr/local/bin/
- run:
name: install git-chglog
command: |
curl -sSLo git-chglog https://github.com/git-chglog/git-chglog/releases/download/${GIT_CHGLOG_VERSION}/git-chglog_linux_amd64
chmod +x git-chglog
sudo mv git-chglog /usr/local/bin/
- run:
name: install hub
command: |
curl -sSLO https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-linux-amd64-${HUB_VERSION}.tgz
tar -xzf hub-linux-amd64-${HUB_VERSION}.tgz
chmod +x hub-linux-amd64-${HUB_VERSION}/bin/hub
sudo mv hub-linux-amd64-${HUB_VERSION}/bin/hub /usr/local/bin/
- run:
name: Fetch Go dependencies
command: |
make mod
- run:
name: Build
command: |
make build
- run:
name: release
command: |
make release
##################################################
# build
##################################################
build:
working_directory: /home/circleci/gogo/src/github.com/isindir/sops-secrets-operator
machine:
image: ubuntu-1604:201903-01
image: ubuntu-1604:202004-01
environment:
K8S_VERSION: v1.16.3
KIND_VERSION: v0.6.1
HELM_VERSION: v3.0.2
GOLANG_VERSION: 1.13.4
# https://github.com/kubernetes/kubernetes/releases
K8S_VERSION: v1.18.3
# https://github.com/kubernetes-sigs/kind/releases
KIND_VERSION: v0.8.1
# https://github.com/helm/helm/releases
HELM_VERSION: v3.2.1
GOLANG_VERSION: 1.14.2
# https://github.com/operator-framework/operator-sdk/releases
OPERATOR_SDK_VERSION: v0.13.0
# https://github.com/mozilla/sops/releases
SOPS_VERSION: v3.5.0

KUBECONFIG: /home/circleci/.kube/config

MINIKUBE_WANTUPDATENOTIFICATION: false
MINIKUBE_WANTREPORTERRORPROMPT: false
MINIKUBE_HOME: /home/circleci
CHANGE_MINIKUBE_NONE_USER: true

GOPATH: /home/circleci/gogo
GOROOT: /usr/local/go
GO111MODULE: "on"
Expand All @@ -45,15 +112,11 @@ jobs:
go get -u golang.org/x/lint/golint
go version
go env
- run:
name: install bats
command: |
sudo add-apt-repository ppa:duggan/bats
sudo apt-get update
sudo apt-get install bats -y
- run:
name: install gpg2
command: |
sudo apt update
sudo apt install -f
sudo apt-get install gnupg2 -y
- run:
name: install kubectl
Expand Down Expand Up @@ -84,18 +147,16 @@ jobs:
- run:
name: start kind
command: |
kind create cluster
kind create cluster --name operator
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1;
done
# make default account cluster-admin
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole cluster-admin --serviceaccount=kube-system:default
# Dump cluster info
kubectl cluster-info
kubectl version
kubectl describe node operator-control-plane
- run:
name: setup helm
command: |
Expand Down Expand Up @@ -141,7 +202,7 @@ jobs:
export SOPS_GPG_EXEC=$( which gpg2 )
export FP=$( gpg2 --with-colons --fingerprint | awk -F: '$1 == "fpr" {print $10; exit}' )
echo "Fingreprint: $FP ; gpg executable: $SOPS_GPG_EXEC"
# TODO: replace some of this by bash unit tests
# Run k8s related commands
kubectl create namespace sops
kubectl apply -f deploy/crds/isindir_v1alpha1_sopssecret_crd.yaml
Expand Down Expand Up @@ -185,3 +246,17 @@ jobs:
command: |
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
make test
workflows:
version: 2
build_and_release:
jobs:
- build:
filters:
branches:
ignore: master
- release:
filters:
branches:
only:
- master
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ repo-tag:
@git tag -a ${VERSION} -m "sops-secrets-operator ${VERSION}"

.PHONY: release
## release: creates github release and pushes docker image to dockerhub
release:
@{ \
set +e ; \
git tag "${VERSION}" ; \
tagResult=$$? ; \
if [[ $$tagResult -ne 0 ]]; then \
echo "Release '${VERSION}' exists - skipping" ; \
else \
set -e ; \
git-chglog "${VERSION}" > chglog.tmp ; \
hub release create -F chglog.tmp "${VERSION}" ; \
echo "${DOCKERHUB_PASS}" | base64 -d | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin ; \
docker push "${IMAGE_NAME}:latest" ; \
docker push "${IMAGE_NAME}:${VERSION}" ; \
fi ; \
}

.PHONY: local/docker/release
## release: builds operator docker image and pushes it to docker repository
release: build push

Expand Down

0 comments on commit 03bd87f

Please sign in to comment.