Skip to content

Commit

Permalink
Merge pull request #141 from kubernetes-simulator/go-static-analysis
Browse files Browse the repository at this point in the history
Go static analysis
  • Loading branch information
abdullahgarcia authored Dec 17, 2019
2 parents eeb6f76 + b4cc4c7 commit 57818af
Show file tree
Hide file tree
Showing 5 changed files with 508 additions and 16 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ USER ${build_user}

# Install golang module dependencies before copying source to cache them in their own layer
WORKDIR /go/src/github.com/controlplaneio/simulator-standalone
RUN go mod download

# Add the full source tree
COPY --chown=1000 . /go/src/github.com/controlplaneio/simulator-standalone/
Expand All @@ -140,11 +139,14 @@ WORKDIR /go/src/github.com/controlplaneio/simulator-standalone/
USER root
RUN chown -R ${build_user}:${build_user} /go/src/github.com/controlplaneio/simulator-standalone/

RUN go get honnef.co/go/tools/cmd/staticcheck
USER ${build_user}

RUN mkdir /home/${build_user}/go/bin
ENV PATH=${PATH}:/home/${build_user}/go/bin

# Golang build and test
WORKDIR /go/src/github.com/controlplaneio/simulator-standalone
ENV GO111MODULE=on
RUN make test-unit

#------------------#
Expand Down
33 changes: 21 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ SIMULATOR_CONFIG_FILE := $(KUBE_SIM_TMP)/simulator.yaml
HOST := $(shell hostname)
TOOLS_DIR := tools/scenario-tools

export GOPROXY=direct
export GOSUMDB=off

# --- Make
.DEFAULT_GOAL := help

Expand Down Expand Up @@ -72,14 +75,14 @@ gpg-preflight:

# --- DOCKER
run: validate-reqs docker-build ## Run the simulator - the build stage of the container runs all the cli tests
@docker run \
-h launch \
-v $(SIMULATOR_AWS_CREDS_PATH):/home/launch/.aws \
-v $(SSH_CONFIG_PATH):/home/launch/.ssh \
-v $(KUBE_SIM_TMP):/home/launch/.kubesim \
@docker run \
-h launch \
-v $(SIMULATOR_AWS_CREDS_PATH):/home/launch/.aws \
-v $(SSH_CONFIG_PATH):/home/launch/.ssh \
-v $(KUBE_SIM_TMP):/home/launch/.kubesim \
-v "$(shell pwd)/terraform":/app/terraform \
-v "$(shell pwd)/simulation-scripts":/app/simulation-scripts:ro \
--env-file launch-environment \
--env-file launch-environment \
--rm --init -it $(CONTAINER_NAME_LATEST)

.PHONY: docker-build-nocache
Expand All @@ -97,21 +100,27 @@ docker-build: ## Builds the launch container
.PHONY: docker-test
docker-test: validate-reqs docker-build ## Run the tests
@export AWS_DEFAULT_REGION="testing propagation to AWS_REGION var"; \
docker run \
-v "$(SIMULATOR_AWS_CREDS_PATH)":/home/launch/.aws \
--env-file launch-environment \
--rm -t $(CONTAINER_NAME_LATEST) \
docker run \
-v "$(SIMULATOR_AWS_CREDS_PATH)":/home/launch/.aws \
--env-file launch-environment \
--rm -t $(CONTAINER_NAME_LATEST) \
/app/test-acceptance.sh

cd attack && make docker-test

# -- SIMULATOR CLI
.PHONY: dep
dep: ## Install dependencies for other targets
$(GO) mod download 2>&1
$(GO) mod download
$(GO) get honnef.co/go/tools/cmd/staticcheck

.PHONY: static-analysis
static-analysis: dep
$(GO) vet
staticcheck $(PKG)

.PHONY: build
build: dep ## Run golang build for the CLI program
build: static-analysis ## Run golang build for the CLI program
@echo "+ $@"
$(GO) build ${GO_LDFLAGS} -a -o ./dist/simulator

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/kubernetes-simulator/simulator/graphs/commit-activity)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![GoDoc](https://godoc.org/github.com/controlplaneio/simulator-standalone?status.svg)](https://godoc.org/github.com/controlplaneio/simulator-standalone)

[![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes-simulator/simulator)](https://goreportcard.com/report/github.com/kubernetes-simulator/simulator)

# Simulator

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ require (
github.com/prometheus/procfs v0.0.3 // indirect
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481 // indirect
github.com/rogpeppe/fastuuid v1.1.0 // indirect
github.com/rogpeppe/go-internal v1.3.0 // indirect
github.com/rogpeppe/godef v1.1.1 // indirect
github.com/russross/blackfriday v2.0.0+incompatible // indirect
github.com/shirou/gopsutil v2.18.12+incompatible // indirect
Expand Down Expand Up @@ -100,8 +99,11 @@ require (
google.golang.org/grpc v1.21.1 // indirect
gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c // indirect
gopkg.in/yaml.v2 v2.2.2
honnef.co/go/tools v0.0.1-2019.2.3 // indirect
mvdan.cc/unparam v0.0.0-20190310220240-1b9ccfa71afe // indirect
sourcegraph.com/sqs/pbtypes v1.0.0 // indirect
)

replace github.com/go-critic/[email protected] => github.com/go-critic/go-critic v0.3.5-0.20190526074819-1df300866540

go 1.13
Loading

0 comments on commit 57818af

Please sign in to comment.