diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..317bbb9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,176 @@ +version: 2 +jobs: + aloha: + machine: true + steps: + - run: echo "Aloha! ;-)" + build: + docker: + - image: circleci/golang:1.12 + working_directory: /go/src/github.com/ory/hydra-maester + steps: + - run: + name: Enable go1.12 modules + command: | + echo 'export GO111MODULE=on' >> $BASH_ENV + source $BASH_ENV + - checkout + - run: + name: Fetch kube-builder + command: | + os=$(go env GOOS) + arch=$(go env GOARCH) + + # download kubebuilder and extract it to tmp + curl -sL https://go.kubebuilder.io/dl/2.0.0-alpha.4/${os}/${arch} | tar -xz -C /tmp/ + + # move to a long-term location and put it on your path + # (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else) + sudo mv /tmp/kubebuilder_2.0.0-alpha.4_${os}_${arch} /usr/local/kubebuilder + export PATH=$PATH:/usr/local/kubebuilder/bin + + - run: make + test: + docker: + - image: circleci/golang:1.12 + environment: + - GO111MODULE=on + working_directory: /go/src/github.com/ory/hydra-maester + steps: + - checkout + - run: + name: Fetch kube-builder + command: | + os=$(go env GOOS) + arch=$(go env GOARCH) + + # download kubebuilder and extract it to tmp + curl -sL https://go.kubebuilder.io/dl/2.0.0-alpha.4/${os}/${arch} | tar -xz -C /tmp/ + + # move to a long-term location and put it on your path + # (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else) + sudo mv /tmp/kubebuilder_2.0.0-alpha.4_${os}_${arch} /usr/local/kubebuilder + export PATH=$PATH:/usr/local/kubebuilder/bin + - run: make test + test-integration: + machine: true + steps: + - checkout + - run: + name: Update golang + command: | + sudo rm -rf /usr/local/go/ + curl -LO https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.12.7.linux-amd64.tar.gz + sudo echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile + go version + + - run: + name: Download kube-builder + command: | + os=$(go env GOOS) + arch=$(go env GOARCH) + + # download kubebuilder and extract it to tmp + curl -sL https://go.kubebuilder.io/dl/2.0.0-alpha.4/${os}/${arch} | tar -xz -C /tmp/ + + # move to a long-term location and put it on your path + # (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else) + sudo mv /tmp/kubebuilder_2.0.0-alpha.4_${os}_${arch} /usr/local/kubebuilder + sudo echo "export PATH=$PATH:/usr/local/kubebuilder/bin" >> $HOME/.profile + + - run: + name: Install ginkgo,controller-gen, kustomize + command: | + go get github.com/onsi/ginkgo/ginkgo + go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0-beta.2 + go install sigs.k8s.io/kustomize/v3/cmd/kustomize + + - run: + name: Install Kind + command: | + curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.4.0/kind-linux-amd64 + chmod +x ./kind + sudo mv ./kind /usr/local/bin/kind + - run: + name: Install kubectl + command: | + 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/kubectl + export KUBECONFIG=$(kind get kubeconfig-path) + - run: + name: Run integration tests + command: make test-integration + + release: + docker: + - image: circleci/golang:1.12 + environment: + - GO111MODULE=on + working_directory: /go/src/github.com/ory/hydra-maester + steps: + - checkout + - run: + command: | + echo 'export DOCKER_FULL_TAG=$(echo $CIRCLE_TAG | tr '+' '_')' >> $BASH_ENV + echo 'export DOCKER_SHORT_TAG=$(echo $CIRCLE_TAG | cut -d '+' -f1)' >> $BASH_ENV + ./.circleci/release_name.bash + source $BASH_ENV + - setup_remote_docker + - run: docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" + - run: curl -sL https://git.io/goreleaser | bash + + release-changelog: + docker: + - image: circleci/ruby:2.4-node + steps: + - checkout + - run: gem install github_changelog_generator + - run: sudo npm i -g doctoc + - run: github_changelog_generator -u ory -p hydra-maester -o CHANGELOG.md --token $GITHUB_TOKEN + - run: doctoc CHANGELOG.md + - run: doctoc README.md + - run: git config --global user.email "circleci@ory.am" + - run: git config --global user.name "ORY Continuous Integration" + - run: git add CHANGELOG.md + - run: git add README.md + - run: | + git commit -a -m "docs: Incorporates changes from version $(git describe --tags)" || true + - run: git remote rm origin + - run: git remote add origin https://arekkas:$GITHUB_TOKEN@github.com/ory/hydra-maester.git + - run: git push origin HEAD:master || true + +workflows: + version: 2 + "test, build and release": + jobs: +# ENABLE IT once controller with make target will be created +# - build: +# filters: +# tags: +# only: /.*/ +# - test-integration: +# filters: +# tags: +# only: /.*/ +# - test: +# filters: +# tags: +# only: /.*/ +# - release: +# requires: +# - test +# filters: +# tags: +# only: /.*/ +# branches: +# ignore: /.*/ +# - release-changelog: +# requires: +# - release +# filters: +# tags: +# only: /.*/ +# branches: +# ignore: /.*/ diff --git a/.circleci/release_name.bash b/.circleci/release_name.bash new file mode 100755 index 0000000..20c106f --- /dev/null +++ b/.circleci/release_name.bash @@ -0,0 +1,13 @@ +#!/bin/bash + +release=$(curl -s "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases") +tag=$(echo ${release} | jq -r ".[0].tag_name") +tag_name=$(echo ${release} | jq -r ".[0].name") + +if [[ -n "$tag_name" ]]; then + echo "export RELEASE_NAME=$tag_name" >> $BASH_ENV +elif [[ -n "$tag" ]]; then + echo "export RELEASE_NAME=$tag" >> $BASH_ENV +else + echo "export RELEASE_NAME=$CIRCLE_SHA1" >> $BASH_ENV +fi