Skip to content

Commit

Permalink
build(deps): migrate rules_ruby to bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
satreix authored Jul 12, 2024
1 parent 57e4ec1 commit ab9ec82
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 93 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,12 @@ jobs:
distribution: "zulu"
java-version: "21"

# Ruby rules use host install still: https://github.com/bazelruby/rules_ruby/issues/112
- name: "[Ruby] Install Ruby"
uses: ruby/setup-ruby@v1.185.0

- name: Versions
run: |
echo "--> bazel"
bazel version
echo "--> java"
java --version
echo "--> ruby"
ruby --version
- name: Copy .bazelrc
run: cp tools/ci/bazel.rc $HOME/.bazelrc
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.3
jruby-9.4.8.0
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ GEM
specs:
ast (2.4.2)
cgi (0.3.6)
cgi (0.3.6-java)
diff-lcs (1.5.1)
erb (4.0.4)
cgi (>= 0.3.3)
erb (4.0.4-java)
cgi (>= 0.3.3)
haml (5.2.2)
temple (>= 0.8.0)
tilt
json (2.7.2)
json (2.7.2-java)
language_server-protocol (3.17.0.3)
parallel (1.25.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
racc (1.8.0)
racc (1.8.0-java)
rainbow (3.1.1)
regexp_parser (2.9.2)
rexml (3.3.1)
Expand Down Expand Up @@ -56,12 +61,14 @@ GEM
temple (~> 0.10.0)
tilt (>= 2.1.0)
strscan (3.1.0)
strscan (3.1.0-java)
temple (0.10.3)
tilt (2.3.0)
unicode-display_width (2.5.0)

PLATFORMS
arm64-darwin-22
universal-java-21
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
Expand Down
52 changes: 52 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,58 @@ bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_cue", version = "0.7.0")
bazel_dep(name = "rules_foreign_cc", version = "0.11.1")
bazel_dep(name = "rules_go", version = "0.48.1", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_ruby", version = "0.11.0")

ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby")
ruby.toolchain(
name = "ruby",
version_file = "//:.ruby-version",
)
use_repo(ruby, "ruby")
ruby.bundle_fetch(
name = "bundle",
gem_checksums = {
"ast-2.4.2": "1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12",
"cgi-0.3.6": "c5e2c301437116b28fdfbb565452b9c1ee597901e68611367b4126b5d10feca3",
"cgi-0.3.6-java": "f94886a613c101f2f60c2e33ea8a42d6ad0b9a5fcda3d550e01f35b0271585af",
"diff-lcs-1.5.1": "273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe",
"erb-4.0.4": "de116e106205c46bc01918789b611aaad1328dcc6e9f12cf8cd2cc60ef619717",
"erb-4.0.4-java": "3767088f230194a84316a5879f0c3dc5f2a96fb1c9a198c3e27d3f35d416c597",
"haml-5.2.2": "6e759246556145642ef832d670fc06f9bd8539159a0e600847a00291dd7aae0c",
"json-2.7.2": "1898b5cbc81cd36c0fd4d0b7ad2682c39fb07c5ff682fc6265f678f550d4982c",
"json-2.7.2-java": "138e3038b5361b3d06ee2e8aa2be00bed0d0de4ef5f1553fc5935e5b93aca7ee",
"language_server-protocol-3.17.0.3": "3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f",
"parallel-1.25.1": "12e089b9aa36ea2343f6e93f18cfcebd031798253db8260590d26a7f70b1ab90",
"parser-3.3.3.0": "a2e23c90918d9b7e866b18dca2b6835f227769dd2fa8e59c5841f3389cf53eeb",
"racc-1.8.0": "09349a65c37c4fe710a435f25c9f1652e39f29ad6b1fa08d4a8d30c0553d3a08",
"racc-1.8.0-java": "3688448632150682bbd708b199961129aed2266107e26fcacb45c997395c19f9",
"rainbow-3.1.1": "039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a",
"regexp_parser-2.9.2": "5a27e767ad634f8a4b544520d5cd28a0db7aa1198a5d7c9d7e11d7b3d9066446",
"rexml-3.3.1": "34af9fb38eff6c451abd187c53fded98378aa91766d4c62fbbce10e40ed7c325",
"rspec-3.13.0": "d490914ac1d5a5a64a0e1400c1d54ddd2a501324d703b8cfe83f458337bab993",
"rspec-core-3.13.0": "557792b4e88da883d580342b263d9652b6a10a12d5bda9ef967b01a48f15454c",
"rspec-expectations-3.13.0": "621d48c62262f955421eaa418130744760802cad47e781df70dba4d9f897102e",
"rspec-its-1.3.0": "4da51040e7820daafd40f2f6216d13c90aa949f0d302a0412c9ef6074e73ea97",
"rspec-mocks-3.13.0": "735a891215758d77cdb5f4721fffc21078793959d1f0ee4a961874311d9b7f66",
"rspec-support-3.13.0": "0e725f53b8c20ce75913a5da7bf06bf90698266951f3b1e3ae7bcd9612775257",
"rubocop-1.64.1": "3145bf1863771e400a1c041060e751e5ff0edd9ceb99d01df36db1902f611f3b",
"rubocop-ast-1.31.3": "1b07d618d8776993ec6053a706d1c09f0bf15139fd69415924656cbff07e7818",
"rubocop-rspec-3.0.2": "95fb61205015b16e2a5416a5b00c035cb725a22a12462cfbd4cab920930d2d8f",
"ruby-progressbar-1.13.0": "80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33",
"slim-5.2.1": "72351dff7e2ff20e2d5c393cfc385bb9142cef5db059141628fd7163ac3c13e7",
"strscan-3.1.0": "01b8a81d214fbf7b5308c6fb51b5972bbfc4a6aa1f166fd3618ba97e0fcd5555",
"strscan-3.1.0-java": "8645aa76e017e21764c6df572d2d79fcc1672284014f5bdbd806278cdbcd11b0",
"temple-0.10.3": "df3145fe6577af1e25387eb7f7122d32ed51bdb6f2e7bb0f4fbf07b66151913b",
"tilt-2.3.0": "82dd903d61213c63679d28e404ee8e10d1b0fdf5270f1ad0898ec314cc3e745c",
"unicode-display_width-2.5.0": "7e7681dcade1add70cb9fda20dd77f300b8587c81ebbd165d14fd93144ff0ab4",
},
gemfile = "//:Gemfile",
gemfile_lock = "//:Gemfile.lock",
)
use_repo(ruby, "bundle", "ruby_toolchains")

register_toolchains("@ruby_toolchains//:all")

bazel_dep(name = "rules_rust", version = "0.46.0")

# rules_rust 0.45.1 does not work with protobuf 23.1 and this breaks `bazel test src/rust/...`
Expand Down
87 changes: 87 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ workspace(name = "everest")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazelruby_rules_ruby",
patch_args = ["-p1"],
patches = [
# A fix for https://github.com/bazelruby/rules_ruby/issues/79
"//third_party/bazelruby_rules_ruby:0001-fix-rspec.patch",
],
sha256 = "33217f27c7cc44355dc82bbe172d0ace09c6a73da387bbbcd66cff013d35e498",
strip_prefix = "rules_ruby-8a03f6c54f1bb3ecbbb82c8e2fdbf40e049a8115",
url = "https://github.com/bazelruby/rules_ruby/archive/8a03f6c54f1bb3ecbbb82c8e2fdbf40e049a8115.tar.gz",
)

http_archive(
name = "com_github_antlr_grammars_v4",
build_file_content = """exports_files(glob(["**/*.g4"]), visibility = ["//visibility:public"])""",
Expand Down Expand Up @@ -87,18 +75,3 @@ openapi_tools_generator_bazel_repositories(
openapi_generator_cli_version = "5.4.0",
sha256 = "f3ed312310e390324b33ba2ffff290ce812935207a1493ec5c098d0a441be51c",
)

load("@bazelruby_rules_ruby//ruby:deps.bzl", "rules_ruby_dependencies", "rules_ruby_select_sdk")

rules_ruby_dependencies()

rules_ruby_select_sdk()

load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle")

ruby_bundle(
name = "bundle",
bundler_version = "2.5.3",
gemfile = "//:Gemfile",
gemfile_lock = "//:Gemfile.lock",
)
25 changes: 19 additions & 6 deletions src/ruby/hello_world/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_binary", "ruby_rspec")
load("@rules_ruby//ruby:defs.bzl", "rb_binary", "rb_test")
load("//tools/test/binary:binary.bzl", "binary_test")

ruby_binary(
rb_binary(
name = "hello_world",
srcs = ["hello_world.rb"],
main = "hello_world.rb",
deps = [
"//src/ruby/hello_world/lib:hello",
],
)

ruby_rspec(
name = "hello_spec_test",
specs = ["//src/ruby/hello_world:spec/hello_spec.rb"],
deps = ["//src/ruby/hello_world/lib:hello"],
rb_test(
name = "rubocop_test",
timeout = "short",
args = [
"src/ruby/hello_world/",
"src/ruby/hello_world/lib/",
"src/ruby/hello_world/spec/",
],
main = "@bundle//bin:rubocop",
tags = ["no-sandbox"],
deps = [
":hello_world",
"//src/ruby/hello_world/lib:hello",
"//src/ruby/hello_world/spec:hello_test",
"@bundle",
],
)

binary_test(
Expand Down
4 changes: 2 additions & 2 deletions src/ruby/hello_world/lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_library")
load("@rules_ruby//ruby:defs.bzl", "rb_library")

ruby_library(
rb_library(
name = "hello",
srcs = ["hello.rb"],
visibility = ["//src/ruby/hello_world:__subpackages__"],
Expand Down
14 changes: 14 additions & 0 deletions src/ruby/hello_world/spec/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_ruby//ruby:defs.bzl", "rb_test")

rb_test(
name = "hello_test",
timeout = "short",
srcs = ["hello_spec.rb"],
args = ["src/ruby/hello_world/spec/"],
main = "@bundle//bin:rspec",
visibility = ["//src/ruby/hello_world:__subpackages__"],
deps = [
"//src/ruby/hello_world/lib:hello",
"@bundle",
],
)
34 changes: 19 additions & 15 deletions src/ruby/template/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_binary", "ruby_library", "ruby_rspec")
load("@rules_ruby//ruby:defs.bzl", "rb_binary", "rb_test")

ruby_binary(
rb_binary(
name = "template",
srcs = ["template.rb"],
data = glob(["templates/**"]),
main = "template.rb",
visibility = ["//src/ruby/template/spec:__pkg__"],
deps = [
"@bundle//:erb",
"@bundle//:haml",
"@bundle//:slim",
"@bundle",
],
)

ruby_library(
name = "empty",
srcs = ["empty.rb"],
)

ruby_rspec(
name = "template_spec_test",
data = [":template"],
specs = ["//src/ruby/template:spec/template_spec.rb"],
deps = [":empty"], # hack to make rspec happy, not used
rb_test(
name = "rubocop_test",
timeout = "short",
args = [
"src/ruby/template/",
"src/ruby/template/spec/",
],
main = "@bundle//bin:rubocop",
tags = ["no-sandbox"],
deps = [
":template",
"//src/ruby/template/spec:template_test",
"@bundle",
],
)
1 change: 0 additions & 1 deletion src/ruby/template/empty.rb

This file was deleted.

14 changes: 14 additions & 0 deletions src/ruby/template/spec/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_ruby//ruby:defs.bzl", "rb_test")

rb_test(
name = "template_test",
timeout = "short",
srcs = ["template_spec.rb"],
args = ["src/ruby/template/spec/"],
data = ["//src/ruby/template"],
main = "@bundle//bin:rspec",
visibility = ["//src/ruby/template:__subpackages__"],
deps = [
"@bundle",
],
)
4 changes: 1 addition & 3 deletions src/ruby/template/spec/template_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require_relative '../template'

EXPECTED_OUTPUT = "=== ERB ===
<h1>Hello, ERB!</h1>
=== Haml ===
Expand All @@ -12,7 +10,7 @@

RSpec.describe 'template', 'main' do # rubocop:disable RSpec/DescribeClass, RSpec/DescribeMethod
it 'renders templates' do
expect { system %(./src/ruby/template/template) }
expect { system %(./src/ruby/template/template.sh) }
.to output(EXPECTED_OUTPUT)
.to_stdout_from_any_process
end
Expand Down
Loading

0 comments on commit ab9ec82

Please sign in to comment.