Skip to content
This repository was archived by the owner on May 31, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- save_cache:
key: build-cache-{{ .Branch }}--{{ .Revision }}
paths:
- /tmp/go/cache
- /tmp/go/cache
when: on_fail
- run:
name: prepare cache dir if not exists
Expand All @@ -54,9 +54,8 @@ jobs:
- go/src/github.com/motonary/Fortuna/builds

test:
working_directory: /go/src/github.com/motonary/Fortuna
environment:
- GOPATH: /home/circleci/go
- GOPATH: /home/circleci/go/src/github.com./motonary/Fortuna
- GOCACHE: "/tmp/go/cache"
docker:
- image: circleci/golang:1.11
Expand All @@ -67,9 +66,11 @@ jobs:
MYSQL_USER: root
MYSQL_DATABASE: circleci_test
MYSQL_ALLOW_EMPTY_PASSWORD: true
working_directory: /go/src/github.com/motonary/Fortuna
steps:
- run: echo 'export PATH=${GOPATH}/bin/:${PATH}' >> $BASH_ENV
- checkout
- run: go env
- restore_cache:
keys:
- vendor-{{ checksum "Gopkg.lock" }}
Expand All @@ -79,19 +80,24 @@ jobs:
- run:
name: install sql-migrate
command: go get -v github.com/rubenv/sql-migrate/...
- run: pwd; which sql-migrate;
- run:
name: migration
command: sql-migrate up -config="config/migration_config_ci.yml" -env="test"
- run:
name: install dep
command: go get github.com/golang/dep/cmd/dep
- run:
name: run go get
command: go get -v -t -d ./...
command: sql-migrate up -config="config/migration_config.ci.yml" -env="test"

# 一旦ハードコーディングでインストール
- run: go get "github.com/dgrijalva/jwt-go"
- run: go get "github.com/go-chi/chi"
- run: go get "github.com/go-chi/jwtauth"
- run: go get "github.com/go-sql-driver/mysql"
- run: go get "github.com/jinzhu/gorm"
- run: go get "github.com/jinzhu/inflection"
- run: go get "github.com/google/uuid"
- run: go get "google.golang.org/appengine"
- run: go get "gopkg.in/yaml.v2"

- run:
name: run go test
command: GO_ENV=test go test ./...
command: GO_ENV=circleci go test -v -cover ./...
- save_cache:
key: build-cache-{{ .Branch }}--{{ .Revision }}
paths:
Expand Down
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,41 @@
# go-tests = true
# unused-packages = true

[[constraint]]
name = "github.com/dgrijalva/jwt-go"
version = "3.2.0"

[[constraint]]
name = "github.com/go-chi/chi"
version = "4.0.1"

[[constraint]]
name = "github.com/go-chi/jwtauth"
version = "4.0.2"

[[constraint]]
name = "github.com/go-sql-driver/mysql"
version = "1.4.1"

[[constraint]]
name = "github.com/google/uuid"
version = "1.1.0"

[[constraint]]
name = "github.com/jinzhu/gorm"
version = "1.9.2"

[[constraint]]
name = "github.com/jinzhu/inflection"
branch = "master"

[[constraint]]
name = "gopkg.in/yaml.v2"
version = "2.2.2"

[[override]]
name = "google.golang.org/appengine"
version = "1.4.0"

[prune]
go-tests = true
Expand Down
2 changes: 1 addition & 1 deletion api/v1/tests/routes_test.go → api/v1/routes_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1_test

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1_test

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package v1_test

import (
"bytes"
Expand Down
7 changes: 7 additions & 0 deletions config/database.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
circleci:
driver: mysql
user: root
pass:
db: circleci_test
protocol: ""
option: charset=utf8&parseTime=True&loc=Local
6 changes: 5 additions & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func init() {

DB = Connect()
log.Printf("database connected\n")
log.Printf("%s\n", os.Getenv("GO_ENV"))
}

func Connect() *gorm.DB {
Expand All @@ -40,13 +41,16 @@ func Connect() *gorm.DB {
}

func getConfigFile() string {
if os.Getenv("GO_ENV") == "circleci" {
return "../../../config/database.ci.yml"
}
if _, err := os.Stat("config/database.yml"); err == nil {
return "config/database.yml"
}
if _, err := os.Stat("../config/database.yml"); err == nil {
return "../config/database.yml"
}
return "../../../config/database.yml"
return "../../config/database.yml"
}

func loadConfig(file_path string) []byte {
Expand Down
2 changes: 2 additions & 0 deletions database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"os"
"testing"

_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"

"github.com/motonary/Fortuna/entity"
test "github.com/motonary/Fortuna/testdata"
Expand Down
12 changes: 12 additions & 0 deletions vendor/gopkg.in/yaml.v2/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading