Skip to content

Commit

Permalink
Merge 0cc3998 into 9eee361
Browse files Browse the repository at this point in the history
  • Loading branch information
architeacher authored Feb 14, 2018
2 parents 9eee361 + 0cc3998 commit 8d500fa
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 58 deletions.
27 changes: 27 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
jobs:
validation:
docker:
- image: circleci/golang:1.9-alpine
working_directory: /go/src/github.com/ahmedkamals/foo-protocol-proxy
steps:
- checkout
- run: make get-deps setup validate nuke

unit:
docker:
- image: circleci/golang:1.9-alpine

working_directory: /go/src/github.com/ahmedkamals/foo-protocol-proxy
steps:
- checkout
- run: make setup unit nuke

integration:
docker:
- image: circleci/golang:1.9-alpine

working_directory: /go/src/github.com/ahmedkamals/foo-protocol-proxy
steps:
- checkout
- run: make setup integration nuke
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ahmed Kamal <me.ahmed.kamal@gmail.com> Ahmed Kamal <ahmedkamals@users.noreply.github.com>
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ script:
# This to fix the error "fatal: ref HEAD is not a symbolic ref", that appears after every make call.
- git checkout -b build-${TRAVIS_PULL_REQUEST}
- if [ "$BUILD" == true ]; then make build ; else echo 'skipping build.'; fi
- if [ "$VALIDATE" == true ]; then make validate ; else echo 'skipping verfication.'; fi
- if [ "$VALIDATE" == true ]; then make validate ; else echo 'skipping verification.'; fi
- if [ "$COVERAGE" == true ]; then make cover; travis_retry make coverage-send || true ; else echo 'skipping coverage.'; fi
- if [ "$TESTS" == true ]; then make unit race bench ; else echo 'skipping tests.'; fi

Expand Down
28 changes: 28 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# InfraKit maintainers file
#
# This file describes who runs the foo-protocol-proxy project and how.
# This is a living document - if you see something out of date or missing, speak up!
#
# It is structured to be consumable by both humans and programs.
# To extract its contents programmatically, use any TOML-compliant parser.
#
# This file is compiled into the MAINTAINERS file in docker/opensource.
#
[Org]
[Org."Core maintainers"]
people = [
"ahmedkamals"
]

[people]

# A reference list of all people associated with the project.
# All other sections should refer to people by their canonical key
# in the people section.

# ADD YOURSELF HERE IN ALPHABETICAL ORDER

[people.ahmedkamals]
Name = "Ahmed Kamal"
Email = "me.ahmed.kamal@gmail.com"
GitHub = "ahmedkamals"
44 changes: 0 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,3 @@

include Makefile.conf
include mk/main.mk

all: setup generate test coverage-html validate format nuke build-x install clean list help deploy ## to run all targets.

list: ## to list all targets.
@$(MAKE) -rRpqn | awk -F':' '/^[a-z0-9][^$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)printf "$(DISCLAIMER_COLOR)%-30s$(NO_COLOR)\n", A[i]}' | sort -u 2>&1

help: ## to get help about the targets.
@echo "$(OK_COLOR)$$FOO_PROTOCOL_PROXY$(NO_COLOR)"
@echo "$(INFO_COLOR)Please use \`make <target>\`, Available options for <target> are:$(NO_COLOR)\n"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z._-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " $(HELP_COLOR)%-28s$(NO_COLOR) %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort -u 2>&1
@echo "Useful variables:"
@awk 'BEGIN { FS = ":=" } /^## /{x = substr($$0, 4); getline; if (NF >= 2) printf " $(DISCLAIMER_COLOR)%-28s$(NO_COLOR) %s\n", $$1, x}' $(MAKEFILE_LIST) | sort -u 2>&1

setup: ## to setup the external used tools.
@echo "$(OK_COLOR)$(MSG_PREFIX) Setting-up required components$(MSG_SUFFIX)$(NO_COLOR)"
@$(GO) install $(GO_FLAGS) -tags $(GO_TAGS) $(PKGS) 2>&1

get-deps: ## to get required dependencies.
@echo "$(OK_COLOR)$(MSG_PREFIX) Installing required dependencies$(MSG_SUFFIX)$(NO_COLOR)"
@$(foreach dependency, $(DEPENDENCIES), $(call getDependency,$(dependency)))

generate: ## to generate related files.
@echo "$(OK_COLOR)$(MSG_PREFIX) Generating files via go generate$(MSG_SUFFIX)$(NO_COLOR)"
@$(GO) generate $(GO_FLAGS) $(PKGS) 2>&1

install: ## to install the generated binary.
@echo "$(OK_COLOR)$(MSG_PREFIX) Installing generated binary$(MSG_SUFFIX)$(NO_COLOR)"
@if [ ! -f $(TARGET_BINARY) ] ; then $(MAKE) build; fi
@cp $(TARGET_BINARY) /usr/local/bin 2>&1

clean: clean-bin clean-coverage ## to clean up all generated files.

nuke: clean ## to do clean up and enforce removing the corresponding installed archive or binary.
@echo "$(OK_COLOR)$(MSG_PREFIX) Cleaning go dependencies$(MSG_SUFFIX)$(NO_COLOR)"
@$(GO) clean -i $(GO_FLAGS) ./... net 2>&1

run: ## to run the generated binary, and build a new one if not existed.
@echo "$(OK_COLOR)$(MSG_PREFIX) Running generated binary$(MSG_SUFFIX)$(NO_COLOR)"
@if [ ! -f $(TARGET_BINARY) ] ; then $(MAKE) build; fi
@$(TARGET_BINARY) $(args) 2>&1

kill: ## to send a kill signal to the running process of the binary.
@echo "$(OK_COLOR)$(MSG_PREFIX) Sending kill signal $(args)$(MSG_SUFFIX)$(NO_COLOR)"
@pkill $(args) $(notdir $(TARGET_BINARY)) > /dev/null 2>&1
4 changes: 4 additions & 0 deletions Makefile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ MSG_SUFFIX := ...

DEPENDENCIES := golang.org/x/tools/cmd/cover \
github.com/golang/lint/golint \
github.com/client9/misspell/cmd/misspell \
github.com/gordonklaus/ineffassign \
github.com/mattn/goveralls \
github.com/wadey/gocovmerge

Expand All @@ -35,6 +37,8 @@ STATIC := true
## Set an output prefix, which is the local directory if not specified.
BINARY_PATH_PREFIX := $(CURDIR)
BINARY_PATH := ${BINARY_PATH_PREFIX}/bin
## Base path used to install.
INSTALLATION_BASE_PATH := /usr/local/bin

# Tests
## The number of parallel tests.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Foo Protocol Proxy [![Build Status](https://travis-ci.org/ahmedkamals/foo-protocol-proxy.svg)](https://travis-ci.org/ahmedkamals/foo-protocol-proxy "Build Status")
Foo Protocol Proxy [![Travis CI](https://travis-ci.org/ahmedkamals/foo-protocol-proxy.svg)](https://travis-ci.org/ahmedkamals/foo-protocol-proxy "Build Status") [![CircleCI](https://circleci.com/ahmedkamals/foo-protocol-prox.svg?style=svg&circle-token=50d2063f283f98b7d94746416c979af3102275b5)](https://circleci.com/ahmedkamals/foo-protocol-proxy "Build Status")
==================

[![GitHub tag](https://img.shields.io/github/tag/ahmedkamals/foo-protocol-proxy.svg?style=flat)](https://github.com/ahmedkamals/foo-protocol-proxy/releases "Version Tag")
Expand Down Expand Up @@ -200,7 +200,7 @@ $ make test
| [`Proxy`][7] | orchestrates the interactions between the components. |
| [`Listner`][8] | awaits for client connections, and on every new connection, a `BridgeConnection` instance is created. |
| [`BridgeConnection`][9] | acts as Bi-directional communication object, that passes data forward and backward to the server. |
| [`Analyzer`][10] | perform `analysis` by sniffing all the data read and written from the server. |
| [`Analyzer`][10] | performs `analysis` by sniffing all the data read and written from the server. |
| [`Stats`][11] | wraps stats data the would be flushed to stdout upon request. |
| [`TimeTable`][12] | contains snapshot of aggregated number of requests/responses at specific timestamp. |
| [`Saver`][13] | handles reading/writing data. |
Expand Down
10 changes: 5 additions & 5 deletions app/http_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func TestShouldConfigureRoutesCorrectly(t *testing.T) {
t.Error(testCase.Format(actual))
}
continue
} else {
expected := testCase.Expected.(*http.ServeMux)
}

if !reflect.DeepEqual(expected, actual) {
t.Error(testCase.Format(actual))
}
expected := testCase.Expected.(*http.ServeMux)

if !reflect.DeepEqual(expected, actual) {
t.Error(testCase.Format(actual))
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions mk/docker.mk
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
DOCKER := $(shell docker info > /dev/null 2>&1 || $(SUDO) 2>&1) docker

image: ## to build a docker image.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Creating Docker Image$(MSG_SUFFIX)$(NO_COLOR)"
@echo "$(WARN_COLOR)$(MSG_PREFIX) 🐳 Creating Docker Image$(MSG_SUFFIX)$(NO_COLOR)"
@$(DOCKER) build ${DOCKER_BUILD_FLAGS} -t $(REGISTRY_REPO):$(DOCKER_TAG) -f $(DOCKER_FILE) $(args) 2>&1

deploy: ## to deploy a docker container.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Deploying Docker Container$(MSG_SUFFIX)$(NO_COLOR)"
@echo "$(WARN_COLOR)$(MSG_PREFIX) 🐳 Deploying Docker Container$(MSG_SUFFIX)$(NO_COLOR)"
@$(SUDO) bash ./deploy.sh $(args) 2>&1

publish: ## to publish the docker image to dockerhub repository.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Pushing Docker Image to $(REGISTRY_REPO):$(DOCKER_TAG)$(MSG_SUFFIX)$(NO_COLOR)"
@echo "$(WARN_COLOR)$(MSG_PREFIX) 🐳 Pushing Docker Image to $(REGISTRY_REPO):$(DOCKER_TAG)$(MSG_SUFFIX)$(NO_COLOR)"
@$(DOCKER) push $(REGISTRY_REPO):$(DOCKER_TAG) 2>&1

docker-kill: ## to send kill signal to the main process at the docker container.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Sending kill signal to main Docker process$(MSG_SUFFIX)$(NO_COLOR)"
@echo "$(WARN_COLOR)$(MSG_PREFIX) 🐳 Sending kill signal to main Docker process$(MSG_SUFFIX)$(NO_COLOR)"
@$(DOCKER) exec -it $(BINARY_PREFIX)-${DOCKER_TAG} pkill $(args) $(BINARY_PREFIX) > /dev/null 2>&1

docker-logs: ## to get logs from the docker container.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Getting logs of the Docker container$(MSG_SUFFIX)$(NO_COLOR)"
@echo "$(WARN_COLOR)$(MSG_PREFIX) 🐳 Getting logs of the Docker container$(MSG_SUFFIX)$(NO_COLOR)"
@$(DOCKER) logs -f $(BINARY_PREFIX)-${DOCKER_TAG} 2>&1
1 change: 1 addition & 0 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PKG_BASE ?= $(shell $(GO) list -e ./ 2> /dev/null)
PKGS ?= $(shell $(GO) list ./... 2> /dev/null | grep -v /vendor/)
GO_FILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*" 2> /dev/null)

include mk/utils.mk
include mk/build.mk
include mk/coverage.mk
include mk/docker.mk
Expand Down
43 changes: 43 additions & 0 deletions mk/utils.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
all: setup generate test coverage-html validate format nuke build-x install clean list help deploy ## to run all targets.

list: ## to list all targets.
@$(MAKE) -rRpqn | awk -F':' '/^[a-z0-9][^$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)printf "$(DISCLAIMER_COLOR)%-30s$(NO_COLOR)\n", A[i]}' | sort -u 2>&1

help: ## to get help about the targets.
@echo "$(OK_COLOR)$$FOO_PROTOCOL_PROXY$(NO_COLOR)"
@echo "$(INFO_COLOR)Please use \`make <target>\`, Available options for <target> are:$(NO_COLOR)\n"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z._-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " $(HELP_COLOR)%-28s$(NO_COLOR) %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort -u 2>&1
@echo "Useful variables:"
@awk 'BEGIN { FS = ":=" } /^## /{x = substr($$0, 4); getline; if (NF >= 2) printf " $(DISCLAIMER_COLOR)%-28s$(NO_COLOR) %s\n", $$1, x}' $(MAKEFILE_LIST) | sort -u 2>&1

setup: ## to setup the external used tools.
@echo "$(OK_COLOR)$(MSG_PREFIX) Setting-up required components$(MSG_SUFFIX)$(NO_COLOR)"
@$(GO) install $(GO_FLAGS) -tags $(GO_TAGS) $(PKGS) 2>&1

get-deps: ## to get required dependencies.
@echo "$(OK_COLOR)$(MSG_PREFIX) Installing required dependencies$(MSG_SUFFIX)$(NO_COLOR)"
@$(foreach dependency, $(DEPENDENCIES), $(call getDependency,$(dependency)))

generate: ## to generate related files.
@echo "$(OK_COLOR)$(MSG_PREFIX) Generating files via go generate$(MSG_SUFFIX)$(NO_COLOR)"
@$(GO) generate $(GO_FLAGS) $(PKGS) 2>&1

install: ## to install the generated binary.
@echo "$(OK_COLOR)$(MSG_PREFIX) Installing generated binary$(MSG_SUFFIX)$(NO_COLOR)"
@if [ ! -f $(TARGET_BINARY) ] ; then $(MAKE) build; fi
@cp $(TARGET_BINARY) $(INSTALLATION_BASE_PATH) 2>&1

clean: clean-bin clean-coverage ## to clean up all generated files.

nuke: clean ## to do clean up and enforce removing the corresponding installed archive or binary.
@echo "$(OK_COLOR)$(MSG_PREFIX) Cleaning go dependencies$(MSG_SUFFIX)$(NO_COLOR)"
@$(GO) clean -i $(GO_FLAGS) ./... net 2>&1

run: ## to run the generated binary, and build a new one if not existed.
@echo "$(OK_COLOR)$(MSG_PREFIX) Running generated binary$(MSG_SUFFIX)$(NO_COLOR)"
@if [ ! -f $(TARGET_BINARY) ] ; then $(MAKE) build; fi
@$(TARGET_BINARY) $(args) 2>&1

kill: ## to send a kill signal to the running process of the binary.
@echo "$(OK_COLOR)$(MSG_PREFIX) Sending kill signal $(args)$(MSG_SUFFIX)$(NO_COLOR)"
@pkill $(args) $(notdir $(TARGET_BINARY)) > /dev/null 2>&1
10 changes: 9 additions & 1 deletion mk/validate.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
validate: vet lint format-check ## to validate the code.
validate: vet lint format-check misspell ineffassign ## to validate the code.

# Simplified dead code detector. Used for skipping certain checks on unreachable code
# (for instance, shift checks on arch-specific code).
Expand All @@ -23,3 +23,11 @@ format-check: ## to check if the go files are formatted correctly.
format: ## to format all go files.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Formatting code$(MSG_SUFFIX)$(NO_COLOR)"
@test -z "$$($(GO_FMT) -s -w $(GO_FLAGS) $(GO_FILES) 2>&1 | tee /dev/stderr)"

misspell: ## to run misspell.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Running misspell$(MSG_SUFFIX)$(NO_COLOR)"
@test -z "$$(find . -type f | grep -v vendor/ | grep -v bin/ | grep -v .git/ | grep -v MAINTAINERS | xargs misspell | tee /dev/stderr)"

ineffassign: ## to run ineffassign.
@echo "$(WARN_COLOR)$(MSG_PREFIX) Running ineffassign$(MSG_SUFFIX)$(NO_COLOR)"
@test -z "$$(ineffassign . | grep -v vendor/ | grep -v ".pb.go:" | tee /dev/stderr)"

0 comments on commit 8d500fa

Please sign in to comment.