From 6db0a0598573303a2a695baf04212b2716d75628 Mon Sep 17 00:00:00 2001 From: Marc Redemske Date: Sat, 27 May 2023 01:30:08 +0200 Subject: [PATCH] chore: add bazel to build --- .gitignore | 1 + BUILD.bazel | 9 +++ WORKSPACE | 36 ++++++++++++ build/BUILD.bazel | 1 + build/deps.bzl | 129 +++++++++++++++++++++++++++++++++++++++++ cmd/tvg/BUILD.bazel | 23 ++++++++ pkg/github/BUILD.bazel | 15 +++++ pkg/output/BUILD.bazel | 12 ++++ 8 files changed, 226 insertions(+) create mode 100644 .gitignore create mode 100644 BUILD.bazel create mode 100644 WORKSPACE create mode 100644 build/BUILD.bazel create mode 100644 build/deps.bzl create mode 100644 cmd/tvg/BUILD.bazel create mode 100644 pkg/github/BUILD.bazel create mode 100644 pkg/output/BUILD.bazel diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac51a05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bazel-* diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..4267cb1 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,9 @@ +load("@bazel_gazelle//:def.bzl", "gazelle") + +# gazelle:prefix github.com/mgred/tool-versions-generator +gazelle(name = "gazelle") + +alias( + name = "tvg", + actual = "//cmd/tvg:tvg", +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..8746e2d --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,36 @@ +workspace( + name = "tool_versions_generator", +) + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip", + ], +) + +http_archive( + name = "bazel_gazelle", + sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("//build:deps.bzl", "go_dependencies") + +# gazelle:repository_macro build/deps.bzl%go_dependencies +go_dependencies() + +go_rules_dependencies() + +go_register_toolchains(version = "1.19.3") + +gazelle_dependencies() diff --git a/build/BUILD.bazel b/build/BUILD.bazel new file mode 100644 index 0000000..e9659dd --- /dev/null +++ b/build/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["deps.bzl"]) diff --git a/build/deps.bzl b/build/deps.bzl new file mode 100644 index 0000000..59e3e2f --- /dev/null +++ b/build/deps.bzl @@ -0,0 +1,129 @@ +load("@bazel_gazelle//:deps.bzl", "go_repository") + +def go_dependencies(): + go_repository( + name = "com_github_bwesterb_go_ristretto", + importpath = "github.com/bwesterb/go-ristretto", + sum = "h1:1w53tCkGhCQ5djbat3+MH0BAQ5Kfgbt56UZQ/JMzngw=", + version = "v1.2.3", + ) + go_repository( + name = "com_github_cloudflare_circl", + importpath = "github.com/cloudflare/circl", + sum = "h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=", + version = "v1.3.3", + ) + go_repository( + name = "com_github_golang_protobuf", + importpath = "github.com/golang/protobuf", + sum = "h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=", + version = "v1.5.3", + ) + go_repository( + name = "com_github_google_go_cmp", + importpath = "github.com/google/go-cmp", + sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", + version = "v0.5.9", + ) + go_repository( + name = "com_github_google_go_github_v52", + importpath = "github.com/google/go-github/v52", + sum = "h1:uyGWOY+jMQ8GVGSX8dkSwCzlehU3WfdxQ7GweO/JP7M=", + version = "v52.0.0", + ) + go_repository( + name = "com_github_google_go_querystring", + importpath = "github.com/google/go-querystring", + sum = "h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=", + version = "v1.1.0", + ) + go_repository( + name = "com_github_protonmail_go_crypto", + importpath = "github.com/ProtonMail/go-crypto", + sum = "h1:ZK3C5DtzV2nVAQTx5S5jQvMeDqWtD1By5mOoyY/xJek=", + version = "v0.0.0-20230518184743-7afd39499903", + ) + go_repository( + name = "com_github_yuin_goldmark", + importpath = "github.com/yuin/goldmark", + sum = "h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=", + version = "v1.4.13", + ) + go_repository( + name = "com_google_cloud_go_compute_metadata", + importpath = "cloud.google.com/go/compute/metadata", + sum = "h1:nBbNSZyDpkNlo3DepaaLKVuO7ClyifSAmNloSCZrHnQ=", + version = "v0.2.0", + ) + go_repository( + name = "org_golang_google_appengine", + importpath = "google.golang.org/appengine", + sum = "h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=", + version = "v1.6.7", + ) + go_repository( + name = "org_golang_google_protobuf", + importpath = "google.golang.org/protobuf", + sum = "h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=", + version = "v1.30.0", + ) + go_repository( + name = "org_golang_x_crypto", + importpath = "golang.org/x/crypto", + sum = "h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=", + version = "v0.9.0", + ) + go_repository( + name = "org_golang_x_mod", + importpath = "golang.org/x/mod", + sum = "h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=", + version = "v0.8.0", + ) + go_repository( + name = "org_golang_x_net", + importpath = "golang.org/x/net", + sum = "h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=", + version = "v0.10.0", + ) + go_repository( + name = "org_golang_x_oauth2", + importpath = "golang.org/x/oauth2", + sum = "h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8=", + version = "v0.8.0", + ) + go_repository( + name = "org_golang_x_sync", + importpath = "golang.org/x/sync", + sum = "h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=", + version = "v0.1.0", + ) + go_repository( + name = "org_golang_x_sys", + importpath = "golang.org/x/sys", + sum = "h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=", + version = "v0.8.0", + ) + go_repository( + name = "org_golang_x_term", + importpath = "golang.org/x/term", + sum = "h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=", + version = "v0.8.0", + ) + go_repository( + name = "org_golang_x_text", + importpath = "golang.org/x/text", + sum = "h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=", + version = "v0.9.0", + ) + go_repository( + name = "org_golang_x_tools", + importpath = "golang.org/x/tools", + sum = "h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=", + version = "v0.6.0", + ) + go_repository( + name = "org_golang_x_xerrors", + importpath = "golang.org/x/xerrors", + sum = "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=", + version = "v0.0.0-20191204190536-9bdfabe68543", + ) diff --git a/cmd/tvg/BUILD.bazel b/cmd/tvg/BUILD.bazel new file mode 100644 index 0000000..8a07846 --- /dev/null +++ b/cmd/tvg/BUILD.bazel @@ -0,0 +1,23 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "tvg_lib", + srcs = [ + "app.go", + "flags.go", + "main.go", + "utils.go", + ], + importpath = "github.com/mgred/tool-versions-generator/cmd/tvg", + visibility = ["//visibility:private"], + deps = [ + "//pkg/github", + "//pkg/output", + ], +) + +go_binary( + name = "tvg", + embed = [":tvg_lib"], + visibility = ["//visibility:public"], +) diff --git a/pkg/github/BUILD.bazel b/pkg/github/BUILD.bazel new file mode 100644 index 0000000..af50caf --- /dev/null +++ b/pkg/github/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "github", + srcs = [ + "assets.go", + "client.go", + ], + importpath = "github.com/mgred/tool-versions-generator/pkg/github", + visibility = ["//visibility:public"], + deps = [ + "@com_github_google_go_github_v52//github", + "@org_golang_x_oauth2//:oauth2", + ], +) diff --git a/pkg/output/BUILD.bazel b/pkg/output/BUILD.bazel new file mode 100644 index 0000000..14bcff3 --- /dev/null +++ b/pkg/output/BUILD.bazel @@ -0,0 +1,12 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "output", + srcs = [ + "output.go", + "sha.go", + ], + importpath = "github.com/mgred/tool-versions-generator/pkg/output", + visibility = ["//visibility:public"], + deps = ["//pkg/github"], +)