Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CI and e2e testing #218

Merged
merged 34 commits into from
Jun 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b5f73d6
Add version command
stefanprodan Jun 21, 2019
0147aea
Build binary and container in CircleCI
stefanprodan Jun 21, 2019
8957994
CircleCI - set job deps
stefanprodan Jun 21, 2019
7ca2558
CircleCI - fix config
stefanprodan Jun 21, 2019
4d5876f
CircleCI - fix job name
stefanprodan Jun 21, 2019
66d662c
CircleCI - fix working_directory
stefanprodan Jun 21, 2019
c3b7aee
CircleCI - make workspace dir
stefanprodan Jun 21, 2019
83b8ae4
CircleCI - copy bin to workspace dir
stefanprodan Jun 21, 2019
991e01e
CircleCI - fix container build
stefanprodan Jun 21, 2019
9b67b36
CircleCI - build and push container
stefanprodan Jun 21, 2019
1911143
CircleCI - run go test
stefanprodan Jun 21, 2019
c0fe461
CircleCI - push to Docker Hub
stefanprodan Jun 21, 2019
4f0ad7a
CircleCI - run Istio e2e
stefanprodan Jun 21, 2019
cf25a9a
CircleCI - fix config
stefanprodan Jun 21, 2019
f4bb0ea
CircleCI - add codecov
stefanprodan Jun 21, 2019
48834cd
CircleCI - refactor Istio e2e testing
stefanprodan Jun 21, 2019
767be5b
CircleCI - reset go mod cache
stefanprodan Jun 21, 2019
31b3fcf
CircleCI - refactor e2e tests
stefanprodan Jun 21, 2019
c744564
CircleCI - install Tiller after Kind create
stefanprodan Jun 21, 2019
a6b2b12
CircleCI - add goreleaser job
stefanprodan Jun 21, 2019
2973822
CircleCI - test goreleaser job
stefanprodan Jun 21, 2019
240591a
CircleCI - run goreleaser
stefanprodan Jun 21, 2019
91cd264
CircleCI - run goreleaser for git tags
stefanprodan Jun 21, 2019
6fe6a41
CircleCI - cleanup branch filters
stefanprodan Jun 21, 2019
cf41f9a
CircleCI - fix deprecated goreleaser config
stefanprodan Jun 21, 2019
0959406
Remove vendor dir
stefanprodan Jun 21, 2019
cbdc7ef
Build and run k8s code gen with go modules
stefanprodan Jun 21, 2019
6363580
Fix k8s code gen
stefanprodan Jun 21, 2019
bea22c0
CircleCI: run go mod download
stefanprodan Jun 21, 2019
0bbe724
CircleCI: chmod k8s code gen
stefanprodan Jun 21, 2019
a894a7a
CircleCI: update code gen package
stefanprodan Jun 21, 2019
6a8aef8
CircleCI: workaround for code gen
stefanprodan Jun 21, 2019
d059191
Update k8s packages
stefanprodan Jun 21, 2019
0d4d2ac
CircleCI: Build and push load tester
stefanprodan Jun 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
146 changes: 112 additions & 34 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,164 @@
version: 2.1
jobs:

build-binary:
docker:
- image: circleci/golang:1.12
working_directory: ~/build
steps:
- checkout
- restore_cache:
keys:
- go-mod-v3-{{ checksum "go.sum" }}
- run:
name: Run go fmt
command: make test-fmt
- run:
name: Build Flagger
command: |
CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-s -w -X github.com/weaveworks/flagger/pkg/version.REVISION=${CIRCLE_SHA1}" \
-a -installsuffix cgo -o bin/flagger ./cmd/flagger/*.go
- run:
name: Build Flagger load tester
command: |
CGO_ENABLED=0 GOOS=linux go build \
-a -installsuffix cgo -o bin/loadtester ./cmd/loadtester/*.go
- run:
name: Run unit tests
command: |
go test -race -coverprofile=coverage.txt -covermode=atomic $(go list ./pkg/...)
bash <(curl -s https://codecov.io/bash)
- run:
name: Verify code gen
command: make test-codegen
- save_cache:
key: go-mod-v3-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod/"
- persist_to_workspace:
root: bin
paths:
- flagger
- loadtester

push-container:
docker:
- image: circleci/golang:1.12
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- attach_workspace:
at: /tmp/bin
- run: test/container-build.sh
- run: test/container-push.sh

push-binary:
docker:
- image: circleci/golang:1.12
working_directory: ~/build
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- restore_cache:
keys:
- go-mod-v3-{{ checksum "go.sum" }}
- run: test/goreleaser.sh

e2e-istio-testing:
machine: true
steps:
- checkout
- attach_workspace:
at: /tmp/bin
- run: test/container-build.sh
- run: test/e2e-kind.sh
- run: test/e2e-istio.sh
- run: test/e2e-istio-build.sh
- run: test/e2e-tests.sh

e2e-smi-istio-testing:
machine: true
steps:
- checkout
- attach_workspace:
at: /tmp/bin
- run: test/container-build.sh
- run: test/e2e-kind.sh
- run: test/e2e-istio.sh
- run: test/e2e-smi-istio-build.sh
- run: test/e2e-smi-istio.sh
- run: test/e2e-tests.sh canary

e2e-supergloo-testing:
machine: true
steps:
- checkout
- attach_workspace:
at: /tmp/bin
- run: test/container-build.sh
- run: test/e2e-kind.sh
- run: test/e2e-supergloo.sh
- run: test/e2e-build.sh supergloo:test.supergloo-system
- run: test/e2e-tests.sh canary

e2e-gloo-testing:
machine: true
steps:
- checkout
- attach_workspace:
at: /tmp/bin
- run: test/container-build.sh
- run: test/e2e-kind.sh
- run: test/e2e-gloo.sh
- run: test/e2e-gloo-build.sh
- run: test/e2e-gloo-tests.sh

e2e-nginx-testing:
machine: true
steps:
- checkout
- attach_workspace:
at: /tmp/bin
- run: test/container-build.sh
- run: test/e2e-kind.sh
- run: test/e2e-nginx.sh
- run: test/e2e-nginx-build.sh
- run: test/e2e-nginx-tests.sh

workflows:
version: 2
build-and-test:
build-test-push:
jobs:
- e2e-istio-testing:
- build-binary:
filters:
branches:
ignore:
- /gh-pages.*/
- /docs-.*/
- /release-.*/
- gh-pages
- e2e-istio-testing:
requires:
- build-binary
- e2e-smi-istio-testing:
filters:
branches:
ignore:
- /gh-pages.*/
- /docs-.*/
- /release-.*/
requires:
- build-binary
- e2e-supergloo-testing:
filters:
branches:
ignore:
- /gh-pages.*/
- /docs-.*/
- /release-.*/
- e2e-nginx-testing:
filters:
branches:
ignore:
- /gh-pages.*/
- /docs-.*/
- /release-.*/
requires:
- build-binary
- e2e-gloo-testing:
requires:
- build-binary
- e2e-nginx-testing:
requires:
- build-binary
- push-container:
requires:
- build-binary
- e2e-istio-testing
- e2e-smi-istio-testing
- e2e-supergloo-testing
- e2e-gloo-testing
- e2e-nginx-testing
- push-binary:
requires:
- push-container
filters:
branches:
ignore:
- /gh-pages.*/
- /docs-.*/
- /release-.*/
ignore: /.*/
tags:
only: /[0-9]+(\.[0-9]+)*(-.*)*/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
.DS_Store

bin/
_tmp/

artifacts/gcloud/
.idea
12 changes: 8 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ builds:
- amd64
env:
- CGO_ENABLED=0
archive:
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
files:
- none*
archives:
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
files:
- none*
changelog:
filters:
exclude:
- '^CircleCI'
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

17 changes: 1 addition & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
FROM golang:1.12

RUN mkdir -p /go/src/github.com/weaveworks/flagger/

WORKDIR /go/src/github.com/weaveworks/flagger

COPY . .

#RUN GO111MODULE=on go mod download

RUN GIT_COMMIT=$(git rev-list -1 HEAD) && \
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -mod=vendor -ldflags "-s -w \
-X github.com/weaveworks/flagger/pkg/version.REVISION=${GIT_COMMIT}" \
-a -installsuffix cgo -o flagger ./cmd/flagger/*

FROM alpine:3.9

RUN addgroup -S flagger \
Expand All @@ -21,7 +6,7 @@ RUN addgroup -S flagger \

WORKDIR /home/flagger

COPY --from=0 /go/src/github.com/weaveworks/flagger/flagger .
COPY /bin/flagger .

RUN chown -R flagger:flagger ./

Expand Down
14 changes: 1 addition & 13 deletions Dockerfile.loadtester
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
FROM golang:1.12 AS builder

RUN mkdir -p /go/src/github.com/weaveworks/flagger/

WORKDIR /go/src/github.com/weaveworks/flagger

COPY . .

RUN go test -race ./pkg/loadtester/

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o loadtester ./cmd/loadtester/*

FROM bats/bats:v1.1.0

RUN addgroup -S app \
Expand All @@ -25,7 +13,7 @@ RUN curl -sSL "https://get.helm.sh/helm-v2.12.3-linux-amd64.tar.gz" | tar xvz &&
chmod +x linux-amd64/helm && mv linux-amd64/helm /usr/local/bin/helm && \
rm -rf linux-amd64

COPY --from=builder /go/src/github.com/weaveworks/flagger/loadtester .
COPY ./bin/loadtester .

RUN chown -R app:app ./

Expand Down
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,36 @@ TAG?=latest
VERSION?=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"')
VERSION_MINOR:=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"' | rev | cut -d'.' -f2- | rev)
PATCH:=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"' | awk -F. '{print $$NF}')
SOURCE_DIRS = cmd pkg/apis pkg/controller pkg/server pkg/logging pkg/version
SOURCE_DIRS = cmd pkg/apis pkg/controller pkg/server pkg/canary pkg/metrics pkg/router pkg/notifier
LT_VERSION?=$(shell grep 'VERSION' cmd/loadtester/main.go | awk '{ print $$4 }' | tr -d '"' | head -n1)
TS=$(shell date +%Y-%m-%d_%H-%M-%S)

run:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=istio -namespace=test \
GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=istio -namespace=test \
-metrics-server=https://prometheus.istio.weavedx.com

run-appmesh:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=appmesh \
GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=appmesh \
-metrics-server=http://acfc235624ca911e9a94c02c4171f346-1585187926.us-west-2.elb.amazonaws.com:9090

run-nginx:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=nginx -namespace=nginx \
GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=nginx -namespace=nginx \
-metrics-server=http://prometheus-weave.istio.weavedx.com

run-smi:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=smi:istio -namespace=smi \
GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=smi:istio -namespace=smi \
-metrics-server=https://prometheus.istio.weavedx.com

run-gloo:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=gloo -namespace=gloo \
GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=gloo -namespace=gloo \
-metrics-server=https://prometheus.istio.weavedx.com

run-nop:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=none -namespace=bg \
GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=none -namespace=bg \
-metrics-server=https://prometheus.istio.weavedx.com

build:
GIT_COMMIT=$$(git rev-list -1 HEAD) && GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w -X github.com/weaveworks/flagger/pkg/version.REVISION=$${GIT_COMMIT}" -a -installsuffix cgo -o ./bin/flagger ./cmd/flagger/*
docker build -t weaveworks/flagger:$(TAG) . -f Dockerfile

push:
Expand Down Expand Up @@ -100,11 +101,14 @@ reset-test:
kubectl apply -f ./artifacts/namespaces
kubectl apply -f ./artifacts/canaries

loadtester-run:
loadtester-run: loadtester-build
docker build -t weaveworks/flagger-loadtester:$(LT_VERSION) . -f Dockerfile.loadtester
docker rm -f tester || true
docker run -dp 8888:9090 --name tester weaveworks/flagger-loadtester:$(LT_VERSION)

loadtester-build:
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./bin/loadtester ./cmd/loadtester/*

loadtester-push:
docker build -t weaveworks/flagger-loadtester:$(LT_VERSION) . -f Dockerfile.loadtester
docker push weaveworks/flagger-loadtester:$(LT_VERSION)
Loading