Skip to content

Commit

Permalink
Merge branch 'master' into client_cardinality
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperQ authored Jun 22, 2023
2 parents c87bbd8 + bf2cc7d commit 61740e9
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v4.0.1
with:
go-version: 1.19
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
python-version: 3.x
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v4.0.1
with:
go-version: 1.19
- name: build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v4.0.1
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Checkout code
Expand All @@ -51,7 +51,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v4.0.1
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
- name: Checkout code
uses: actions/[email protected]
- name: Setup Golang
uses: actions/setup-go@v4
uses: actions/setup-go@v4.0.1
with:
go-version: ${{ env.GOLANG_VERSION }}
# k8s codegen generates files into GOPATH location instead of the GitHub git checkout location
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image-reuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
if: ${{ github.ref_type != 'tag'}}

- name: Setup Golang
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
uses: actions/setup-go@v4.0.1 # v3.5.0
with:
go-version: ${{ inputs.go-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
ref: ${{ github.event.inputs.tag }}

- name: Setup Golang
uses: actions/setup-go@v4
uses: actions/setup-go@v4.0.1
with:
go-version: 1.19

Expand Down
122 changes: 69 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ifdef IMAGE_NAMESPACE
IMAGE_PREFIX=${IMAGE_NAMESPACE}/
endif

# protoc,my.proto
## protoc,my.proto
define protoc
# protoc $(1)
PATH=${DIST_DIR}:$$PATH protoc \
Expand All @@ -66,22 +66,26 @@ endef
.PHONY: all
all: controller image

# downloads vendor files needed by tools.go (i.e. go_install)
##@ Development
.PHONY: go-mod-vendor
go-mod-vendor:
go-mod-vendor: ## downloads vendor files needed by tools.go (i.e. go_install)
go mod tidy
go mod vendor

.PHONY: lint
lint: go-mod-vendor ## run all linters
golangci-lint run --fix

.PHONY: install-go-tools-local
install-go-tools-local: go-mod-vendor
install-go-tools-local: go-mod-vendor ## install all go tools
./hack/installers/install-codegen-go-tools.sh

.PHONY: install-protoc-local
install-protoc-local:
install-protoc-local: ## install protoc tool
./hack/installers/install-protoc.sh

.PHONY: install-devtools-local
install-devtools-local:
install-devtools-local: ## install dev tools
./hack/installers/install-dev-tools.sh

# Installs all tools required to build and test locally
Expand All @@ -94,6 +98,8 @@ APIMACHINERY_PKGS=k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/a
.PHONY: install-toolchain
install-toolchain: install-go-tools-local install-protoc-local

##@ Code Generation

# generates all auto-generated code
.PHONY: codegen
codegen: go-mod-vendor gen-proto gen-k8scodegen gen-openapi gen-mocks gen-crd manifests docs
Expand All @@ -104,7 +110,7 @@ gen-proto: k8s-proto api-proto ui-proto

# generates the .proto files affected by changes to types.go
.PHONY: k8s-proto
k8s-proto: go-mod-vendor $(TYPES)
k8s-proto: go-mod-vendor $(TYPES) ## generate kubernetes protobuf files
PATH=${DIST_DIR}:$$PATH go-to-protobuf \
--go-header-file=./hack/custom-boilerplate.go.txt \
--packages=github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1 \
Expand All @@ -117,44 +123,42 @@ k8s-proto: go-mod-vendor $(TYPES)

# generates *.pb.go, *.pb.gw.go, swagger from .proto files
.PHONY: api-proto
api-proto: go-mod-vendor k8s-proto
api-proto: go-mod-vendor k8s-proto ## generate api protobuf files
$(call protoc,pkg/apiclient/rollout/rollout.proto)

# generates ui related proto files
.PHONY: ui-proto
ui-proto:
ui-proto: ## generate ui protobuf files
yarn --cwd ui run protogen

# generates k8s client, informer, lister, deepcopy from types.go
.PHONY: gen-k8scodegen
gen-k8scodegen: go-mod-vendor
gen-k8scodegen: go-mod-vendor ## generate kubernetes codegen files
./hack/update-codegen.sh

# generates ./manifests/crds/
.PHONY: gen-crd
gen-crd: install-go-tools-local
gen-crd: install-go-tools-local ## generate crd manifests
go run ./hack/gen-crd-spec/main.go

# generates mock files from interfaces
.PHONY: gen-mocks
gen-mocks: install-go-tools-local
gen-mocks: install-go-tools-local ## generate mock files
./hack/update-mocks.sh

# generates openapi_generated.go
.PHONY: gen-openapi
gen-openapi: $(DIST_DIR)/openapi-gen
gen-openapi: $(DIST_DIR)/openapi-gen ## generate openapi files
PATH=${DIST_DIR}:$$PATH openapi-gen \
--go-header-file ${CURRENT_DIR}/hack/custom-boilerplate.go.txt \
--input-dirs github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1 \
--output-package github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1 \
--report-filename pkg/apis/api-rules/violation_exceptions.list

.PHONY: controller
controller:
CGO_ENABLED=0 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/rollouts-controller ./cmd/rollouts-controller
##@ Plugins

.PHONY: plugin
plugin: ui/dist
plugin: ui/dist ## build plugin
cp -r ui/dist/app/* server/static
CGO_ENABLED=0 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME} ./cmd/kubectl-argo-rollouts

Expand All @@ -163,28 +167,30 @@ ui/dist:
yarn --cwd ui build

.PHONY: plugin-linux
plugin-linux: ui/dist
plugin-linux: ui/dist ## build plugin for linux
cp -r ui/dist/app/* server/static
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-linux-amd64 ./cmd/kubectl-argo-rollouts
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-linux-arm64 ./cmd/kubectl-argo-rollouts

.PHONY: plugin-darwin
plugin-darwin: ui/dist
plugin-darwin: ui/dist ## build plugin for darwin
cp -r ui/dist/app/* server/static
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-darwin-amd64 ./cmd/kubectl-argo-rollouts
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-darwin-arm64 ./cmd/kubectl-argo-rollouts

.PHONY: plugin-windows
plugin-windows: ui/dist
plugin-windows: ui/dist ## build plugin for windows
cp -r ui/dist/app/* server/static
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-windows-amd64 ./cmd/kubectl-argo-rollouts

.PHONY: docs
docs:
go run ./hack/gen-docs/main.go
##@ Build

.PHONY: controller
controller: ## build controller binary
CGO_ENABLED=0 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/rollouts-controller ./cmd/rollouts-controller

.PHONY: builder-image
builder-image:
builder-image: ## build builder image
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)argo-rollouts-ci-builder:$(IMAGE_TAG) --target builder .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argo-rollouts:$(IMAGE_TAG) ; fi

Expand All @@ -198,95 +204,105 @@ else
endif
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argo-rollouts:$(IMAGE_TAG) ; fi


# Build sample plugin with debug info
# https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html
.PHONY: build-sample-metric-plugin-debug
build-sample-metric-plugin-debug: ## build sample metric plugin with debug info
go build -gcflags="all=-N -l" -o metric-plugin test/cmd/metrics-plugin-sample/main.go

.PHONY: build-sample-traffic-plugin-debug
build-sample-traffic-plugin-debug: ## build sample traffic plugin with debug info
go build -gcflags="all=-N -l" -o traffic-plugin test/cmd/trafficrouter-plugin-sample/main.go

.PHONY: plugin-image
plugin-image:
plugin-image: ## build plugin image
DOCKER_BUILDKIT=1 docker build --target kubectl-argo-rollouts -t $(IMAGE_PREFIX)kubectl-argo-rollouts:$(IMAGE_TAG) .
if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)kubectl-argo-rollouts:$(IMAGE_TAG) ; fi

.PHONY: lint
lint: go-mod-vendor
golangci-lint run --fix
##@ Test

.PHONY: test
test: test-kustomize
test: test-kustomize ## run all tests
@make test-unit

.PHONY: test-kustomize
test-kustomize:
test-kustomize: ## run kustomize tests
./test/kustomize/test.sh

.PHONY: start-e2e
start-e2e:
start-e2e: ## start e2e test environment
go run ./cmd/rollouts-controller/main.go --instance-id ${E2E_INSTANCE_ID} --loglevel debug --kloglevel 6

.PHONY: test-e2e
test-e2e: install-devtools-local
${DIST_DIR}/gotestsum --rerun-fails-report=rerunreport.txt --junitfile=junit.xml --format=testname --packages="./test/e2e" --rerun-fails=5 -- -timeout 60m -count 1 --tags e2e -p ${E2E_PARALLEL} -parallel ${E2E_PARALLEL} -v --short ./test/e2e ${E2E_TEST_OPTIONS}

.PHONY: test-unit
test-unit: install-devtools-local
test-unit: install-devtools-local ## run unit tests
${DIST_DIR}/gotestsum --junitfile=junit.xml --format=testname -- -covermode=count -coverprofile=coverage.out `go list ./... | grep -v ./test/cmd/metrics-plugin-sample`


.PHONY: coverage
coverage: test
coverage: test ## run coverage tests
go tool cover -html=coverage.out -o coverage.html
open coverage.html

.PHONY: manifests
manifests:
manifests: ## generate manifests e.g. CRD, RBAC etc.
./hack/update-manifests.sh

.PHONY: clean
clean:
clean: ## clean up build artifacts
-rm -rf ${CURRENT_DIR}/dist
-rm -rf ${CURRENT_DIR}/ui/dist

.PHONY: precheckin
precheckin: test lint

##@ Docs

# convenience target to run `mkdocs serve` using a docker container
.PHONY: serve-docs
serve-docs: docs ## serve docs locally
docker run --rm -it -p 8000:8000 -v ${CURRENT_DIR}:/docs squidfunk/mkdocs-material serve -a 0.0.0.0:8000

.PHONY: docs
docs: ## build docs
go run ./hack/gen-docs/main.go

##@ Release

.PHONY: release-docs
release-docs: docs
release-docs: docs ## build and deploy docs
docker run --rm -it \
-v ~/.ssh:/root/.ssh \
-v ${CURRENT_DIR}:/docs \
-v ~/.gitconfig:/root/.gitconfig \
squidfunk/mkdocs-material gh-deploy -r ${GIT_REMOTE_REPO}

# convenience target to run `mkdocs serve` using a docker container
.PHONY: serve-docs
serve-docs: docs
docker run --rm -it -p 8000:8000 -v ${CURRENT_DIR}:/docs squidfunk/mkdocs-material serve -a 0.0.0.0:8000

.PHONY: release-precheck
release-precheck: manifests
release-precheck: manifests ## precheck release
@if [ "$(GIT_TREE_STATE)" != "clean" ]; then echo 'git tree state is $(GIT_TREE_STATE)' ; exit 1; fi
@if [ -z "$(GIT_TAG)" ]; then echo 'commit must be tagged to perform release' ; exit 1; fi
@if [ "$(GIT_TAG)" != "v`cat VERSION`" ]; then echo 'VERSION does not match git tag'; exit 1; fi

.PHONY: release-plugins
release-plugins:
release-plugins: ## build and push plugins
./hack/build-release-plugins.sh

.PHONY: release
release: release-precheck precheckin image plugin-image release-plugins

.PHONY: trivy
trivy:
trivy: ## run trivy scan
@trivy fs --clear-cache
@trivy fs .

.PHONY: checksums
checksums:
shasum -a 256 ./dist/kubectl-argo-rollouts-* | awk -F './dist/' '{print $$1 $$2}' > ./dist/argo-rollouts-checksums.txt

# Build sample plugin with debug info
# https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html
.PHONY: build-sample-metric-plugin-debug
build-sample-metric-plugin-debug:
go build -gcflags="all=-N -l" -o metric-plugin test/cmd/metrics-plugin-sample/main.go

.PHONY: build-sample-traffic-plugin-debug
build-sample-traffic-plugin-debug:
go build -gcflags="all=-N -l" -o traffic-plugin test/cmd/trafficrouter-plugin-sample/main.go

help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2 v1.18.1
github.com/aws/aws-sdk-go-v2/config v1.18.27
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.26.2
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.19.12
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.19.13
github.com/blang/semver v3.5.1+incompatible
github.com/bombsimon/logrusr/v4 v4.0.0
github.com/evanphx/json-patch/v5 v5.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 h1:LWA+3kDM8ly001vJ1X1waCuLJdt
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35/go.mod h1:0Eg1YjxE0Bhn56lx+SHJwCzhW+2JGtizsrx+lCqrfm0=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.26.2 h1:PWGu2JhCb/XJlJ7SSFJq76pxk4xWsN76nZxh7TzMHx0=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.26.2/go.mod h1:2KOZkkzMDZCo/aLzPhys06mHNkiU74u85aMJA3PLRvg=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.19.12 h1:CeJNl5G6Y3+VYbZHczL/I2rsvQDBsNkhEOm98eo2eVo=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.19.12/go.mod h1:BNkuX97Xp8meRKwZkWlXajo3u4cP/B3TC+YsadbOfaM=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.19.13 h1:g/Kzed9qNdvz5p7Av3ffavD19eN11deWqlHgR2JuXuw=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.19.13/go.mod h1:BNkuX97Xp8meRKwZkWlXajo3u4cP/B3TC+YsadbOfaM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 h1:bkRyG4a929RCnpVSTvLM2j/T4ls015ZhhYApbmYs15s=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28/go.mod h1:jj7znCIg05jXlaGBlFMGP8+7UN3VtCkRBG2spnmRQkU=
github.com/aws/aws-sdk-go-v2/service/sso v1.12.12 h1:nneMBM2p79PGWBQovYO/6Xnc2ryRMw3InnDJq1FHkSY=
Expand Down

0 comments on commit 61740e9

Please sign in to comment.