Skip to content

Update Bazel build rules and remove unmaintained travis config #783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 20, 2025
Merged
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ jobs:
# version: v1.30.0
- run: make all
- name: Install goveralls
env:
GO111MODULE: off
run: |
export GOPATH=$GITHUB_WORKSPACE
go get github.com/mattn/goveralls
go install github.com/mattn/goveralls@v0.0.12
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bin/goveralls -coverprofile=coverage.out -service=github
run: |
./bin/goveralls -coverprofile=coverage.out -service=github

goreleaser:
name: Goreleaser
Expand Down
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@bazel_gazelle//:def.bzl",
"gazelle",
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

# gazelle:prefix github.com/google/go-jsonnet
gazelle(
Expand All @@ -13,6 +13,7 @@ go_library(
name = "go_default_library",
srcs = [
"builtins.go",
"debugger.go",
"doc.go",
"error_formatter.go",
"imports.go",
Expand All @@ -32,6 +33,7 @@ go_library(
"//internal/errors:go_default_library",
"//internal/parser:go_default_library",
"//internal/program:go_default_library",
"//toolutils:go_default_library",
"@io_k8s_sigs_yaml//:go_default_library",
"@org_golang_x_crypto//sha3:go_default_library",
],
Expand Down
20 changes: 18 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
module(name = "jsonnet_go", version = "0.0.0")

bazel_dep(name = "gazelle", version = "0.37.0", repo_name = "bazel_gazelle")
bazel_dep(name = "jsonnet", version = "0.20.0", repo_name = "cpp_jsonnet")
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# NB: update_cpp_jsonnet.sh looks for these.
CPP_JSONNET_SHA256 = "e7d14d8ad65dc334b9a9f3bd1c542a82b3b80029860a8d78fd829b23d0e9845b"
CPP_JSONNET_GITHASH = "5a4e8e34cc1fe841bdebb983646b9b9ae8fa8ca4"

# We don't use a normal bazel_dep reference for the cpp_jsonnet module,
# because we want to pin to the specific jsonnet commit (which might not
# even exactly match a released version).
http_archive(
name = "cpp_jsonnet",
sha256 = CPP_JSONNET_SHA256,
strip_prefix = "jsonnet-%s" % CPP_JSONNET_GITHASH,
urls = ["https://github.com/google/jsonnet/archive/%s.tar.gz" % CPP_JSONNET_GITHASH],
)

bazel_dep(name = "gazelle", version = "0.41.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.48.0", repo_name = "io_bazel_rules_go")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
Expand All @@ -11,4 +26,5 @@ use_repo(
"com_github_fatih_color",
"com_github_sergi_go_diff",
"io_k8s_sigs_yaml",
"org_golang_x_crypto",
)
32 changes: 15 additions & 17 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
load(
"@io_bazel_rules_go//go:deps.bzl",
"go_register_toolchains",
"go_rules_dependencies",
)
load(
"@bazel_gazelle//:deps.bzl",
"gazelle_dependencies",
"go_repository",
)
load(
"@io_bazel_rules_go//go:deps.bzl",
"go_register_toolchains",
"go_rules_dependencies",
)

def jsonnet_go_dependencies(go_sdk_version = "host"):
go_rules_dependencies()
go_register_toolchains(version = go_sdk_version)
gazelle_dependencies()
go_register_toolchains(version = go_sdk_version)
go_repository(
name = "com_github_davecgh_go_spew",
importpath = "github.com/davecgh/go-spew",
Expand All @@ -26,7 +25,6 @@ def jsonnet_go_dependencies(go_sdk_version = "host"):
sum = "h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=",
version = "v1.12.0",
)

go_repository(
name = "com_github_kr_pretty",
importpath = "github.com/kr/pretty",
Expand Down Expand Up @@ -104,31 +102,31 @@ def jsonnet_go_dependencies(go_sdk_version = "host"):
go_repository(
name = "org_golang_x_crypto",
importpath = "golang.org/x/crypto",
sum = "h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=",
version = "v0.9.0",
sum = "h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=",
version = "v0.17.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_sys",
importpath = "golang.org/x/sys",
sum = "h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=",
version = "v0.8.0",
sum = "h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=",
version = "v0.15.0",
)
go_repository(
name = "org_golang_x_term",
importpath = "golang.org/x/term",
sum = "h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=",
version = "v0.8.0",
sum = "h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=",
version = "v0.15.0",
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=",
version = "v0.9.0",
sum = "h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=",
version = "v0.14.0",
)
go_rules_dependencies()
4 changes: 2 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ load(
)

# NB: update_cpp_jsonnet.sh looks for these.
CPP_JSONNET_SHA256 = "9e545f17b614c89d40d1f58d7f8fceded4cc93d1d29edfd8a93833b61201fd20"
CPP_JSONNET_GITHASH = "4487bfb8ba7ed7a3d91d79d4a1aa2205e7839558"
CPP_JSONNET_SHA256 = "e7d14d8ad65dc334b9a9f3bd1c542a82b3b80029860a8d78fd829b23d0e9845b"
CPP_JSONNET_GITHASH = "5a4e8e34cc1fe841bdebb983646b9b9ae8fa8ca4"

def jsonnet_go_repositories():
http_archive(
Expand Down
12 changes: 10 additions & 2 deletions formatter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
Expand All @@ -7,7 +7,15 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//ast:go_default_library",
"//internal/parser:go_default_library",
"//internal/formatter:go_default_library",
"//internal/parser:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["formatter_test.go"],
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = ["//internal/testutils:go_default_library"],
)
8 changes: 4 additions & 4 deletions python/_jsonnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static struct JsonnetJsonValue *cpython_native_callback(
}

// Call python function.
result = PyEval_CallObject(ctx->callback, arglist);
result = PyObject_CallObject(ctx->callback, arglist);
Py_DECREF(arglist);

if (result == NULL) {
Expand Down Expand Up @@ -226,7 +226,7 @@ static int cpython_import_callback(void *ctx_, const char *base, const char *rel

PyEval_RestoreThread(*ctx->py_thread);
arglist = Py_BuildValue("(s, s)", base, rel);
result = PyEval_CallObject(ctx->callback, arglist);
result = PyObject_CallObject(ctx->callback, arglist);
Py_DECREF(arglist);

if (result == NULL) {
Expand Down Expand Up @@ -255,7 +255,7 @@ static int cpython_import_callback(void *ctx_, const char *base, const char *rel
success = 0;
} else {
char *content_buf;
ssize_t content_len;
Py_ssize_t content_len;
#if PY_MAJOR_VERSION >= 3
const char *found_here_cstr = PyUnicode_AsUTF8(file_name);
#else
Expand Down Expand Up @@ -665,7 +665,7 @@ static struct PyModuleDef _module =

PyMODINIT_FUNC PyInit__gojsonnet(void)
{
PyObject *module = PyModule_Create(&_module);
PyObject *module = PyModule_Create(&_module);
PyObject *version_str = PyUnicode_FromString(LIB_JSONNET_VERSION);
if (PyModule_AddObject(module, "version", PyUnicode_FromString(LIB_JSONNET_VERSION)) < 0) {
Py_XDECREF(version_str);
Expand Down
15 changes: 0 additions & 15 deletions travisBazel.sh

This file was deleted.

10 changes: 0 additions & 10 deletions travisBuild.sh

This file was deleted.

3 changes: 2 additions & 1 deletion update_cpp_jsonnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ sha256=$(curl -fL https://github.com/google/jsonnet/archive/$hash.tar.gz | shasu
sed -i.bak \
-e "s/CPP_JSONNET_SHA256 = .*/CPP_JSONNET_SHA256 = \"$sha256\"/;" \
-e "s/CPP_JSONNET_GITHASH = .*/CPP_JSONNET_GITHASH = \"$hash\"/;" \
bazel/repositories.bzl
bazel/repositories.bzl MODULE.bazel

# NB: macOS sed doesn't support -i without arg. This is the easy workaround.
rm bazel/repositories.bzl.bak
rm MODULE.bazel.bak

set +x
echo
Expand Down
Loading