Skip to content

Instantly share code, notes, and snippets.

@snormore
Last active February 16, 2023 09:57
Show Gist options
  • Select an option

  • Save snormore/36eb05b675f399af6b18e960488440e4 to your computer and use it in GitHub Desktop.

Select an option

Save snormore/36eb05b675f399af6b18e960488440e4 to your computer and use it in GitHub Desktop.
Golang with kind (Kubernetes-in-Docker) on CircleCI
version: 2
jobs:
build:
working_directory: /go/src/github.com/your_company/your_project
docker:
- image: golang:1.11
environment:
- GOCACHE: "/tmp/go/cache"
- DEP_VERSION: 0.4.1
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Install Docker Client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- restore_cache:
key: gopkg-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
paths:
- /go/src/github.com/your_comany/your_projecte/vendor
- run:
name: Install Golang Packages
command: |
if [ ! -d /go/src/github.com/your_comany/your_projecte/vendor ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
/go/bin/dep ensure
fi
- save_cache:
key: gopkg-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
paths:
- /go/src/github.com/your_comany/your_projecte/vendor
- restore_cache:
keys:
- build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
paths:
- /tmp/go/cache
- run:
name: Setup Kubernetes Cluster (kind)
command: |
go get github.com/kubernetes-sigs/kind
kind create cluster --name="1"
export KUBECONFIG="$(kind get kubeconfig-path --name="1")"
- run:
name: Run Tests
command: make test
- run:
name: Build
command: make build
- save_cache:
key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_BUILD_NUM }}
paths:
- /tmp/go/cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment