Skip to content

Commit 2d364d8

Browse files
committed
Upgrading bazel and ruby
1 parent c93a681 commit 2d364d8

File tree

12 files changed

+45
-18
lines changed

12 files changed

+45
-18
lines changed

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.0
1+
5.2.0

.circleci/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# rules_ruby circleci Docker file.
33
#
4-
FROM ruby:3.0.2
4+
FROM ruby:3.1.2
55

66
# make Apt non-interactive
77
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \

.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
3.1.2

WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ load("@bazel_skylib//lib:versions.bzl", "versions")
1212

1313
versions.check("3.4.1")
1414

15-
rules_ruby_select_sdk("3.0.2")
15+
rules_ruby_select_sdk("3.1.2")
1616

1717
local_repository(
1818
name = "bazelruby_rules_ruby_ruby_tests_testdata_another_workspace",

bin/setup

+18-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
source "bin/deps"
1818

19+
export ruby_version="$(cat .ruby-version | tr -d '\n')"
20+
1921
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————
2022
# Private Functions
2123
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————
@@ -30,8 +32,19 @@ __setup.actions() {
3032
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————
3133

3234
setup.rbenv() {
35+
command -v rbenv >/dev/null || {
36+
if [[ $(uname -s) == "Darwin" ]]; then
37+
command -v brew>/dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
38+
brew.install.packages rbenv ruby-build
39+
brew.upgrade.packages rbenv ruby-build
40+
else
41+
setup.local-rbenv
42+
fi
43+
}
44+
}
45+
46+
setup.local-rbenv() {
3347
local rbenv_home="${HOME}/.rbenv"
34-
local ruby_version="$(cat .ruby-version | tr -d '\n')"
3548

3649
if [[ -n $(command -v ruby) ]]; then
3750
local installed_version="$(ruby -e 'puts RUBY_VERSION' | tr -d '\n')"
@@ -65,9 +78,10 @@ setup.rbenv() {
6578
error "PATH: ${PATH}"
6679
return 1
6780
}
81+
}
6882

69-
# Set our current ruby version to the desired one, even if it's not yet there.
70-
# This allows the next block to auto-detect it and skip the remainder.
83+
setup.ruby() {
84+
run "rbenv install -s ${ruby_version}"
7185
run "rbenv global ${ruby_version} || true"
7286
# see if we even need to install anything:
7387
local ruby_sdk_marker="$(rbenv versions | grep "${ruby_version}" | cut -d ' ' -f 1)"
@@ -171,6 +185,7 @@ setup.main() {
171185
set +e
172186
h2 "Installing required development dependencies for working with rules_ruby and Bazel."
173187
setup.rbenv
188+
setup.ruby
174189
setup.gems
175190
[[ -z ${CI} ]] && setup.git-hook
176191
setup.os-specific "$@"

bin/setup-darwin

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
# vim: ft=bash
23
# —————————————————————————————————————————————————————————————————————————————————————
34
# NOTE: These setup scripts rely on an open source BASH framework BashMatic.
45
# https://github.com/kigster/bashmatic
@@ -52,24 +53,21 @@ setup.xcode-tools() {
5253
info: "xcode-select tools are already installed."
5354
fi
5455

55-
info "Next command requires sudo privileges to accept XCode License"
56-
run.set-next show-output-on
57-
run "sudo xcodebuild -license accept"
56+
info "Next command may require a sudo privileges to accept XCode License"
57+
bin/xcode-accept
5858
}
5959

6060
setup.bazel() {
6161
brew.package.is-installed bazelisk &&
62-
brew.uninstall.package bazelisk &&
63-
run "brew unlink bazel"
62+
brew.uninstall.package bazelisk 1>/dev/null 2>/dev/null &&
63+
run "brew unlink bazel 2>/dev/null || true"
6464

6565
if __setup.is-bazelisk-installed && __setup.is-bazel-installed ; then
6666
info: "Bazel & bazelisk are already installed."
6767
else
6868
brew.install.packages bazel bazelisk
6969
run "brew link bazel || true"
7070
fi
71-
72-
7371
}
7472

7573
setup.darwin() {

bin/xcode-accept

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
# vim: ft=bash
3+
4+
# https://stackoverflow.com/questions/58632629/how-to-check-if-xcode-license-needs-to-be-accepted
5+
6+
XCODE_VERSION=$(xcodebuild -version | grep '^Xcode\s' | sed -E 's/^Xcode[[:space:]]+([0-9\.]+)/\1/')
7+
ACCEPTED_LICENSE_VERSION=$(defaults read /Library/Preferences/com.apple.dt.Xcode 2> /dev/null | grep IDEXcodeVersionForAgreedToGMLicense | cut -d '"' -f 2)
8+
9+
if [[ "$XCODE_VERSION" = "$ACCEPTED_LICENSE_VERSION" ]]; then
10+
exit 0
11+
else
12+
exit 1
13+
fi

examples/simple_rails_api/WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ load(
1515

1616
rules_ruby_dependencies()
1717

18-
rules_ruby_select_sdk(version = "3.0.2")
18+
rules_ruby_select_sdk(version = "3.1.2")
1919

2020
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
2121

examples/simple_script/.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
3.1.2

examples/simple_script/WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ load(
1515

1616
rules_ruby_dependencies()
1717

18-
rules_ruby_select_sdk(version = "3.0.2")
18+
rules_ruby_select_sdk(version = "3.1.2")
1919

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

ruby/private/sdk.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def rules_ruby_select_sdk(version = "host"):
2828
"3.0.3",
2929
"3.1.0",
3030
"3.1.1",
31+
"3.1.2",
3132
]
3233

3334
if version in supported_versions:

ruby/tests/testdata/bundle_includes_workspace/WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ load(
1313

1414
rules_ruby_dependencies()
1515

16-
rules_ruby_select_sdk(version = "3.0.2")
16+
rules_ruby_select_sdk(version = "3.1.2")
1717

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

0 commit comments

Comments
 (0)