Skip to content
Permalink
Browse files

ci: break pipeline down into smaller bits

Among other things, this makes it easier to mix and match bits of the CI
pipeline, either for developers to run it on their machines, or to build
different pipelines using the same scripts, if need be.
  • Loading branch information...
juliogreff committed Aug 5, 2019
1 parent de90030 commit eb32bf37df78c4d83acad4c5b496739879d4925c
Showing with 70 additions and 54 deletions.
  1. +1 −3 .gitignore
  2. +1 −0 .golangci.yml
  3. +1 −3 .travis.yml
  4. +2 −2 Dockerfile.helm
  5. +1 −1 Dockerfile.shipper
  6. +1 −1 Dockerfile.shipper-state-metrics
  7. +33 −7 Makefile
  8. +1 −3 ci/build.sh
  9. +13 −21 ci/e2e.sh
  10. +1 −6 ci/helm.yaml
  11. +12 −0 ci/helm_svc.yaml
  12. +1 −7 ci/test.sh
  13. +2 −0 kubernetes/shipper.deployment.yaml
@@ -5,9 +5,7 @@ pkg/chart/testdata/index.yaml
docs/generated

# Binaries generated when building Shipper
./shipper
./shipper-state-metrics
./e2e.test
build/

# IntelliJ IDE auto generated files
.idea/**
@@ -1,4 +1,5 @@
run:
deadline: 600s
skip-dirs:
- pkg/apis/shipper/v1alpha1
- pkg/clients
@@ -6,8 +6,6 @@ sudo: required
dist: xenial
services:
- docker
env:
- RESYNC_PERIOD=30s GOFLAGS=-mod=vendor

before_install:
- sudo snap install microk8s --classic --channel=1.14/stable
@@ -23,7 +21,7 @@ before_install:
install: true

script:
- "./ci/test.sh && ./ci/build.sh && ./ci/package.sh"
- "./ci/test.sh && ./ci/build.sh && ./ci/e2e.sh && ./ci/package.sh"

after_success:
- "./ci/build-release-files.sh"
@@ -1,5 +1,5 @@
FROM alpine/helm:2.13.1
FROM alpine/helm:2.14.3

ADD test/e2e/testdata /charts

ENTRYPOINT helm serve --repo-path /charts --address $POD_IP:8879
ENTRYPOINT helm serve --repo-path /charts --address 0.0.0.0:$HELM_SERVICE_PORT --url http://$HELM_SERVICE_HOST:$HELM_SERVICE_PORT
@@ -1,5 +1,5 @@
FROM alpine:3.8
LABEL authors="Parham Doustdar <parham.doustdar@booking.com>, Alexey Surikov <alexey.surikov@booking.com>, Igor Sutton <igor.sutton@booking.com>, Ben Tyler <benjamin.tyler@booking.com>"
RUN apk add ca-certificates
ADD shipper /bin/shipper
ADD build/shipper /bin/shipper
ENTRYPOINT ["shipper", "-disable", "clustersecret", "-v", "4", "-logtostderr"]
@@ -1,5 +1,5 @@
FROM alpine:3.8
LABEL authors="Parham Doustdar <parham.doustdar@booking.com>, Alexey Surikov <alexey.surikov@booking.com>, Igor Sutton <igor.sutton@booking.com>, Ben Tyler <benjamin.tyler@booking.com>"
RUN apk add ca-certificates
ADD shipper-state-metrics /bin/shipper-state-metrics
ADD build/shipper-state-metrics /bin/shipper-state-metrics
ENTRYPOINT ["shipper-state-metrics", "-v", "2"]
@@ -3,18 +3,37 @@ METRICS_IMAGE ?= bookingcom/shipper-state-metrics:latest
HELM_IMAGE ?= bookingcom/shipper-helm:latest
SHIPPER_NAMESPACE ?= shipper-system
KUBECTL ?= kubectl -n $(SHIPPER_NAMESPACE)

PKG = pkg/**/* vendor/**/*

shipper: $(PKG) cmd/shipper/* Dockerfile.shipper
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -o shipper ./cmd/shipper/*.go
export GOFLAGS := -mod=vendor
export GO111MODULE := on
export CGO_ENABLED := 0
export GOARCH := amd64
export GOOS := linux

build/%: cmd/%/*.go $(PKG)
go build -o $@ cmd/$*/*.go

build/e2e.test: $(PKG) test/e2e/*
go test -c ./test/e2e/ -o build/e2e.test

build: build/shipper build/shipperctl build/shipper-state-metrics build/e2e.test

.PHONY: shipper shipper-state-metrics restart logs helm lint test vendor

shipper: build/shipper Dockerfile.shipper
docker build -f Dockerfile.shipper -t $(SHIPPER_IMAGE) --build-arg HTTP_PROXY=$(HTTP_PROXY) --build-arg HTTPS_PROXY=$(HTTPS_PROXY) .
docker push $(SHIPPER_IMAGE)

shipper-state-metrics: $(PKG) cmd/shipper-state-metrics/* Dockerfile.shipper-state-metrics
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -o shipper-state-metrics ./cmd/shipper-state-metrics/*.go
shipper-state-metrics: build/shipper-state-metrics Dockerfile.shipper-state-metrics
docker build -f Dockerfile.shipper-state-metrics -t $(METRICS_IMAGE) --build-arg HTTP_PROXY=$(HTTP_PROXY) --build-arg HTTPS_PROXY=$(HTTPS_PROXY) .
docker push $(METRICS_IMAGE)

helm:
docker build -f Dockerfile.helm -t $(HELM_IMAGE) --build-arg HTTP_PROXY=$(HTTP_PROXY) --build-arg HTTPS_PROXY=$(HTTPS_PROXY) .
docker push $(HELM_IMAGE)

restart:
# Delete all Pods in namespace, to force the ReplicaSet to spawn new ones
# with the new latest image (assuming that imagePullPolicy is set to Always).
@@ -23,6 +42,13 @@ restart:
logs:
$(KUBECTL) get po -o jsonpath='{.items[*].metadata.name}' | xargs $(KUBECTL) logs --follow

helm:
docker build -f Dockerfile.helm -t $(HELM_IMAGE) --build-arg HTTP_PROXY=$(HTTP_PROXY) --build-arg HTTPS_PROXY=$(HTTPS_PROXY) .
docker push $(HELM_IMAGE)
lint:
golangci-lint run -v --config .golangci.yml ./pkg/... ./cmd/... ./test/...

test:
go test -v ./pkg/... ./cmd/...

vendor:
go mod tidy -v
go mod vendor -v
go mod verify
@@ -1,5 +1,3 @@
#!/bin/bash -ex

CGO_ENABLED=0 GOOS=linux go build -v -o shipper cmd/shipper/*.go
CGO_ENABLED=0 GOOS=linux go build -v -o shipper-state-metrics cmd/shipper-state-metrics/*.go
CGO_ENABLED=0 GOOS=linux go build -v -o shipperctl cmd/shipperctl/*.go
make build
@@ -3,35 +3,27 @@
set -e

# Apply cluster configurations for shipper
go run cmd/shipperctl/main.go admin clusters apply -f ci/clusters.yaml
./build/shipperctl admin clusters apply -f ci/clusters.yaml

# Wait for microk8s.registry to be ready, as we're about to use it
REGISTRY_POD=$(kubectl get pod -n container-registry -l app=registry \
-o jsonpath='{.items[0].metadata.name}')
kubectl wait -n container-registry --for=condition=ready pod/$REGISTRY_POD

# Build an image with the test charts and deploy it
HELM_IMAGE=localhost:32000/bookingcom/shipper-helm:latest make helm
sed s=\<HELM_IMAGE\>=localhost:32000/bookingcom/shipper-helm:latest= ci/helm.yaml | \
kubectl apply -f -
kubectl apply -f ci/helm_svc.yaml

# Build an image with shipper and deploy it
SHIPPER_IMAGE=localhost:32000/bookingcom/shipper:latest make shipper
sed s=\<IMAGE\>=localhost:32000/bookingcom/shipper:latest= kubernetes/shipper.deployment.yaml | \
kubectl create -f -
export HELM_IMAGE=${HELM_IMAGE:=localhost:32000/bookingcom/shipper-helm:latest}
export SHIPPER_IMAGE=${SHIPPER_IMAGE:=localhost:32000/bookingcom/shipper:latest}

SHIPPER_POD=$(kubectl get pod -n shipper-system -l app=shipper \
-o jsonpath='{.items[0].metadata.name}')
kubectl wait -n shipper-system --for=condition=ready pod/$SHIPPER_POD
kubectl -n shipper-system logs -f $SHIPPER_POD &
make helm shipper

TESTCHARTS=http://$(kubectl get pod -l app=helm -o jsonpath='{.items[0].status.podIP}'):8879
sed s=\<HELM_IMAGE\>=$HELM_IMAGE= ci/helm.yaml | kubectl apply -f -
sed s=\<IMAGE\>=$SHIPPER_IMAGE= kubernetes/shipper.deployment.yaml | kubectl apply -f -

go test ./test/e2e --test.v --e2e --kubeconfig ~/.kube/config \
TESTCHARTS=http://$(kubectl get service -n shipper-system helm -o jsonpath='{.spec.clusterIP}'):8879
./build/e2e.test --test.v --e2e --kubeconfig ~/.kube/config \
--testcharts $TESTCHARTS --progresstimeout=2m --appcluster microk8s

TEST_STATUS=$?

set +e
SHIPPER_POD=$(kubectl get pod -n shipper-system -l app=shipper \
-o jsonpath='{.items[0].metadata.name}')
kubectl -n shipper-system logs $SHIPPER_POD

set +e
exit $TEST_STATUS
@@ -2,6 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: helm
namespace: shipper-system
spec:
selector:
matchLabels:
@@ -15,9 +16,3 @@ spec:
containers:
- name: app
image: <HELM_IMAGE>
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: helm
namespace: shipper-system
spec:
selector:
app: helm
ports:
- protocol: TCP
port: 8879
targetPort: 8879
@@ -4,10 +4,4 @@ go mod verify

./hack/verify-codegen.sh

PKGS="./pkg/... ./cmd/... ./test/..."

golangci-lint run --config .golangci.yml $PKGS

go test -v $PKGS

./ci/e2e.sh "$RESYNC_PERIOD"
make lint test
@@ -25,6 +25,8 @@ spec:
- "/etc/webhook/certs/tls.key"
- "-webhook-port"
- "9443"
- "-resync"
- "10m"
ports:
- containerPort: 9443
volumeMounts:

0 comments on commit eb32bf3

Please sign in to comment.
You can’t perform that action at this time.