Skip to content
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
18 changes: 18 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This is from Bazel's former travis setup, to avoid blowing up the RAM usage.
startup --host_jvm_args=-Xmx2500m
startup --host_jvm_args=-Xms2500m
test --ram_utilization_factor=10

# This is so we understand failures better
build --verbose_failures

# This is so we don't use sandboxed execution. Sandboxed execution
# runs stuff in a container, and since Travis already runs its script
# in a container (unless you require sudo in your .travis.yml) this
# fails to run tests.
build --spawn_strategy=standalone --genrule_strategy=standalone
test --test_strategy=standalone

# Below this line, .travis.yml will cat the default bazelrc.
# This is needed so Bazel starts with the base workspace in its
# package path.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
bazel-*
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ go:
- 1.11.x
- 1.12.x

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- wget
- pkg-config

before_install:
- wget https://github.com/bazelbuild/bazel/releases/download/0.28.1/bazel_0.28.1-linux-x86_64.deb
- sha256sum -c tools/bazel_0.28.1-linux-x86_64.deb.sha256
- sudo dpkg -i bazel_0.28.1-linux-x86_64.deb

before_script:
- go get -u honnef.co/go/tools/cmd/staticcheck

Expand Down
16 changes: 16 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/bongnv/kitgen
# gazelle:build_file_name BUILD,BUILD.bazel
gazelle(
name = "gazelle",
prefix = "github.cgom/bongnv/kitgen",
)

go_library(
name = "go_default_library",
srcs = ["doc.go"],
importpath = "github.com/bongnv/kitgen",
visibility = ["//visibility:public"],
)
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
[![Build Status](https://travis-ci.com/bongnv/kitgen.svg?branch=master)](https://travis-ci.com/bongnv/kitgen)[![codecov](https://codecov.io/gh/bongnv/kitgen/branch/master/graph/badge.svg)](https://codecov.io/gh/bongnv/kitgen)[![Go Report Card](https://goreportcard.com/badge/github.com/bongnv/kitgen)](https://goreportcard.com/report/github.com/bongnv/kitgen)[![GoDoc](https://godoc.org/github.com/bongnv/kitgen?status.svg)](https://godoc.org/github.com/bongnv/kitgen)[![GolangCI](https://golangci.com/badges/github.com/golangci/golangci-lint.svg)](https://golangci.com)

kitgen is a code generation utility that help to speed up building web-application with Golang

## Working with Bazel
Use following command to update & fix BUILD files:

$bazel run //:gazelle -- fix

Use the following command to add go_repository for external dependencies

$bazel run //:gazelle -- update-repos -from_file=go.mod

118 changes: 118 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# download go bazel tools
http_archive(
name = "io_bazel_rules_go",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.19.1/rules_go-0.19.1.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/0.19.1/rules_go-0.19.1.tar.gz",
],
sha256 = "8df59f11fb697743cbb3f26cfb8750395f30471e9eabde0d174c3aebc7a1cd39",
)

# download the gazelle tool
http_archive(
name = "bazel_gazelle",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz",
],
sha256 = "be9296bfd64882e3c08e3283c58fcb461fa6dd3c171764fcc4cf322f60615a9b",
)

# download docker tool
http_archive(
name = "io_bazel_rules_docker",
sha256 = "6dede2c65ce86289969b907f343a1382d33c14fbce5e30dd17bb59bb55bb6593",
strip_prefix = "rules_docker-0.4.0",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.4.0.tar.gz"],
)

# load go rules
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")

go_rules_dependencies()

go_register_toolchains()

# load gazelle rules
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

go_repository(
name = "com_github_davecgh_go_spew",
importpath = "github.com/davecgh/go-spew",
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
version = "v1.1.1",
)

go_repository(
name = "com_github_pallinder_go_randomdata",
importpath = "github.com/Pallinder/go-randomdata",
sum = "h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg=",
version = "v1.2.0",
)

go_repository(
name = "com_github_pmezard_go_difflib",
importpath = "github.com/pmezard/go-difflib",
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
version = "v1.0.0",
)

go_repository(
name = "com_github_stretchr_objx",
importpath = "github.com/stretchr/objx",
sum = "h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=",
version = "v0.1.0",
)

go_repository(
name = "com_github_stretchr_testify",
importpath = "github.com/stretchr/testify",
sum = "h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=",
version = "v1.3.0",
)

go_repository(
name = "org_golang_x_crypto",
importpath = "golang.org/x/crypto",
sum = "h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=",
version = "v0.0.0-20190308221718-c2843e01d9a2",
)

go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=",
version = "v0.0.0-20190620200207-3b0461eec859",
)

go_repository(
name = "org_golang_x_sync",
importpath = "golang.org/x/sync",
sum = "h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=",
version = "v0.0.0-20190423024810-112230192c58",
)

go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=",
version = "v0.0.0-20190215142949-d0b11bdaac8a",
)

go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
version = "v0.3.0",
)

go_repository(
name = "org_golang_x_tools",
importpath = "golang.org/x/tools",
sum = "h1:9hRk1xeL9LTT3yX/941DqeBz87XgHAQuj+TbimYJuiw=",
version = "v0.0.0-20190706070813-72ffa07ba3db",
)
15 changes: 15 additions & 0 deletions cmd/kitgen/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/bongnv/kitgen/cmd/kitgen",
visibility = ["//visibility:private"],
deps = ["//gen:go_default_library"],
)

go_binary(
name = "kitgen",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
33 changes: 33 additions & 0 deletions gen/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"data_parser.go",
"gen.go",
"generator.go",
"helpers.go",
"writer.go",
],
importpath = "github.com/bongnv/kitgen/gen",
visibility = ["//visibility:public"],
deps = [
"//templates:go_default_library",
"@org_golang_x_tools//go/packages:go_default_library",
"@org_golang_x_tools//imports:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = [
"gen_test.go",
"helpers_test.go",
"writer_test.go",
],
embed = [":go_default_library"],
deps = [
"@com_github_pallinder_go_randomdata//:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
],
)
8 changes: 8 additions & 0 deletions templates/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["z_bindata.go"],
importpath = "github.com/bongnv/kitgen/templates",
visibility = ["//visibility:public"],
)
8 changes: 8 additions & 0 deletions testdata/model/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["models.go"],
importpath = "github.com/bongnv/kitgen/testdata/model",
visibility = ["//visibility:public"],
)
12 changes: 12 additions & 0 deletions testdata/service/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = [
"service.go",
"z_noop_service.go",
],
importpath = "github.com/bongnv/kitgen/testdata/service",
visibility = ["//visibility:public"],
deps = ["//testdata/model:go_default_library"],
)