Skip to content

Commit

Permalink
Merge pull request #52 from benchsci/bzlmod-support
Browse files Browse the repository at this point in the history
Implement bzlmod
  • Loading branch information
ewianda authored Jan 8, 2024
2 parents 615fd3a + 41c67e2 commit 6fb0bcc
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
6.4.0
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@ jobs:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel test //...
test_bzlmod:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Mount bazel caches
uses: actions/cache@v2
with:
path: |
"~/.cache/bazel"
"~/.cache/bazel-repo"
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', '**/*.js') }}
restore-keys: bazel-cache-
- name: bazel test //... --enable_bzlmod
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel test //... --enable_bzlmod
16 changes: 15 additions & 1 deletion .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@ NAME=rules_nodejs_gazelle
COMMIT=$(git rev-parse HEAD)
PREFIX=${NAME}-${COMMIT}
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${COMMIT} | gzip | shasum -a 256 | awk '{print $1}')
INTEGRITY=$(git archive --format=tar --prefix=${PREFIX}/ ${COMMIT} | gzip | openssl dgst -sha256 -binary | openssl base64 -A)

cat <<EOF
MODULE.bazel setup:
\`\`\`starlark
bazel_dep(name = "com_github_benchsci_rules_nodejs_gazelle", version = "0.0.0", repo_name = "com_github_benchsci_rules_nodejs_gazelle")
archive_override(
module_name = "com_github_benchsci_rules_nodejs_gazelle",
integrity = "sha256-${INTEGRITY}",
strip_prefix = "${PREFIX}",
urls = ["https://github.com/benchsci/rules_nodejs_gazelle/archive/$COMMIT.tar.gz"],
)
\`\`\`
cat << EOF
WORKSPACE setup:
\`\`\`starlark
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@

bazel-*
node_modules

go.sum
go.mod
30 changes: 30 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2019 The Bazel Authors. All rights reserved.
# Modifications copyright (C) 2021 BenchSci Analytics Inc.
# Modifications copyright (C) 2018 Ecosia GmbH

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
module(
name = "com_github_benchsci_rules_nodejs_gazelle",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "rules_go", version = "0.42.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.34.0", repo_name = "bazel_gazelle")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_bazelbuild_buildtools",
)
17 changes: 8 additions & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "bfc5ce70b9d1634ae54f4e7b495657a18a04e0d596785f672d35d5f505ab491a",
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
],
)

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

http_archive(
name = "bazel_gazelle",
sha256 = "b8b6d75de6e4bf7c41b7737b183523085f56283f6db929b86c5e7e1f09cf59c9",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.31.1/bazel-gazelle-v0.31.1.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.31.1/bazel-gazelle-v0.31.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

############################################################
Expand All @@ -52,6 +51,6 @@ gazelle_deps()

go_rules_dependencies()

go_register_toolchains(version = "1.19")
go_register_toolchains(version = "1.20.5")

gazelle_dependencies()
Empty file added WORKSPACE.bzlmod
Empty file.
90 changes: 28 additions & 62 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,33 @@ def gazelle_deps():
go_repository(
name = "com_github_bazelbuild_bazel_gazelle",
importpath = "github.com/bazelbuild/bazel-gazelle",
sum = "h1:ROyUyUHzoEdvoOs1e0haxJx1l5EjZX6AOqiKdVlaBbg=",
version = "v0.31.1",
sum = "h1:YHkwssgvCXDRU7sLCq1kGqaGYO9pKNR1Wku7UT2LhoY=",
version = "v0.34.0",
)
go_repository(
name = "com_github_bazelbuild_buildtools",
importpath = "github.com/bazelbuild/buildtools",
sum = "h1:Fl1FfItZp34QIQmmDTbZXHB5XA6JfbNNfH7tRRGWvQo=",
version = "v0.0.0-20230510134650-37bd1811516d",
sum = "h1:VUHCI4QRifAGYsbVJYqJndLf7YqV12YthB+PLFsEKqo=",
version = "v0.0.0-20231017121127-23aa65d4e117",
)
go_repository(
name = "com_github_bazelbuild_rules_go",
importpath = "github.com/bazelbuild/rules_go",
sum = "h1:i2HspGKiHMAnq2xIsp7sGJ7CiIlLlEKBtL1aogLJhEo=",
version = "v0.40.0",
sum = "h1:aY2smc3JWyUKOjGYmOKVLX70fPK9ON0rtwQojuIeUHc=",
version = "v0.42.0",
)

go_repository(
name = "com_github_bmatcuk_doublestar_v4",
importpath = "github.com/bmatcuk/doublestar/v4",
sum = "h1:HTuxyug8GyFbRkrffIpzNCSK4luc0TY3wzXvzIZhEXc=",
version = "v4.6.0",
sum = "h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=",
version = "v4.6.1",
)
go_repository(
name = "com_github_burntsushi_toml",
importpath = "github.com/BurntSushi/toml",
sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=",
version = "v0.3.1",
)

go_repository(
name = "com_github_census_instrumentation_opencensus_proto",
importpath = "github.com/census-instrumentation/opencensus-proto",
Expand Down Expand Up @@ -69,14 +67,6 @@ def gazelle_deps():
sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=",
version = "v0.3.4",
)

go_repository(
name = "com_github_emirpasic_gods",
importpath = "github.com/emirpasic/gods",
sum = "h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=",
version = "v1.18.1",
)

go_repository(
name = "com_github_envoyproxy_go_control_plane",
importpath = "github.com/envoyproxy/go-control-plane",
Expand All @@ -89,20 +79,12 @@ def gazelle_deps():
sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=",
version = "v0.1.0",
)

go_repository(
name = "com_github_fsnotify_fsnotify",
importpath = "github.com/fsnotify/fsnotify",
sum = "h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=",
version = "v1.6.0",
)
go_repository(
name = "com_github_ghodss_yaml",
importpath = "github.com/ghodss/yaml",
sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=",
version = "v1.0.0",
sum = "h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=",
version = "v1.7.0",
)

go_repository(
name = "com_github_golang_glog",
importpath = "github.com/golang/glog",
Expand All @@ -124,47 +106,27 @@ def gazelle_deps():
go_repository(
name = "com_github_google_go_cmp",
importpath = "github.com/google/go-cmp",
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=",
version = "v0.5.9",
sum = "h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=",
version = "v0.6.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_prometheus_client_model",
importpath = "github.com/prometheus/client_model",
sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=",
version = "v0.0.0-20190812154241-14fe0d1b01d4",
)
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",
importpath = "cloud.google.com/go",
sum = "h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=",
version = "v0.26.0",
)
go_repository(
name = "in_gopkg_check_v1",
importpath = "gopkg.in/check.v1",
sum = "h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=",
version = "v0.0.0-20161208181325-20d25e280405",
)
go_repository(
name = "in_gopkg_yaml_v2",
importpath = "gopkg.in/yaml.v2",
sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=",
version = "v2.4.0",
)

go_repository(
name = "net_starlark_go",
importpath = "go.starlark.net",
Expand Down Expand Up @@ -201,7 +163,6 @@ def gazelle_deps():
sum = "h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=",
version = "v0.0.0-20190308221718-c2843e01d9a2",
)

go_repository(
name = "org_golang_x_exp",
importpath = "golang.org/x/exp",
Expand All @@ -217,16 +178,15 @@ def gazelle_deps():
go_repository(
name = "org_golang_x_mod",
importpath = "golang.org/x/mod",
sum = "h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=",
version = "v0.10.0",
sum = "h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=",
version = "v0.14.0",
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=",
version = "v0.10.0",
sum = "h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=",
version = "v0.0.0-20210405180319-a5a99cb37ef4",
)

go_repository(
name = "org_golang_x_oauth2",
importpath = "golang.org/x/oauth2",
Expand All @@ -236,14 +196,14 @@ def gazelle_deps():
go_repository(
name = "org_golang_x_sync",
importpath = "golang.org/x/sync",
sum = "h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=",
version = "v0.2.0",
sum = "h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=",
version = "v0.4.0",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=",
version = "v0.8.0",
sum = "h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=",
version = "v0.14.0",
)
go_repository(
name = "org_golang_x_text",
Expand All @@ -254,8 +214,14 @@ def gazelle_deps():
go_repository(
name = "org_golang_x_tools",
importpath = "golang.org/x/tools",
sum = "h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=",
version = "v0.9.1",
sum = "h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=",
version = "v0.13.0",
)
go_repository(
name = "org_golang_x_tools_go_vcs",
importpath = "golang.org/x/tools/go/vcs",
sum = "h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4=",
version = "v0.1.0-deprecated",
)
go_repository(
name = "org_golang_x_xerrors",
Expand Down
16 changes: 16 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/bazelbuild/rules_python

go 1.19

require (
github.com/bazelbuild/bazel-gazelle v0.34.0
github.com/bazelbuild/buildtools v0.0.0-20231017121127-23aa65d4e117
github.com/bazelbuild/rules_go v0.42.0
)

require (
github.com/google/go-cmp v0.6.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect
)
Loading

0 comments on commit 6fb0bcc

Please sign in to comment.