From bc1b48c5d8dcd6da7dab4cbcc56cc3323cf44930 Mon Sep 17 00:00:00 2001 From: Nachi Ueno Date: Wed, 13 Dec 2017 14:00:04 -0800 Subject: [PATCH] Enable CircleCI --- .circleci/config.yml | 30 ++++++++ Gopkg.lock | 8 +- README.md | 75 ------------------- pkg/apisrv/server.go | 1 + pkg/common/api.go | 2 +- pkg/common/schema.go | 4 +- tools/reset_db.sh | 6 +- tools/test_config.yml | 2 +- .../{Sirupsen => sirupsen}/logrus/.gitignore | 0 .../{Sirupsen => sirupsen}/logrus/.travis.yml | 0 .../logrus/CHANGELOG.md | 0 .../{Sirupsen => sirupsen}/logrus/LICENSE | 0 .../{Sirupsen => sirupsen}/logrus/README.md | 0 .../{Sirupsen => sirupsen}/logrus/alt_exit.go | 0 .../logrus/alt_exit_test.go | 0 .../logrus/appveyor.yml | 0 .../{Sirupsen => sirupsen}/logrus/doc.go | 0 .../{Sirupsen => sirupsen}/logrus/entry.go | 0 .../logrus/entry_test.go | 0 .../logrus/example_basic_test.go | 0 .../logrus/example_hook_test.go | 0 .../{Sirupsen => sirupsen}/logrus/exported.go | 0 .../logrus/formatter.go | 0 .../logrus/formatter_bench_test.go | 0 .../logrus/hook_test.go | 0 .../{Sirupsen => sirupsen}/logrus/hooks.go | 0 .../logrus/hooks/syslog/README.md | 0 .../logrus/hooks/syslog/syslog.go | 0 .../logrus/hooks/syslog/syslog_test.go | 0 .../logrus/hooks/test/test.go | 0 .../logrus/hooks/test/test_test.go | 0 .../logrus/json_formatter.go | 0 .../logrus/json_formatter_test.go | 0 .../{Sirupsen => sirupsen}/logrus/logger.go | 0 .../logrus/logger_bench_test.go | 0 .../{Sirupsen => sirupsen}/logrus/logrus.go | 0 .../logrus/logrus_test.go | 0 .../logrus/terminal_bsd.go | 0 .../logrus/terminal_linux.go | 0 .../logrus/text_formatter.go | 0 .../logrus/text_formatter_test.go | 0 .../{Sirupsen => sirupsen}/logrus/writer.go | 0 42 files changed, 39 insertions(+), 89 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 README.md rename vendor/github.com/{Sirupsen => sirupsen}/logrus/.gitignore (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/.travis.yml (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/CHANGELOG.md (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/LICENSE (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/README.md (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/alt_exit.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/alt_exit_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/appveyor.yml (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/doc.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/entry.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/entry_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/example_basic_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/example_hook_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/exported.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/formatter.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/formatter_bench_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hook_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks/syslog/README.md (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks/syslog/syslog.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks/syslog/syslog_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks/test/test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks/test/test_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/json_formatter.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/json_formatter_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/logger.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/logger_bench_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/logrus.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/logrus_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_bsd.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_linux.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/text_formatter.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/text_formatter_test.go (100%) rename vendor/github.com/{Sirupsen => sirupsen}/logrus/writer.go (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..7de36a59f4 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,30 @@ +version: 2 +jobs: + build: + working_directory: /go/src/github.com/Juniper/contrail + docker: + - image: circleci/golang:1.9 + - image: circleci/mysql:5.7 + environment: + - MYSQL_ROOT_PASSWORD=contrail123 + + steps: + - checkout + - run: + name: install mysql client + command: sudo apt install mysql-client + - run: + name: install deps + command: ./tools/deps.sh + - run: + name: lint + command: ./tools/lint.sh + - run: + name: Wait for db + command: dockerize -wait tcp://localhost:3306 -timeout 1m + - run: + name: Reset database + command: ./tools/reset_db.sh + - run: + name: Run Test + command: make test \ No newline at end of file diff --git a/Gopkg.lock b/Gopkg.lock index a58ee92a22..659668f7b0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -37,12 +37,6 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" -[[projects]] - name = "github.com/k0kubun/pp" - packages = ["."] - revision = "027a6d1765d673d337e687394dbe780dd64e2a1e" - version = "v2.3.0" - [[projects]] name = "github.com/labstack/echo" packages = [".","middleware"] @@ -190,6 +184,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "9dde4ea971665f7bcb52f02605cd2404861fd4865bf45104254a96fa6ed96174" + inputs-digest = "91d7e800d2f1f3a52367e62e3955304d6b398f30af511965b14896f3c9811766" solver-name = "gps-cdcl" solver-version = 1 diff --git a/README.md b/README.md deleted file mode 100644 index 08d9399f4c..0000000000 --- a/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Go code base for contrail projects - - -# Important principal - -- Apply lint tools -- Go get must simply work -- Follow best practices - Effective Go: https://golang.org/doc/effective_go.html - -# How to build - -``` shell -go get github.com/Juniper/contrail -``` - -# Generate Code - -``` shell -make generate -``` - -Templates are stored in tools/templates -You can add your template on template_config.yaml - -# Schema Files - -Note that schema stored here is just a cache for helping development. -Developers should make sure download latest schema from http://github.com/Juniper/contrail-api-client - -JSON version stored in public/schema.json - -# Testing - -You need to run local mysql running with test configuraion. - -ID: root -Password: contrail123 -DataBase: contrail_test - -You need also add this for /etc/hosts - -``` -127.0.0.1 mysql -``` - -Init DB before test -``` -./tool/reset_db.sh -``` - -``` -make test -``` - -# API Server - -You can run API server using this command. - -``` -go run cmd/contrail/main.go server -c tools/test_config.yml -``` - -# Packaging - -TBD - -# Dependency management - -We use golang standard dep tool for dependency management. -(see https://github.com/golang/dep) - -``` -brew install dep -``` diff --git a/pkg/apisrv/server.go b/pkg/apisrv/server.go index 23ac90ce76..d879e91132 100644 --- a/pkg/apisrv/server.go +++ b/pkg/apisrv/server.go @@ -131,6 +131,7 @@ func (s *Server) Run() error { return nil } +//Close closes server resources func (s *Server) Close() error { return s.DB.Close() } diff --git a/pkg/common/api.go b/pkg/common/api.go index a4a1b114c5..0cb8b2987b 100644 --- a/pkg/common/api.go +++ b/pkg/common/api.go @@ -6,7 +6,7 @@ import ( "github.com/labstack/echo" ) -//REST API defines handlers for REST API calls. +//RESTAPI defines handlers for REST API calls. type RESTAPI interface { Path() string LongPath() string diff --git a/pkg/common/schema.go b/pkg/common/schema.go index 42bfa5a86e..10605357d9 100644 --- a/pkg/common/schema.go +++ b/pkg/common/schema.go @@ -59,7 +59,7 @@ func (c ColumnConfigs) Less(i, j int) bool { return strings.Compare(strings.Join(c[i].ParentColumn, "")+c[i].Column, strings.Join(c[j].ParentColumn, "")+c[j].Column) > 0 } -func (c ColumnConfigs) ShortenColumn() { +func (c ColumnConfigs) shortenColumn() { sort.Sort(c) if len(c) < 2 { return @@ -418,7 +418,7 @@ func (api *API) resolveAllSQL() error { if err != nil { return err } - s.Columns.ShortenColumn() + s.Columns.shortenColumn() } return nil } diff --git a/tools/reset_db.sh b/tools/reset_db.sh index 38fdbeb5a3..544a4a03c5 100755 --- a/tools/reset_db.sh +++ b/tools/reset_db.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash TOP=$(dirname "$0") -mysql -uroot -pcontrail123 -e "drop database if exists contrail_test;" -mysql -uroot -pcontrail123 -e "create database contrail_test;" -mysql -uroot -pcontrail123 contrail_test < $TOP/init.sql \ No newline at end of file +mysql -uroot -pcontrail123 -h 127.0.0.1 -e "drop database if exists contrail_test;" +mysql -uroot -pcontrail123 -h 127.0.0.1 -e "create database contrail_test;" +mysql -uroot -pcontrail123 -h 127.0.0.1 contrail_test < $TOP/init.sql \ No newline at end of file diff --git a/tools/test_config.yml b/tools/test_config.yml index 5853849f96..d468f05797 100644 --- a/tools/test_config.yml +++ b/tools/test_config.yml @@ -1,6 +1,6 @@ # Database configuraion. Only MySQL supported database: - connection: "root:contrail123@tcp(mysql:3306)/contrail_test" + connection: "root:contrail123@tcp(localhost:3306)/contrail_test" # Max Open Connections for MySQL Server max_open_conn: 100 diff --git a/vendor/github.com/Sirupsen/logrus/.gitignore b/vendor/github.com/sirupsen/logrus/.gitignore similarity index 100% rename from vendor/github.com/Sirupsen/logrus/.gitignore rename to vendor/github.com/sirupsen/logrus/.gitignore diff --git a/vendor/github.com/Sirupsen/logrus/.travis.yml b/vendor/github.com/sirupsen/logrus/.travis.yml similarity index 100% rename from vendor/github.com/Sirupsen/logrus/.travis.yml rename to vendor/github.com/sirupsen/logrus/.travis.yml diff --git a/vendor/github.com/Sirupsen/logrus/CHANGELOG.md b/vendor/github.com/sirupsen/logrus/CHANGELOG.md similarity index 100% rename from vendor/github.com/Sirupsen/logrus/CHANGELOG.md rename to vendor/github.com/sirupsen/logrus/CHANGELOG.md diff --git a/vendor/github.com/Sirupsen/logrus/LICENSE b/vendor/github.com/sirupsen/logrus/LICENSE similarity index 100% rename from vendor/github.com/Sirupsen/logrus/LICENSE rename to vendor/github.com/sirupsen/logrus/LICENSE diff --git a/vendor/github.com/Sirupsen/logrus/README.md b/vendor/github.com/sirupsen/logrus/README.md similarity index 100% rename from vendor/github.com/Sirupsen/logrus/README.md rename to vendor/github.com/sirupsen/logrus/README.md diff --git a/vendor/github.com/Sirupsen/logrus/alt_exit.go b/vendor/github.com/sirupsen/logrus/alt_exit.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/alt_exit.go rename to vendor/github.com/sirupsen/logrus/alt_exit.go diff --git a/vendor/github.com/Sirupsen/logrus/alt_exit_test.go b/vendor/github.com/sirupsen/logrus/alt_exit_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/alt_exit_test.go rename to vendor/github.com/sirupsen/logrus/alt_exit_test.go diff --git a/vendor/github.com/Sirupsen/logrus/appveyor.yml b/vendor/github.com/sirupsen/logrus/appveyor.yml similarity index 100% rename from vendor/github.com/Sirupsen/logrus/appveyor.yml rename to vendor/github.com/sirupsen/logrus/appveyor.yml diff --git a/vendor/github.com/Sirupsen/logrus/doc.go b/vendor/github.com/sirupsen/logrus/doc.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/doc.go rename to vendor/github.com/sirupsen/logrus/doc.go diff --git a/vendor/github.com/Sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/entry.go rename to vendor/github.com/sirupsen/logrus/entry.go diff --git a/vendor/github.com/Sirupsen/logrus/entry_test.go b/vendor/github.com/sirupsen/logrus/entry_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/entry_test.go rename to vendor/github.com/sirupsen/logrus/entry_test.go diff --git a/vendor/github.com/Sirupsen/logrus/example_basic_test.go b/vendor/github.com/sirupsen/logrus/example_basic_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/example_basic_test.go rename to vendor/github.com/sirupsen/logrus/example_basic_test.go diff --git a/vendor/github.com/Sirupsen/logrus/example_hook_test.go b/vendor/github.com/sirupsen/logrus/example_hook_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/example_hook_test.go rename to vendor/github.com/sirupsen/logrus/example_hook_test.go diff --git a/vendor/github.com/Sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/exported.go rename to vendor/github.com/sirupsen/logrus/exported.go diff --git a/vendor/github.com/Sirupsen/logrus/formatter.go b/vendor/github.com/sirupsen/logrus/formatter.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/formatter.go rename to vendor/github.com/sirupsen/logrus/formatter.go diff --git a/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go b/vendor/github.com/sirupsen/logrus/formatter_bench_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/formatter_bench_test.go rename to vendor/github.com/sirupsen/logrus/formatter_bench_test.go diff --git a/vendor/github.com/Sirupsen/logrus/hook_test.go b/vendor/github.com/sirupsen/logrus/hook_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hook_test.go rename to vendor/github.com/sirupsen/logrus/hook_test.go diff --git a/vendor/github.com/Sirupsen/logrus/hooks.go b/vendor/github.com/sirupsen/logrus/hooks.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks.go rename to vendor/github.com/sirupsen/logrus/hooks.go diff --git a/vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md b/vendor/github.com/sirupsen/logrus/hooks/syslog/README.md similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md rename to vendor/github.com/sirupsen/logrus/hooks/syslog/README.md diff --git a/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go b/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go rename to vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go diff --git a/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go b/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go rename to vendor/github.com/sirupsen/logrus/hooks/syslog/syslog_test.go diff --git a/vendor/github.com/Sirupsen/logrus/hooks/test/test.go b/vendor/github.com/sirupsen/logrus/hooks/test/test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks/test/test.go rename to vendor/github.com/sirupsen/logrus/hooks/test/test.go diff --git a/vendor/github.com/Sirupsen/logrus/hooks/test/test_test.go b/vendor/github.com/sirupsen/logrus/hooks/test/test_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/hooks/test/test_test.go rename to vendor/github.com/sirupsen/logrus/hooks/test/test_test.go diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/sirupsen/logrus/json_formatter.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/json_formatter.go rename to vendor/github.com/sirupsen/logrus/json_formatter.go diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter_test.go b/vendor/github.com/sirupsen/logrus/json_formatter_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/json_formatter_test.go rename to vendor/github.com/sirupsen/logrus/json_formatter_test.go diff --git a/vendor/github.com/Sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/logger.go rename to vendor/github.com/sirupsen/logrus/logger.go diff --git a/vendor/github.com/Sirupsen/logrus/logger_bench_test.go b/vendor/github.com/sirupsen/logrus/logger_bench_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/logger_bench_test.go rename to vendor/github.com/sirupsen/logrus/logger_bench_test.go diff --git a/vendor/github.com/Sirupsen/logrus/logrus.go b/vendor/github.com/sirupsen/logrus/logrus.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/logrus.go rename to vendor/github.com/sirupsen/logrus/logrus.go diff --git a/vendor/github.com/Sirupsen/logrus/logrus_test.go b/vendor/github.com/sirupsen/logrus/logrus_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/logrus_test.go rename to vendor/github.com/sirupsen/logrus/logrus_test.go diff --git a/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/vendor/github.com/sirupsen/logrus/terminal_bsd.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_bsd.go rename to vendor/github.com/sirupsen/logrus/terminal_bsd.go diff --git a/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/vendor/github.com/sirupsen/logrus/terminal_linux.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/terminal_linux.go rename to vendor/github.com/sirupsen/logrus/terminal_linux.go diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/text_formatter.go rename to vendor/github.com/sirupsen/logrus/text_formatter.go diff --git a/vendor/github.com/Sirupsen/logrus/text_formatter_test.go b/vendor/github.com/sirupsen/logrus/text_formatter_test.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/text_formatter_test.go rename to vendor/github.com/sirupsen/logrus/text_formatter_test.go diff --git a/vendor/github.com/Sirupsen/logrus/writer.go b/vendor/github.com/sirupsen/logrus/writer.go similarity index 100% rename from vendor/github.com/Sirupsen/logrus/writer.go rename to vendor/github.com/sirupsen/logrus/writer.go