Skip to content

Commit

Permalink
Add Automation files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskaranbir committed Oct 4, 2018
1 parent a96a9ae commit 8ebbb74
Show file tree
Hide file tree
Showing 24 changed files with 282 additions and 265 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.history
.vagrant
.vscode
vendor*
7 changes: 0 additions & 7 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,5 @@ KAFKA_PRODUCER_TOPIC_LOGIN=auth.login.request
KAFKA_CONSUMER_TOPIC_REGISTER=auth.register.response
KAFKA_PRODUCER_TOPIC_REGISTER=event.rns_eventstore.events

MONGO_HOSTS=localhost:27017
MONGO_USERNAME=root
MONGO_PASSWORD=root
MONGO_DATABASE=rns_projections
MONGO_COLLECTION=user_auth
MONGO_TIMEOUT=3000

REDIS_HOST=localhost:6379
REDIS_DB=0
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.history
.vagrant
.vscode
vendor*
debug.test
vendor*
17 changes: 17 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
linters:
enable:
- dupl
- gocyclo
- maligned
- misspell
- lll
- unparam

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
lll:
line-length: 90
unparam:
algo: rta
41 changes: 41 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
project_name: go-apigateway

builds:
- main: ./main/
env:
- CGO_ENABLED=0
goos:
- linux
- windows

archive:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format: binary

sign:
artifacts: none

release:
github:
owner: TerrexTech
name: go-apigateway

changelog:
sort: asc
filters:
exclude:
- '^bors:'
- '^docs:'
- typo

dockers:
- image: terrextech/go-apigateway
binary: go-apigateway
dockerfile: Dockerfile_ci
goos: linux
goarch: amd64
tag_templates:
- "{{ .Tag }}"
- latest
extra_files:
- .env
64 changes: 64 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
dist: trusty

services:
- docker

language: go

go:
- "1.11"

# Only clone the most recent commit
git:
depth: 1

branches:
except:
- staging.tmp

env:
global:
- DEP_VERSION="0.5.0"
- DOCKER_COMPOSE_VERSION=1.22.0

addons:
apt:
packages:
- docker-ce

before_install:
# Download dep binary to $GOPATH/bin
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep

# Docker-Compose
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname
-s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

install:
# Only install local deps if its a tagged-commit
- if [[ ! -z ${TRAVIS_TAG} ]]; then dep ensure; fi

before_script:
- chmod +x ./run_test.sh

script:
- ./run_test.sh

# after_script:
# - docker-compose -f ./test/docker-compose.yaml down --volumes --rmi all

after_success:
- test -n "$TRAVIS_TAG"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

deploy:
- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash -s -- --debug --skip-validate
on:
all_branches: true
tags: true
6 changes: 6 additions & 0 deletions Dockerfile_ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Dockerfile used by GoReleaser
FROM scratch
LABEL maintainer="Jaskaranbir Dhillon"

COPY /go-apigateway ./
ENTRYPOINT ["./go-apigateway"]
23 changes: 23 additions & 0 deletions Dockerfile_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dockerfile used to build the image in which the tests are run against
# the image where compiled binary is running.
FROM golang:1.11.0-alpine3.8
LABEL maintainer="Jaskaranbir Dhillon"

ARG SOURCE_REPO

ENV DEP_VERSION=0.5.0

# Download and install dep and git
ADD https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
RUN apk add --update git

WORKDIR $GOPATH/src/github.com/TerrexTech/${SOURCE_REPO}

# Copy the code from the host and compile it
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only -v

COPY . ./

ENTRYPOINT go test -v ./...
88 changes: 0 additions & 88 deletions auth/db.go

This file was deleted.

5 changes: 5 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
status = [ "continuous-integration/travis-ci/push" ]
delete_merged_branches = true
[committer]
name = "Ninja Bruh"
email = "terrextech.ninjabruh@gmail.com"
4 changes: 3 additions & 1 deletion gql/resolver/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var RegisterResolver = func(params graphql.ResolveParams) (interface{}, error) {
ka := rootValue["kafkaFactory"].(*util.KafkaFactory)
ts := rootValue["tokenStore"].(auth.TokenStoreI)

epio, err := ka.EnsureEventProducerIO(prodTopic, prodTopic, false)
epio, err := ka.EnsureEventProducerIO(prodTopic, false)
if err != nil {
err = errors.Wrap(err, "Error creating ProducerIO for RegisterResolver")
return nil, err
Expand Down Expand Up @@ -84,6 +84,8 @@ var RegisterResolver = func(params graphql.ResolveParams) (interface{}, error) {
return registerResp.tokens, nil
}
ae := registerResp.err
err = errors.Wrap(ae.Err, "Registration Error")
log.Println(err)
outErr := fmt.Errorf("%d: Registration Error", ae.Code)
return nil, outErr
}
Expand Down
1 change: 1 addition & 0 deletions gql/schema/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/graphql-go/graphql"
)

// RootMutation is the schema-definition for GraphQL mutations.
var RootMutation = graphql.NewObject(graphql.ObjectConfig{
Name: "RootMutation",
Fields: graphql.Fields{
Expand Down
1 change: 1 addition & 0 deletions gql/schema/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/graphql-go/graphql"
)

// RootQuery is the schema-definition for GraphQL queries.
var RootQuery = graphql.NewObject(graphql.ObjectConfig{
Name: "RootQuery",
Fields: graphql.Fields{
Expand Down
4 changes: 2 additions & 2 deletions gwerrors/kafkaresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package gwerrors

import "fmt"

// KRError represents a KafkaResponse error.
// KRError represents an error from KafkaResponse.
type KRError struct {
Code int16
Err error
Message string
}

// NewKRError creates a new KRError from provided parameters.
// NewKRError creates a new error for KafkaResponse from provided parameters.
func NewKRError(err error, code int16, msg string) *KRError {
return &KRError{
Code: code,
Expand Down
1 change: 1 addition & 0 deletions gwerrors/var.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package gwerrors

// InternalError represents an error when something goes wrong, and its our fault.
const InternalError = 2
7 changes: 0 additions & 7 deletions main/.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,5 @@ KAFKA_PRODUCER_TOPIC_LOGIN=auth.login.request
KAFKA_CONSUMER_TOPIC_REGISTER=auth.register.response
KAFKA_PRODUCER_TOPIC_REGISTER=event.rns_eventstore.events

MONGO_HOSTS=localhost:27017
MONGO_USERNAME=root
MONGO_PASSWORD=root
MONGO_DATABASE=rns_projections
MONGO_COLLECTION=user_auth
MONGO_TIMEOUT=3000

REDIS_HOST=localhost:6379
REDIS_DB=0
Loading

0 comments on commit 8ebbb74

Please sign in to comment.