Skip to content

Commit

Permalink
build: simplify using Golang 1.16 (argoproj#6893)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: kriti-sc <kathuriakriti1@gmail.com>
  • Loading branch information
alexec authored and kriti-sc committed Oct 24, 2021
1 parent 8d60417 commit 9aca97e
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 134 deletions.
53 changes: 16 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ SWAGGER_FILES := pkg/apiclient/_.primary.swagger.json \
pkg/apiclient/workflowtemplate/workflow-template.swagger.json
PROTO_BINARIES := $(GOPATH)/bin/protoc-gen-gogo $(GOPATH)/bin/protoc-gen-gogofast $(GOPATH)/bin/goimports $(GOPATH)/bin/protoc-gen-grpc-gateway $(GOPATH)/bin/protoc-gen-swagger

# go_install,path
define go_install
go mod vendor
go install -mod=vendor ./vendor/$(1)
endef

# protoc,my.proto
define protoc
# protoc $(1)
Expand Down Expand Up @@ -153,7 +147,7 @@ ui/dist/app/index.html: $(shell find ui/src -type f && find ui -maxdepth 1 -type
JOBS=max yarn --cwd ui build

$(GOPATH)/bin/staticfiles:
cd `mktemp -d` && go get bou.ke/staticfiles
go install bou.ke/staticfiles@dd04075

ifeq ($(STATIC_FILES),true)
server/static/files.go: $(GOPATH)/bin/staticfiles ui/dist/app/index.html
Expand Down Expand Up @@ -268,44 +262,34 @@ docs: \

$(GOPATH)/bin/mockery:
go install github.com/vektra/mockery/v2@v2.9.4

$(GOPATH)/bin/controller-gen:
$(call go_install,sigs.k8s.io/controller-tools/cmd/controller-gen)

go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1
$(GOPATH)/bin/go-to-protobuf:
$(call go_install,k8s.io/code-generator/cmd/go-to-protobuf)

go install k8s.io/code-generator/cmd/go-to-protobuf@v0.21.5
$(GOPATH)/src/github.com/gogo/protobuf:
[ -e $(GOPATH)/src/github.com/gogo/protobuf ] || git clone --depth 1 https://github.com/gogo/protobuf.git -b v1.3.2 $(GOPATH)/src/github.com/gogo/protobuf
$(GOPATH)/bin/protoc-gen-gogo:
$(call go_install,github.com/gogo/protobuf/protoc-gen-gogo)

go install github.com/gogo/protobuf/protoc-gen-gogo@v1.3.2
$(GOPATH)/bin/protoc-gen-gogofast:
$(call go_install,github.com/gogo/protobuf/protoc-gen-gogofast)

go install github.com/gogo/protobuf/protoc-gen-gogofast@v1.3.2
$(GOPATH)/bin/protoc-gen-grpc-gateway:
$(call go_install,github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway)

go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0
$(GOPATH)/bin/protoc-gen-swagger:
$(call go_install,github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger)

go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.16.0
$(GOPATH)/bin/openapi-gen:
$(call go_install,k8s.io/kube-openapi/cmd/openapi-gen)

go install k8s.io/kube-openapi/cmd/openapi-gen@v0.0.0-20210305001622-591a79e4bda7
$(GOPATH)/bin/swagger:
$(call go_install,github.com/go-swagger/go-swagger/cmd/swagger)

go install github.com/go-swagger/go-swagger/cmd/swagger@v0.25.0
$(GOPATH)/bin/goimports:
$(call go_install,golang.org/x/tools/cmd/goimports)
go install golang.org/x/tools/cmd/goimports@v0.1.6

pkg/apis/workflow/v1alpha1/generated.proto: $(GOPATH)/bin/go-to-protobuf $(PROTO_BINARIES) $(TYPES)
[ -e ./vendor ] || go mod vendor
[ -e ./v3 ] || ln -s . v3
pkg/apis/workflow/v1alpha1/generated.proto: $(GOPATH)/bin/go-to-protobuf $(PROTO_BINARIES) $(TYPES) $(GOPATH)/src/github.com/gogo/protobuf
$(GOPATH)/bin/go-to-protobuf \
--go-header-file=./hack/custom-boilerplate.go.txt \
--packages=github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
--apimachinery-packages=+k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime/schema,+k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/api/core/v1,k8s.io/api/policy/v1beta1 \
--proto-import $(CURDIR)/vendor
--proto-import $(GOPATH)/src
touch pkg/apis/workflow/v1alpha1/generated.proto
[ -e ./v3 ] && rm -rf v3

# this target will also create a .pb.go and a .pb.gw.go file, but in Make 3 we cannot use _grouped target_, instead we must choose
# on file to represent all of them
Expand Down Expand Up @@ -427,7 +411,7 @@ pull-images:
docker pull python:alpine3.6

$(GOPATH)/bin/goreman:
cd `mktemp -d` && go get github.com/mattn/goreman
go install github.com/mattn/goreman@v0.3.7

.PHONY: start
ifeq ($(RUN_MODE),local)
Expand Down Expand Up @@ -494,25 +478,20 @@ clean:
# swagger

pkg/apis/workflow/v1alpha1/openapi_generated.go: $(GOPATH)/bin/openapi-gen $(TYPES)
[ -e ./v3 ] || ln -s . v3
$(GOPATH)/bin/openapi-gen \
--go-header-file ./hack/custom-boilerplate.go.txt \
--input-dirs github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
--output-package github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
--report-filename pkg/apis/api-rules/violation_exceptions.list
[ -e ./v3 ] && rm -rf v3


# generates many other files (listers, informers, client etc).
pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go: $(TYPES)
[ -e ./vendor ] || go mod vendor
[ -e ./v3 ] || ln -s . v3
bash $(GOPATH)/pkg/mod/k8s.io/code-generator@v0.21.5/generate-groups.sh \
"deepcopy,client,informer,lister" \
github.com/argoproj/argo-workflows/v3/pkg/client github.com/argoproj/argo-workflows/v3/pkg/apis \
workflow:v1alpha1 \
--go-header-file ./hack/custom-boilerplate.go.txt
[ -e ./v3 ] && rm -rf v3

dist/kubernetes.swagger.json:
@mkdir -p dist
Expand Down Expand Up @@ -563,7 +542,7 @@ validate-examples: api/jsonschema/schema.json
# pre-push

.PHONY: pre-commit
pre-commit: codegen lint test start
pre-commit: codegen lint

ifeq ($(GIT_BRANCH),master)
LOG_OPTS := '-n10'
Expand Down
73 changes: 34 additions & 39 deletions docs/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

## Pre-requisites

* [Go](https://golang.org/dl/) (The project currently uses version 1.15)
* [Go 1.16](https://golang.org/dl/)
* [Yarn](https://classic.yarnpkg.com/en/docs/install/#mac-stable)
* [Docker](https://docs.docker.com/get-docker/)
* [protoc](http://google.github.io/proto-lens/installing-protoc.html) `brew install protobuf`
* [protoc](http://google.github.io/proto-lens/installing-protoc.html)
* [`jq`](https://stedolan.github.io/jq/download/)
* A local Kubernetes cluster

### 1. Set up a local cluster
Code must be checked out into `$(GOPATH)/src/github.com/argo-workflows`.

We recommend using [K3D](https://k3d.io/) to set up the local Kubernetes cluster since this will allow you to test RBAC set-up and is fast. You can set-up K3D to be part of your default kube config as follows:
We recommend using [K3D](https://k3d.io/) to set up the local Kubernetes cluster since this will allow you to test RBAC
set-up and is fast. You can set-up K3D to be part of your default kube config as follows:

k3d cluster start --wait

Alternatively, you can use [Minikube](https://github.com/kubernetes/minikube) to set up the local Kubernetes cluster. Once a local Kubernetes cluster has started via `minikube start`, your kube config will use Minikube's context automatically.


### 2. Set up local service aliases
Alternatively, you can use [Minikube](https://github.com/kubernetes/minikube) to set up the local Kubernetes cluster.
Once a local Kubernetes cluster has started via `minikube start`, your kube config will use Minikube's context
automatically.

Add to /etc/hosts:

Expand All @@ -27,59 +27,54 @@ Add to /etc/hosts:
127.0.0.1 postgres
127.0.0.1 mysql

### 3. Install Argo and start the controller

To install into the “argo” namespace of your cluster: Argo and MinIO (for saving artifacts and logs):

make start

### 4. (Optional) Set up a DB for the Workflow archive
If you want the UI:

make start UI=true

If you want MySQL for the workflow archive:

make start PROFILE=mysql

### 5. Check out the Argo services running locally
For testing SSO integration, you can start a Argo with sso profile which will deploy a pre-configured dex instance in
argo namespace

make start PROFILE=sso

You’ll now have
You’ll now have:

* MinIO on http://localhost:9000 (use admin/password)
* Argo Server API on https://localhost:2746
* UI on http://localhost:8080
* MinIO http://localhost:9000 (use admin/password)
* Postgres on http://localhost:5432, run `make postgres-cli` to access.
* MySQL on http://localhost:3306, run `make mysql-cli` to access.

Either:
Before submitting/running workflows, build all the executor image:

* Postgres on http://localhost:5432, run `make postgres-cli` to access.
* MySQL on http://localhost:3306, run `make mysql-cli` to access.
make argoexec-image

At this point you’ll have everything you need to use the CLI and UI.
Before you commit, run:

make pre-commit -B

### 6. Build Argo images
Commits

Before submitting/running workflows, build all Argo images, so they're available for the workflow.
* Sign-off your commits.
* Use [Conventional Commit messages](https://www.conventionalcommits.org/en/v1.0.0/).
* Suffix the issue number.

make build
Example:

### 7. SSO with Dex
For testing SSO integration, you can start a Argo with sso profile which will deploy
a pre-configured dex instance in argo namespace

```sh
make start PROFILE=sso
```
git commit --signoff -m 'fix: Fixed broken thing. Fixes #1234'

## Troubleshooting Notes

* If you get a similar error when running one of the make pre-commit tests `make: *** [pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.swagger.json] Error 1`, ensure you are working within your $GOPATH (YOUR-GOPATH/src/github.com/argoproj/argo-workflows).

* If you encounter out of heap issues when building UI through Docker, please validate resources allocated to Docker. Compilation may fail if allocated RAM is less than 4Gi


## Clean

To clean-up everything:
* If you get a similar error when running one of the make pre-commit
tests `make: *** [pkg/apiclient/clusterworkflowtemplate/cluster-workflow-template.swagger.json] Error 1`, ensure you
are working within your $GOPATH (YOUR-GOPATH/src/github.com/argoproj/argo-workflows).
* If you encounter out of heap issues when building UI through Docker, please validate resources allocated to Docker.
Compilation may fail if allocated RAM is less than 4Gi

make clean
kubectl delete ns argo
docker system prune -af
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require (
github.com/go-openapi/spec v0.20.2
github.com/go-python/gpython v0.0.3
github.com/go-sql-driver/mysql v1.6.0
github.com/go-swagger/go-swagger v0.25.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2
github.com/gorilla/handlers v1.4.2
Expand Down Expand Up @@ -61,7 +60,7 @@ require (
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/tools v0.1.5
golang.org/x/tools v0.1.5 // indirect
google.golang.org/api v0.44.0
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c
google.golang.org/grpc v1.38.0
Expand All @@ -74,11 +73,9 @@ require (
k8s.io/api v0.21.5
k8s.io/apimachinery v0.21.5
k8s.io/client-go v0.21.5
k8s.io/code-generator v0.21.5
k8s.io/klog/v2 v2.8.0
k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
sigs.k8s.io/controller-tools v0.4.1
sigs.k8s.io/yaml v1.2.0
upper.io/db.v3 v3.6.3+incompatible
)
Loading

0 comments on commit 9aca97e

Please sign in to comment.