Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
160 lines (157 sloc) 5.37 KB
version: 2
## Definitions
build_allways: &build_allways
filters:
tags:
only: /.*/
defaults: &defaults
working_directory: /home/circleci/.go_workspace/src/github.com/kubeless/kafka-trigger
environment:
GOPATH: /home/circleci/.go_workspace
CONTROLLER_IMAGE_NAME: bitnami/kubeless-controller-manager
KAFKA_CONTROLLER_IMAGE_NAME: bitnami/kafka-trigger-controller
CGO_ENABLED: "0"
TEST_DEBUG: "1"
MINIKUBE_VERSION: v0.25.2
MANIFESTS: kafka-zookeeper kafka-zookeeper-openshift
exports: &exports
# It is not possible to resolve env vars in the environment section:
# https://discuss.circleci.com/t/using-environment-variables-in-config-yml-not-working/14237
run: |
CONTROLLER_TAG=${CIRCLE_TAG:-build-$CIRCLE_WORKFLOW_ID}
echo "export CONTROLLER_TAG=${CONTROLLER_TAG}" >> $BASH_ENV
echo "export CONTROLLER_IMAGE=${CONTROLLER_IMAGE_NAME}:${CONTROLLER_TAG}" >> $BASH_ENV
echo "export KAFKA_CONTROLLER_IMAGE=${KAFKA_CONTROLLER_IMAGE_NAME}:${CONTROLLER_TAG}" >> $BASH_ENV
echo "export KUBECFG_JPATH=/home/circleci/src/github.com/kubeless/kafka-trigger/ksonnet-lib" >> $BASH_ENV
echo "export PATH=$(pwd)/bats/libexec:$PATH" >> $BASH_ENV
restore_workspace: &restore_workspace
run: |
make bootstrap
sudo cp -r /tmp/go/bin/* /usr/local/bin/
cp -r /tmp/go/src/github.com/kubeless/kafka-trigger/build-manifests/*yaml .
should_test: &should_test
run: |
case $CIRCLE_JOB in
# In kase of minikube+kafka we want to test it if
# it is a Pull Request related to Kafka (discovered from the PR title)
# or if the build is from the "master" branch
minikube_kafka)
if [[ -n "$CIRCLE_PULL_REQUESTS" ]]; then
pr_kafka_title=$(curl -H "Authorization: token $ACCESS_TOKEN" "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/${CIRCLE_PR_NUMBER}" | grep title || true)
fi
if [[ -z "$CIRCLE_PULL_REQUESTS" || "$pr_kafka_title" == "" || "$pr_kafka_title" =~ ^.*(Kafka|kafka|KAFKA).*$ ]]; then
export SHOULD_TEST=1
fi
;;
esac
echo "Should test? $SHOULD_TEST"
if [[ "$SHOULD_TEST" != "1" ]]; then
circleci step halt
fi
#### End of definitions
workflows:
version: 2
kubeless:
jobs:
- build:
<<: *build_allways
- minikube_kafka:
<<: *build_allways
requires:
- build
- push_latest_images:
filters:
branches:
only: master
requires:
- minikube_kafka
- release:
filters:
tags:
only: /v.*/
branches:
ignore: /.*/
requires:
- minikube_kafka
jobs:
build:
<<: *defaults
docker:
- image: circleci/golang:1.9
steps:
- checkout
- <<: *exports
# go build creates files under /usr/local/go where the running user doesn't have permissions to write
- run: sudo chown -R circleci:circleci /usr/local/go/
- run: make bootstrap
- run: mkdir build-manifests
# Install kubeless required files
- run: |
git clone https://github.com/kubeless/kubeless.git $GOPATH/src/github.com/kubeless/kubeless
ln -s $(pwd)/ksonnet-lib $GOPATH/src/github.com/kubeless/kubeless/ksonnet-lib
cd $GOPATH/src/github.com/kubeless/kubeless
make binary
make all-yaml
cd -
cp $GOPATH/src/github.com/kubeless/kubeless/kubeless-non-rbac.yaml $GOPATH/src/github.com/kubeless/kubeless/kubeless.yaml build-manifests/
- run: make VERSION=${CONTROLLER_TAG} binary
- run: make test
- run: make validation
- run: make all-yaml
- run: |
IFS=' ' read -r -a manifests <<< "$MANIFESTS"
for f in "${manifests[@]}"; do
sed -i.bak 's/:latest/'":${CONTROLLER_TAG}"'/g' ${f}.yaml
cp ${f}.yaml build-manifests/
done
- persist_to_workspace:
root: /home/circleci/.go_workspace
paths:
- bin
- src/github.com/kubeless/kafka-trigger/build-manifests/*yaml
- store_artifacts:
path: /home/circleci/.go_workspace/bin/kubeless
- store_artifacts:
path: build-manifests
minikube_kafka:
<<: *defaults
machine: true
steps:
- <<: *should_test
- checkout
- <<: *exports
- attach_workspace:
at: /tmp/go
- <<: *restore_workspace
- run: ./script/pull-or-build-image.sh kafka-controller-image
- run: ./script/integration-tests minikube deployment
- run: ./script/integration-tests minikube kafka
push_latest_images:
<<: *defaults
docker:
- image: circleci/golang:1.9
steps:
- <<: *exports
- setup_remote_docker
- run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
- run: |
images=(
$KAFKA_CONTROLLER_IMAGE_NAME
)
for image in "${images[@]}"; do
echo "Pulling ${image}:${CONTROLLER_TAG}"
docker pull ${image}:${CONTROLLER_TAG}
docker tag ${image}:${CONTROLLER_TAG} ${image}:latest
docker push ${image}:latest
done
release:
<<: *defaults
docker:
- image: circleci/golang:1.9
steps:
- <<: *exports
- checkout
- attach_workspace:
at: /tmp/go
- <<: *restore_workspace
- run: ./script/create_release.sh ${CIRCLE_TAG} "${MANIFESTS}"