diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9dff45b..ebd58bc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,11 +9,6 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v1 - with: - go-version: 1.17 - - name: Checkout code - uses: actions/checkout@v2 - - name: Run tests - run: go test ./... + - uses: actions/checkout@v3 + - uses: bazelbuild/setup-bazelisk@v2 + - run: bazel build //... diff --git a/.gitignore b/.gitignore index 109bcad..cdf2f13 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ waybar-issues + +# Bazel +bazel-** \ No newline at end of file diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..8d65c10 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@bazel_gazelle//:def.bzl", "gazelle") + +# gazelle:prefix github.com/andresterba/waybar-issues +gazelle(name = "gazelle") + +gazelle( + name = "gazelle-update-repos", + args = [ + "-from_file=go.mod", + "-to_macro=deps.bzl%go_dependencies", + "-prune", + "-build_file_proto_mode=disable_global", + ], + command = "update-repos", +) + +go_library( + name = "waybar-issues_lib", + srcs = ["main.go"], + importpath = "github.com/andresterba/waybar-issues", + visibility = ["//visibility:private"], + deps = [ + "//config", + "//provider", + ], +) + +go_binary( + name = "waybar-issues", + embed = [":waybar-issues_lib"], + visibility = ["//visibility:public"], +) diff --git a/Makefile b/Makefile index b023681..1b231fd 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,10 @@ BINARY_NAME=waybar-issues all: build run: build - ./$(BINARY_NAME) + ./bazel-bin/waybar-issues_/waybar-issues build: - $(GOBUILD) -o $(BINARY_NAME) + bazel build //... format: $(GOFORMAT) ./... test: - $(GOTEST) ./... -cover + bazel test //... --test_output=errors diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel new file mode 100644 index 0000000..7d38461 --- /dev/null +++ b/WORKSPACE.bazel @@ -0,0 +1,39 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + sha256 = "f2dcd210c7095febe54b804bb1cd3a58fe8435a909db2ec04e31542631cf715c", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip", + ], +) + +http_archive( + name = "bazel_gazelle", + sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + +############################################################ +# Define your own dependencies here using go_repository. +# Else, dependencies declared by rules_go/gazelle will be used. +# The first declaration of an external repository "wins". +############################################################ + +load("//:deps.bzl", "go_dependencies") + +# gazelle:repository_macro deps.bzl%go_dependencies +go_dependencies() + +go_rules_dependencies() + +go_register_toolchains(version = "1.18") + +gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bazel") diff --git a/config/BUILD.bazel b/config/BUILD.bazel new file mode 100644 index 0000000..c2cfb62 --- /dev/null +++ b/config/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "config", + srcs = ["config.go"], + importpath = "github.com/andresterba/waybar-issues/config", + visibility = ["//visibility:public"], +) + +go_test( + name = "config_test", + srcs = ["config_test.go"], + embed = [":config"], + data = ["config.test", "invalid_config.test"], +) \ No newline at end of file diff --git a/deps.bzl b/deps.bzl new file mode 100644 index 0000000..38807e5 --- /dev/null +++ b/deps.bzl @@ -0,0 +1,122 @@ +load("@bazel_gazelle//:deps.bzl", "go_repository") + +def go_dependencies(): + go_repository( + name = "com_github_elazarl_goproxy", + build_file_proto_mode = "disable_global", + importpath = "github.com/elazarl/goproxy", + sum = "h1:Am81SElhR3XCQBunTisljzNkNese2T1FiV8jP79+dqg=", + version = "v0.0.0-20201021153353-00ad82a08272", + ) + go_repository( + name = "com_github_elazarl_goproxy_ext", + build_file_proto_mode = "disable_global", + importpath = "github.com/elazarl/goproxy/ext", + sum = "h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=", + version = "v0.0.0-20190711103511-473e67f1d7d2", + ) + go_repository( + name = "com_github_gopherjs_gopherjs", + build_file_proto_mode = "disable_global", + importpath = "github.com/gopherjs/gopherjs", + sum = "h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=", + version = "v0.0.0-20181017120253-0766667cb4d1", + ) + go_repository( + name = "com_github_jarcoal_httpmock", + build_file_proto_mode = "disable_global", + importpath = "github.com/jarcoal/httpmock", + sum = "h1:F47ChZj1Y2zFsCXxNkBPwNNKnAyOATcdQibk0qEdVCE=", + version = "v1.1.0", + ) + go_repository( + name = "com_github_jtolds_gls", + build_file_proto_mode = "disable_global", + importpath = "github.com/jtolds/gls", + sum = "h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=", + version = "v4.20.0+incompatible", + ) + go_repository( + name = "com_github_parnurzeal_gorequest", + build_file_proto_mode = "disable_global", + importpath = "github.com/parnurzeal/gorequest", + sum = "h1:T/5x+/4BT+nj+3eSknXmCTnEVGSzFzPGdpqmUVVZXHQ=", + version = "v0.2.16", + ) + go_repository( + name = "com_github_pkg_errors", + build_file_proto_mode = "disable_global", + importpath = "github.com/pkg/errors", + sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", + version = "v0.9.1", + ) + go_repository( + name = "com_github_rogpeppe_go_charset", + build_file_proto_mode = "disable_global", + importpath = "github.com/rogpeppe/go-charset", + sum = "h1:BN/Nyn2nWMoqGRA7G7paDNDqTXE30mXGqzzybrfo05w=", + version = "v0.0.0-20180617210344-2471d30d28b4", + ) + go_repository( + name = "com_github_smartystreets_assertions", + build_file_proto_mode = "disable_global", + importpath = "github.com/smartystreets/assertions", + sum = "h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=", + version = "v0.0.0-20180927180507-b2de0cb4f26d", + ) + go_repository( + name = "com_github_smartystreets_goconvey", + build_file_proto_mode = "disable_global", + importpath = "github.com/smartystreets/goconvey", + sum = "h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=", + version = "v1.6.4", + ) + go_repository( + name = "io_moul_http2curl", + build_file_proto_mode = "disable_global", + importpath = "moul.io/http2curl", + sum = "h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8=", + version = "v1.0.0", + ) + go_repository( + name = "org_golang_x_crypto", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/crypto", + sum = "h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=", + version = "v0.0.0-20190308221718-c2843e01d9a2", + ) + go_repository( + name = "org_golang_x_net", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/net", + sum = "h1:vI32FkLJNAWtGD4BwkThwEy6XS7ZLLMHkSkYfF8M0W0=", + version = "v0.0.0-20220403103023-749bd193bc2b", + ) + go_repository( + name = "org_golang_x_sys", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/sys", + sum = "h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=", + version = "v0.0.0-20211216021012-1d35b9e2eb4e", + ) + go_repository( + name = "org_golang_x_term", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/term", + sum = "h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=", + version = "v0.0.0-20210927222741-03fcf44c2211", + ) + go_repository( + name = "org_golang_x_text", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/text", + sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=", + version = "v0.3.7", + ) + go_repository( + name = "org_golang_x_tools", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/tools", + sum = "h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=", + version = "v0.0.0-20190328211700-ab21143f2384", + ) diff --git a/provider/BUILD.bazel b/provider/BUILD.bazel new file mode 100644 index 0000000..e24fd4b --- /dev/null +++ b/provider/BUILD.bazel @@ -0,0 +1,23 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "provider", + srcs = [ + "github.go", + "gitlab.go", + "types.go", + ], + importpath = "github.com/andresterba/waybar-issues/provider", + visibility = ["//visibility:public"], + deps = ["@com_github_parnurzeal_gorequest//:go_default_library"], +) + +go_test( + name = "provider_test", + srcs = [ + "github_test.go", + "gitlab_test.go", + ], + embed = [":provider"], + deps = ["@com_github_jarcoal_httpmock//:go_default_library"], +)