From 6b930112063cb54e0e13d6ab0211ab8e381b0704 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 7 Jul 2021 17:37:19 -0700 Subject: [PATCH] Massive upgrade of everything at once ;-) (#105) * Massive upgrade of everything at once ;-) * Ruby 2.7.1 -> 3.0.1 * Bazel 3.4.1 -> 4.1.0 * Rules Ruby: 0.5.0 candidate Updated CircleCI Docker image to 3.0.1. * Upgrade Rubocop and add new rules * Update README & v0.5.0 * Fixes issue #81 --- .bazelversion | 2 +- .circleci/Dockerfile | 2 +- .circleci/config.yml | 2 +- .envrc | 3 + .ruby-version | 2 +- CHANGELOG.md | 31 +- Gemfile.lock | 24 +- README.md | 307 ++++++++---------- WORKSPACE | 4 +- bin/clean | 25 +- bin/deps | 13 +- bin/setup | 17 +- bin/setup-darwin | 8 +- bin/test-suite | 6 +- examples/example_gem/WORKSPACE | 2 +- examples/simple_rails_api/Gemfile.lock | 156 +++++---- examples/simple_rails_api/WORKSPACE | 2 +- examples/simple_script/.rubocop.yml | 3 +- examples/simple_script/Gemfile | 2 +- examples/simple_script/Gemfile.lock | 31 +- examples/simple_script/WORKSPACE | 4 +- .../bundle/create_bundle_build_file.rb | 3 + ruby/private/constants.bzl | 2 +- ruby/private/dependencies.bzl | 6 +- ruby/private/toolchains/ruby_runtime.bzl | 6 +- 25 files changed, 328 insertions(+), 335 deletions(-) diff --git a/.bazelversion b/.bazelversion index 47b322c..ee74734 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -3.4.1 +4.1.0 diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile index aaaf8c3..73c74c7 100644 --- a/.circleci/Dockerfile +++ b/.circleci/Dockerfile @@ -1,7 +1,7 @@ # # rules_ruby circleci Docker file. # -FROM ruby:2.7.1 +FROM ruby:3.0.1 # make Apt non-interactive RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \ diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e941be..a848906 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ jobs: working_directory: /home/circleci/repo resource_class: medium docker: - - image: bazelruby/ruby-2.7.1 + - image: bazelruby/ruby-3.0.1 environment: PATH: "/usr/local/bin:/usr/bin:/sbin:/opt/bin:/home/circleci/repo/bin:/bin:/sbin:/usr/sbin" BUNDLE_PATH: /home/circleci/.bundle_cache diff --git a/.envrc b/.envrc index 861e443..3b31e6f 100644 --- a/.envrc +++ b/.envrc @@ -10,3 +10,6 @@ PATH_add bin } } +eval "$(rbenv init -)" +rbenv local $(cat .ruby-version) +echo "Ruby Version is $(ruby --version)" diff --git a/.ruby-version b/.ruby-version index 860487c..cb2b00e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.1 +3.0.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index ce3607e..4bad943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,31 @@ # Changelog +## [Unreleased](https://github.com/bazelruby/rules_ruby/tree/HEAD) + +[Full Changelog](https://github.com/bazelruby/rules_ruby/compare/v0.4.1...HEAD) + +**Closed issues:** + +- ruby\_binary - how to package up runfiles dir [\#101](https://github.com/bazelruby/rules_ruby/issues/101) +- `warning: string literal in condition` from generated wrapper [\#87](https://github.com/bazelruby/rules_ruby/issues/87) +- ruby\_rspec specs argument not resolved [\#79](https://github.com/bazelruby/rules_ruby/issues/79) +- ruby\_test and ruby\_rspec rules use system ruby [\#63](https://github.com/bazelruby/rules_ruby/issues/63) + +**Merged pull requests:** + +- Support ruby 3 [\#103](https://github.com/bazelruby/rules_ruby/pull/103) ([mmizutani](https://github.com/mmizutani)) +- Bump nokogiri from 1.11.2 to 1.11.5 in /examples/simple\_rails\_api [\#99](https://github.com/bazelruby/rules_ruby/pull/99) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump nokogiri from 1.10.10 to 1.11.2 in /examples/simple\_rails\_api [\#94](https://github.com/bazelruby/rules_ruby/pull/94) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Update README.md [\#93](https://github.com/bazelruby/rules_ruby/pull/93) ([JustusFT](https://github.com/JustusFT)) +- Fix warning due to string literal in condition [\#91](https://github.com/bazelruby/rules_ruby/pull/91) ([russell](https://github.com/russell)) +- Add description for how to configure ASDF [\#90](https://github.com/bazelruby/rules_ruby/pull/90) ([russell](https://github.com/russell)) +- Remove print statements from ruby\_runtime.bzl [\#84](https://github.com/bazelruby/rules_ruby/pull/84) ([adzenith](https://github.com/adzenith)) +- Document path argument to ruby\_test [\#80](https://github.com/bazelruby/rules_ruby/pull/80) ([sayrer](https://github.com/sayrer)) + ## [v0.4.1](https://github.com/bazelruby/rules_ruby/tree/v0.4.1) (2020-08-10) [Full Changelog](https://github.com/bazelruby/rules_ruby/compare/v0.4.0...v0.4.1) - * Switched from `develop` to `master` as the base branch & updated README - ## [v0.4.0](https://github.com/bazelruby/rules_ruby/tree/v0.4.0) (2020-08-04) [Full Changelog](https://github.com/bazelruby/rules_ruby/compare/v0.3.0...v0.4.0) @@ -29,8 +49,8 @@ **Closed issues:** - 🐛 "Could not create symlink... \(File exists\)" [\#54](https://github.com/bazelruby/rules_ruby/issues/54) -- When using a local ruby installation it includes the local `LOAD\_PATH` [\#44](https://github.com/bazelruby/rules_ruby/issues/44) -- \[Cleanup\] Pretty sure `eval` is never used in `repository\_context` [\#43](https://github.com/bazelruby/rules_ruby/issues/43) +- When using a local ruby installation it includes the local `LOAD_PATH` [\#44](https://github.com/bazelruby/rules_ruby/issues/44) +- \[Cleanup\] Pretty sure `eval` is never used in `repository_context` [\#43](https://github.com/bazelruby/rules_ruby/issues/43) - Importing a bundle gem adds all gems onto the load path \(although they are not there\) [\#42](https://github.com/bazelruby/rules_ruby/issues/42) - Support Ruby Lambda with the Gemfile full of dependencies. [\#33](https://github.com/bazelruby/rules_ruby/issues/33) - Support AWS Ruby Lambda with Bazel Rules [\#27](https://github.com/bazelruby/rules_ruby/issues/27) @@ -55,13 +75,14 @@ **Fixed bugs:** -- Make `rules\_ruby/examples` a deeper tree structure and ensure CircleCI integration pass [\#10](https://github.com/bazelruby/rules_ruby/issues/10) +- Make `rules_ruby/examples` a deeper tree structure and ensure CircleCI integration pass [\#10](https://github.com/bazelruby/rules_ruby/issues/10) **Closed issues:** - Ability to package all files related to a bazel target in a zip file [\#29](https://github.com/bazelruby/rules_ruby/issues/29) - Build rules\_ruby on CircleCI using workflows \(in addition to Travis\) [\#26](https://github.com/bazelruby/rules_ruby/issues/26) - Restore functionality that supported symlinking an existing Ruby interpreter [\#21](https://github.com/bazelruby/rules_ruby/issues/21) +- Move ruby files under ruby\_rules/examples into a mini-mono repo [\#8](https://github.com/bazelruby/rules_ruby/issues/8) **Merged pull requests:** diff --git a/Gemfile.lock b/Gemfile.lock index 228e957..2004164 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,25 +1,25 @@ GEM remote: https://rubygems.org/ specs: - ast (2.4.1) - parallel (1.19.2) - parser (2.7.1.4) + ast (2.4.2) + parallel (1.20.1) + parser (3.0.1.1) ast (~> 2.4.1) rainbow (3.0.0) - regexp_parser (1.7.1) - rexml (3.2.4) - rubocop (0.88.0) + regexp_parser (2.1.1) + rexml (3.2.5) + rubocop (0.93.1) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 2.7.1.5) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) + regexp_parser (>= 1.8) rexml - rubocop-ast (>= 0.1.0, < 1.0) + rubocop-ast (>= 0.6.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.2.0) - parser (>= 2.7.0.1) - ruby-progressbar (1.10.1) + rubocop-ast (1.7.0) + parser (>= 3.0.1.1) + ruby-progressbar (1.11.0) unicode-display_width (1.7.0) PLATFORMS diff --git a/README.md b/README.md index 7cdb064..5e96a9f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ -# Rules Ruby Version 0.4.1 +# Rules Ruby Version 0.5.0 This is the README for Ruby Rules for the [Bazel Build](https://bazel.build) system. -## ATTENTION: Base Branch Change Announcement - -We recently switched from the base branch of `develop` to the base of `master`. Please update your local repos accordingly. - ### Build Status [![CircleCI](https://circleci.com/gh/bazelruby/rules_ruby.svg?style=shield)](https://circleci.com/gh/bazelruby/rules_ruby)   @@ -13,47 +9,13 @@ We recently switched from the base branch of `develop` to the base of `master`. ![activity](https://img.shields.io/github/commit-activity/m/bazelruby/rules_ruby?style=for-the-badge)   -- [Rules Development Status](#rules-development-status) -- [Usage](#usage) - - [`WORKSPACE` File](#workspace-file) - - [Load dependencies, select Ruby SDK and define one or more Bundles](#load-dependencies-select-ruby-sdk-and-define-one-or-more-bundles) - - [`BUILD.bazel` file(s)](#buildbazel-files) - - [Define Ruby Executable, Library and an RSpec](#define-ruby-executable-library-and-an-rspec) - - [Package Ruby files as a Gem](#package-ruby-files-as-a-gem) - - [Tool Specific Setup](#tool-specific-setup) - - [ASDF](#asdf) - - [Rule Dependency Diagram](#rule-dependency-diagram) -- [Rules](#rules) - - [`ruby_library`](#ruby_library) - - [`ruby_binary`](#ruby_binary) - - [`ruby_test`](#ruby_test) - - [`ruby_bundle`](#ruby_bundle) - - [Limitations](#limitations) - - [Conventions](#conventions) - - [`WORKSPACE`:](#workspace) - - [`BUILD.bazel`:](#buildbazel) - - [`ruby_rspec`](#ruby_rspec) - - [`ruby_gem`](#ruby_gem) -- [What's coming next](#whats-coming-next) -- [Contributing](#contributing) - - [Setup](#setup) - - [Using the Script](#using-the-script) - - [OS-Specific Setup](#os-specific-setup) - - [Issues During Setup](#issues-during-setup) - - [Developing Rules](#developing-rules) - - [Running Tests](#running-tests) - - [Test Script](#test-script) - - [Linter](#linter) -- [Copyright](#copyright) - - ### [Change Log](CHANGELOG.md) -To regenerate: +To regenerate, first you may need to grab an [API token](https://github.com/settings/tokens), and then: ```bash gem install github_changelog_generator -github_changelog_generator -u bazelruby -p rules_ruby +github_changelog_generator -u bazelruby -p rules_ruby -t your-github-token ``` ## Rules Development Status @@ -64,9 +26,42 @@ github_changelog_generator -u bazelruby -p rules_ruby | ![Wait](docs/img/status-wait.svg) | medium-sized Ruby on Rails apps, ideally in a mono-repo | | ![Not Ready](docs/img/status-not-ready.svg) | complex Ruby on Rails monoliths, single-repo | - Note: we have a short guide on [Building your first Ruby Project](https://github.com/bazelruby/rules_ruby/wiki/Build-your-ruby-project) on the Wiki. We encourage you to check it out. + +## Table of Contents + + + + + +- [Rules Ruby Version 0.5.0](#rules-ruby-version-050) + - [Build Status](#build-status) + - [Change Log](#change-logchangelogmd) + - [Rules Development Status](#rules-development-status) + - [Table of Contents](#table-of-contents) + - [Usage](#usage) + - [`WORKSPACE` File](#workspace-file) + - [`BUILD.bazel` file(s)](#buildbazel-files) + - [Tool Specific Setup](#tool-specific-setup) + - [Rule Dependency Diagram](#rule-dependency-diagram) + - [Rules](#rules) + - [`ruby_library`](#ruby_library) + - [`ruby_binary`](#ruby_binary) + - [`ruby_test`](#ruby_test) + - [`ruby_bundle`](#ruby_bundle) + - [`ruby_rspec`](#ruby_rspec) + - [`ruby_gem`](#ruby_gem) + - [What's coming next](#whats-coming-next) + - [Contributing](#contributing) + - [Setup](#setup) + - [Developing Rules](#developing-rules) + - [Running Tests](#running-tests) + - [Linter](#linter) + - [Copyright](#copyright) + + + ## Usage ### `WORKSPACE` File @@ -105,7 +100,7 @@ rules_ruby_dependencies() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() -rules_ruby_select_sdk(version = "2.7.1") +rules_ruby_select_sdk(version = "3.0.1") #——————————————————————————————————————————————————————————————————————— # Now, load the ruby_bundle rule & install gems specified in the Gemfile @@ -192,7 +187,7 @@ Use `ruby_gem` rule to package any number of ruby files or folders into a Ruby-G ```bazel load( "@bazelruby_rules_ruby//ruby:defs.bzl", - "ruby_gem", + "ruby_gem", ) ruby_gem( @@ -201,7 +196,7 @@ ruby_gem( gem_version = "0.1.0", gem_summary = "Example gem to demonstrate Bazel Gem packaging", gem_description = "Example gem to demonstrate Bazel Gem packaging", - gem_homepage = "https://github.com/bazelruby/rules_ruby", + gem_homepage = "https://github.com/bazelruby/rules_ruby", gem_authors = [ "BazelRuby", "Konstantin Gredeskoul" @@ -238,7 +233,8 @@ If you are using ASDF to manage your ruby installs, you can use them by adding ` build --test_env=ASDF_DIR --test_env=ASDF_DATA_DIR build --action_env=ASDF_DIR --test_env=ASDF_DATA_DIR ``` -You will have to be sure to export the `ASDF_DATA_DIR` in your profile since it's not set by default. e.g. `export ASDF_DATA_DIR="$HOME/.asdf"` + +You will have to be sure to export the `ASDF_DATA_DIR` in your profile since it's not set by default. e.g. `export ASDF_DATA_DIR="$HOME/.asdf"` ### Rule Dependency Diagram @@ -254,19 +250,19 @@ The following diagram attempts to capture the implementation behind `ruby_librar ```bazel ruby_library( - name, - deps, - srcs, - data, - compatible_with, - deprecation, - distribs, - features, - licenses, - restricted_to, - tags, - testonly, - toolchains, + name, + deps, + srcs, + data, + compatible_with, + deprecation, + distribs, + features, + licenses, + restricted_to, + tags, + testonly, + toolchains, visibility) ``` @@ -343,22 +339,22 @@ ruby_library( ```bazel ruby_binary( - name, - deps, - srcs, + name, + deps, + srcs, data, - main, - compatible_with, - deprecation, - distribs, - features, - licenses, - restricted_to, - tags, - testonly, - toolchains, - visibility, - args, + main, + compatible_with, + deprecation, + distribs, + features, + licenses, + restricted_to, + tags, + testonly, + toolchains, + visibility, + args, output_licenses ) ``` @@ -442,25 +438,25 @@ ruby_binary( ```bazel ruby_test( - name, - deps, - srcs, - data, - main, - compatible_with, - deprecation, - distribs, - features, - licenses, - restricted_to, - tags, - testonly, - toolchains, - visibility, - args, - size, - timeout, - flaky, + name, + deps, + srcs, + data, + main, + compatible_with, + deprecation, + distribs, + features, + licenses, + restricted_to, + tags, + testonly, + toolchains, + visibility, + args, + size, + timeout, + flaky, local, shard_count) ``` @@ -547,10 +543,10 @@ This rule installs gems defined in a Gemfile using Bundler, and exports individu ```bazel ruby_bundle( - name, - gemfile, - gemfile_lock, - bundler_version = "2.1.2", + name, + gemfile, + gemfile_lock, + bundler_version = "2.1.4", excludes = [], ruby_sdk = "@org_ruby_lang_ruby_toolchain", ruby_interpreter = "@org_ruby_lang_ruby_toolchain//:ruby", @@ -596,7 +592,7 @@ ruby_bundle( bundler_version String, optional -

The Version of Bundler to use. Defaults to 2.1.2.

+

The Version of Bundler to use. Defaults to 2.1.4.

NOTE: This rule never updates the Gemfile.lock. It is your responsibility to generate/update Gemfile.lock

@@ -611,10 +607,10 @@ Installing using a `Gemfile` that uses the `gemspec` keyword is not currently su `ruby_bundle` creates several targets that can be used downstream. In the examples below we assume that your `ruby_bundle` has a name `app_bundle`: - * `@app_bundle//:bundler` — references just the Bundler from the bundle. - * `@app_bundle//:gems` — references *all* gems in the bundle (i.e. "the entire bundle"). - * `@app_bundle//:gem-name` — references *just the specified* gem in the bundle, eg. `@app_bundle//:awesome_print`. - * `@app_bundle//:bin` — references to all installed executables from this bundle, with individual executables accessible via eg. `@app_bundle//:bin/rubocop` +- `@app_bundle//:bundler` — references just the Bundler from the bundle. +- `@app_bundle//:gems` — references _all_ gems in the bundle (i.e. "the entire bundle"). +- `@app_bundle//:gem-name` — references _just the specified_ gem in the bundle, eg. `@app_bundle//:awesome_print`. +- `@app_bundle//:bin` — references to all installed executables from this bundle, with individual executables accessible via eg. `@app_bundle//:bin/rubocop` #### `WORKSPACE`: @@ -623,7 +619,7 @@ load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle") ruby_bundle( name = "gems", - bundler_version = '2.1.2', + bundler_version = '2.1.4', gemfile = "//:Gemfile", gemfile_lock = "//:Gemfile.lock", ) @@ -655,28 +651,28 @@ ruby_binary( ```bazel ruby_rspec( - name, - deps, - srcs, - data, - main, - rspec_args, - bundle, - compatible_with, - deprecation, - distribs, - features, - licenses, - restricted_to, - tags, - testonly, - toolchains, - visibility, - args, - size, - timeout, - flaky, - local, + name, + deps, + srcs, + data, + main, + rspec_args, + bundle, + compatible_with, + deprecation, + distribs, + features, + licenses, + restricted_to, + tags, + testonly, + toolchains, + visibility, + args, + size, + timeout, + flaky, + local, shard_count ) ``` @@ -786,7 +782,6 @@ ruby_gem( data = data ) ``` - @@ -971,8 +966,8 @@ EXAMPLES: Note that the setup contains `os-specific` section. This is because there are two extension scripts: - * `bin/setup-linux` - * `bin/setup-darwin` +- `bin/setup-linux` +- `bin/setup-darwin` Those will install Bazel and everything else you need on either platform. In fact, we use the linux version on CI. @@ -984,9 +979,10 @@ Those will install Bazel and everything else you need on either platform. In fac Besides making yourself familiar with the existing code, and [Bazel documentation on writing rules](https://docs.bazel.build/versions/master/skylark/concepts.html), you might want to follow this order: - 1. Setup dev tools as described in the [setup](#Setup) section. - 3. hack, hack, hack... - 4. Make sure all tests pass — you can run a single command for that (but see more on it [below](#test-script). +1. Setup dev tools as described in the [setup](#Setup) section. +2. hack, hack, hack... +3. Make sure all tests pass — you can run a single command for that (but see more on it [below](#test-script). + ```bash bin/test-suite @@ -994,10 +990,10 @@ Besides making yourself familiar with the existing code, and [Bazel documentatio OR you can run individual Bazel test commands from the inside. - * `bazel test //...` - * `cd examples/simple_script && bazel test //...` +- `bazel test //...` +- `cd examples/simple_script && bazel test //...` - 4. Open a pull request in Github, and please be as verbose as possible in your description. +4. Open a pull request in Github, and please be as verbose as possible in your description. In general, it's always a good idea to ask questions first — you can do so by creating an issue. @@ -1047,7 +1043,7 @@ bin/linter [ all | buildifier | help | rubocop ] ## Copyright -© 2018-2019 Yuki Yugui Sonoda & BazelRuby Authors +© 2018-2019 Yuki Yugui Sonoda, Konstantin Gredeskoul, and BazelRuby Contributors 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 @@ -1056,44 +1052,3 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use 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. - - - - - - [Build Status](#build-status) - - [Change Log](#change-logchangelogmd) -- [ATTENTION: Base Branch Change Announcement](#attention-base-branch-change-announcement) - - [Build Status](#build-status) - - [Change Log](#change-log) -- [Rules Development Status](#rules-development-status) -- [Usage](#usage) - - [`WORKSPACE` File](#workspace-file) - - [Load dependencies, select Ruby SDK and define one or more Bundles](#load-dependencies-select-ruby-sdk-and-define-one-or-more-bundles) - - [`BUILD.bazel` file(s)](#buildbazel-files) - - [Define Ruby Executable, Library and an RSpec](#define-ruby-executable-library-and-an-rspec) - - [Package Ruby files as a Gem](#package-ruby-files-as-a-gem) - - [Rule Dependency Diagram](#rule-dependency-diagram) -- [Rules](#rules) - - [`ruby_library`](#ruby_library) - - [`ruby_binary`](#ruby_binary) - - [`ruby_test`](#ruby_test) - - [`ruby_bundle`](#ruby_bundle) - - [Limitations](#limitations) - - [Conventions](#conventions) - - [`WORKSPACE`:](#workspace) - - [`BUILD.bazel`:](#buildbazel) - - [`ruby_rspec`](#ruby_rspec) - - [`ruby_gem`](#ruby_gem) -- [What's coming next](#whats-coming-next) -- [Contributing](#contributing) - - [Setup](#setup) - - [Using the Script](#using-the-script) - - [OS-Specific Setup](#os-specific-setup) - - [Issues During Setup](#issues-during-setup) - - [Developing Rules](#developing-rules) - - [Running Tests](#running-tests) - - [Test Script](#test-script) - - [Linter](#linter) -- [Copyright](#copyright) - - diff --git a/WORKSPACE b/WORKSPACE index 028298d..20e7927 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,7 +12,7 @@ load("@bazel_skylib//lib:versions.bzl", "versions") versions.check("3.4.1") -rules_ruby_select_sdk("2.7.1") +rules_ruby_select_sdk("3.0.1") local_repository( name = "bazelruby_rules_ruby_ruby_tests_testdata_another_workspace", @@ -94,7 +94,7 @@ load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle") ruby_bundle( name = "bundle", - bundler_version = "2.1.2", + bundler_version = "2.1.4", excludes = { "mini_portile": ["test/**/*"], }, diff --git a/bin/clean b/bin/clean index 6171763..edfc3b5 100755 --- a/bin/clean +++ b/bin/clean @@ -1,38 +1,39 @@ #!/usr/bin/env bash # vim: ft=sh # ————————————————————————————————————————————————————————————————————————————————————— -# NOTE: These setup scripts rely on an open source BASH framework BashMatic. +# NOTE: These setup scripts rely on an open source BASH framework BASHMATIC_HOME. # https://github.com/kigster/bashmatic # # The framework is pretty light-weight, and is installed in your $HOME/.bashmatic folder. -# You can safely remove that folder after the setup if you wish, although re-running the +# You can safely remove that folder after the setup if you wish, although re-running the # setup will re-install it. # ————————————————————————————————————————————————————————————————————————————————————— -export BashMatic="${HOME}/.bashmatic" - -if [[ ! -f "${BashMatic}/init.sh" ]]; then - rm -rf "${BashMatic}" 2>/dev/null - git clone https://github.com/kigster/bashmatic "${BashMatic}" 1>/dev/null 2>&1 -fi +[[ -z ${BASHMATIC_HOME} ]] && export BASHMATIC_HOME="${HOME}/.bashmatic" +[[ -d ${BASHMATIC_HOME} ]] || bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install -q" # shellcheck disable=SC1090 -source "${BashMatic}/init.sh" 1>/dev/null 2>&1 +source "${BASHMATIC_HOME}/init.sh" 1>/dev/null 2>&1 + +export BAZEL_OPTS="--max_idle_secs=10800 --noshutdown_on_low_sys_mem --connect_timeout_secs=30" main() { - export BAZEL_OPTS="--max_idle_secs=10800 --noshutdown_on_low_sys_mem --connect_timeout_secs=30" h1 "Cleaning Bazel directories... Please wait." + # shellcheck disable=SC2207 local -a du_before=($(du -hs .)) run "bazel clean --expunge" - for dir in $(ls -1 examples); do + # shellcheck disable=SC2207 + local -a examples=($(ls -1 examples)) + for dir in "${examples[@]}"; do run "cd examples/${dir}" run "bazel clean --expunge" run "cd -" done + + # shellcheck disable=SC2207 local -a du_after=($(du -hs .)) h2 "Space before cleaning: ${bldylw}${du_before[0]}" \ "Space after cleaning: ${bldgrn}${du_after[0]}" } main "$@" - diff --git a/bin/deps b/bin/deps index 353492a..13688af 100755 --- a/bin/deps +++ b/bin/deps @@ -9,15 +9,14 @@ # setup will re-install it. # ————————————————————————————————————————————————————————————————————————————————————— -export BashMatic="${HOME}/.bashmatic" -if [[ ! -f "${BashMatic}/init.sh" ]]; then - rm -rf "${BashMatic}" 2>/dev/null - git clone https://github.com/kigster/bashmatic "${BashMatic}" 1>/dev/null 2>&1 -fi +[[ -z ${BASHMATIC_HOME} ]] && export BASHMATIC_HOME="${HOME}/.bashmatic" +[[ -d ${BASHMATIC_HOME} ]] || bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install -q" # shellcheck disable=SC1090 -source "${BashMatic}/init.sh" 1>/dev/null 2>&1 +source "${BASHMATIC_HOME}/init.sh" 1>/dev/null 2>&1 + +command -v rbenv >/dev/null && eval "$(rbenv init -)" __version.detect() { local file="$1" @@ -35,7 +34,7 @@ __version.detect() { # Application Constants export RulesRuby__RulesVersion="$(__version.detect .rules_version)" -export RulesRuby__RubyVersion="$(__version.detect .ruby_version)" +export RulesRuby__RubyVersion="$(__version.detect .ruby-version)" export RulesRuby__BazelVersion="$(__version.detect .bazelversion)" bazel-sha() { diff --git a/bin/setup b/bin/setup index f313335..c0799ca 100755 --- a/bin/setup +++ b/bin/setup @@ -41,21 +41,26 @@ setup.rbenv() { fi fi - [[ -d "${rbenv_home}" && -f "${rbenv_home}/bin/rbenv" ]] || { + [[ -d "${rbenv_home}" && -n "$(command -v rbenv)" ]] || { if [[ -z ${CI} ]]; then - warning "You are on a local system without any RBENV..." - run.ui.ask "Are you sure you want to wipe your local ~/.rbenv?" + warning "You are on a local system without any RBENV..." \ + "We are going to move your ~/.rbenv to a backup location and" \ + "install it from scratch to ensure it is up to date." + run.ui.ask "Should we proceed with building a new Ruby and backing up your ~/.rbenv?" fi - warning "Recreating RBENV home, downloading rbenv..." - run "rm -rf ${rbenv_home}" + [[ -d ${rbenv_home} ]] && { + local rbenv_backup="${rbenv_home}.backup.$(time.now.db)" + info "Moving your current ${rbenv_home} to ${bldylw}${rbenv_backup}" + run "mv -v ${rbenv_home} ${rbenv_backup}" + } run "git clone https://github.com/rbenv/rbenv.git ${rbenv_home}" export PATH="${rbenv_home}/bin:${rbenv_home}/shims:${PATH}" } export PATH="${rbenv_home}/bin:${rbenv_home}/shims:${PATH}" - [[ $(which rbenv) == "${rbenv_home}/bin/rbenv" ]] || { + [[ $(command -v rbenv) == "${rbenv_home}/bin/rbenv" || $(command -v rbenv) == "/usr/local/bin/rbenv" ]] || { error "Can't find rbenv in the PATH — which rbenv returns: $(which rbenv)" error "PATH: ${PATH}" return 1 diff --git a/bin/setup-darwin b/bin/setup-darwin index a21487a..3327bb4 100755 --- a/bin/setup-darwin +++ b/bin/setup-darwin @@ -58,14 +58,18 @@ setup.xcode-tools() { } setup.bazel() { - brew.package.is-installed bazelbuild/tap/bazelisk && - brew.uninstall.package bazelbuild/tap/bazelisk + brew.package.is-installed bazelisk && + brew.uninstall.package bazelisk && + run "brew unlink bazel" if __setup.is-bazelisk-installed && __setup.is-bazel-installed ; then info: "Bazel & bazelisk are already installed." else brew.install.packages bazel bazelisk + run "brew link bazel || true" fi + + } setup.darwin() { diff --git a/bin/test-suite b/bin/test-suite index 7c17406..63643f1 100755 --- a/bin/test-suite +++ b/bin/test-suite @@ -12,7 +12,7 @@ set -e # shellcheck disable=SC1091 -source "bin/deps" 2>/dev/null 1>/dev/null +source "bin/deps" export SHELL_INIT="${HOME}/.bashrc" export BUNDLE_PATH="${BUNDLE_PATH:-${HOME}/.bundle/gems}" @@ -21,10 +21,12 @@ export PATH="${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:/usr/local/bin:/usr/bin:/bi export BAZEL_OPTS="--host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m" export BAZEL_BUILD_OPTS="--curses=no --verbose_failures -j 30 --progress_report_interval=2" export BAZEL_TEST_OPTS="--verbose_failures --test_verbose_timeout_warnings --verbose_explanations" -export RUBY_VERSION="$(__version.detect .ruby_version)" +export RUBY_VERSION="$(__version.detect .ruby-version)" export BUNDLER_VERSION=$(gem.gemfile.bundler-version) export RULES_VERSION=$(__version.detect .rules_version) +h3bg "RUBY_VERSION=${RUBY_VERSION}" + export BashMatic__Expr=" [[ -f ${SHELL_INIT} ]] && source ${SHELL_INIT}; [[ -f ${HOME}/.bashmatic/init.sh ]] && source ${HOME}/.bashmatic/init.sh; diff --git a/examples/example_gem/WORKSPACE b/examples/example_gem/WORKSPACE index d0ee220..06b7964 100644 --- a/examples/example_gem/WORKSPACE +++ b/examples/example_gem/WORKSPACE @@ -15,7 +15,7 @@ load( rules_ruby_dependencies() -rules_ruby_select_sdk("2.7.1") +rules_ruby_select_sdk("3.0.1") load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") diff --git a/examples/simple_rails_api/Gemfile.lock b/examples/simple_rails_api/Gemfile.lock index 167a148..07a3f1a 100644 --- a/examples/simple_rails_api/Gemfile.lock +++ b/examples/simple_rails_api/Gemfile.lock @@ -1,153 +1,147 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.2) - actionpack (= 6.0.3.2) + actioncable (6.0.4) + actionpack (= 6.0.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.2) - actionpack (= 6.0.3.2) - activejob (= 6.0.3.2) - activerecord (= 6.0.3.2) - activestorage (= 6.0.3.2) - activesupport (= 6.0.3.2) + actionmailbox (6.0.4) + actionpack (= 6.0.4) + activejob (= 6.0.4) + activerecord (= 6.0.4) + activestorage (= 6.0.4) + activesupport (= 6.0.4) mail (>= 2.7.1) - actionmailer (6.0.3.2) - actionpack (= 6.0.3.2) - actionview (= 6.0.3.2) - activejob (= 6.0.3.2) + actionmailer (6.0.4) + actionpack (= 6.0.4) + actionview (= 6.0.4) + activejob (= 6.0.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.2) - actionview (= 6.0.3.2) - activesupport (= 6.0.3.2) + actionpack (6.0.4) + actionview (= 6.0.4) + activesupport (= 6.0.4) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.2) - actionpack (= 6.0.3.2) - activerecord (= 6.0.3.2) - activestorage (= 6.0.3.2) - activesupport (= 6.0.3.2) + actiontext (6.0.4) + actionpack (= 6.0.4) + activerecord (= 6.0.4) + activestorage (= 6.0.4) + activesupport (= 6.0.4) nokogiri (>= 1.8.5) - actionview (6.0.3.2) - activesupport (= 6.0.3.2) + actionview (6.0.4) + activesupport (= 6.0.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.3.2) - activesupport (= 6.0.3.2) + activejob (6.0.4) + activesupport (= 6.0.4) globalid (>= 0.3.6) - activemodel (6.0.3.2) - activesupport (= 6.0.3.2) - activerecord (6.0.3.2) - activemodel (= 6.0.3.2) - activesupport (= 6.0.3.2) - activestorage (6.0.3.2) - actionpack (= 6.0.3.2) - activejob (= 6.0.3.2) - activerecord (= 6.0.3.2) - marcel (~> 0.3.1) - activesupport (6.0.3.2) + activemodel (6.0.4) + activesupport (= 6.0.4) + activerecord (6.0.4) + activemodel (= 6.0.4) + activesupport (= 6.0.4) + activestorage (6.0.4) + actionpack (= 6.0.4) + activejob (= 6.0.4) + activerecord (= 6.0.4) + marcel (~> 1.0.0) + activesupport (6.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.2, >= 2.2.2) - bootsnap (1.4.6) + bootsnap (1.7.5) msgpack (~> 1.0) builder (3.2.4) byebug (11.1.3) - concurrent-ruby (1.1.6) + concurrent-ruby (1.1.9) crass (1.0.6) - erubi (1.9.0) - ffi (1.13.1) + erubi (1.10.0) + ffi (1.15.3) globalid (0.4.2) activesupport (>= 4.2.0) - i18n (1.8.3) + i18n (1.8.10) concurrent-ruby (~> 1.0) - listen (3.1.5) + listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.6.0) + loofah (2.10.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) method_source (1.0.0) - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_mime (1.0.2) - mini_portile2 (2.5.1) - minitest (5.14.1) - msgpack (1.3.3) - nio4r (2.5.2) - nokogiri (1.11.5) + mini_mime (1.1.0) + mini_portile2 (2.5.3) + minitest (5.14.4) + msgpack (1.4.2) + nio4r (2.5.7) + nokogiri (1.11.7) mini_portile2 (~> 2.5.0) racc (~> 1.4) - puma (4.3.5) + puma (4.3.8) nio4r (~> 2.0) racc (1.5.2) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.3.2) - actioncable (= 6.0.3.2) - actionmailbox (= 6.0.3.2) - actionmailer (= 6.0.3.2) - actionpack (= 6.0.3.2) - actiontext (= 6.0.3.2) - actionview (= 6.0.3.2) - activejob (= 6.0.3.2) - activemodel (= 6.0.3.2) - activerecord (= 6.0.3.2) - activestorage (= 6.0.3.2) - activesupport (= 6.0.3.2) + rails (6.0.4) + actioncable (= 6.0.4) + actionmailbox (= 6.0.4) + actionmailer (= 6.0.4) + actionpack (= 6.0.4) + actiontext (= 6.0.4) + actionview (= 6.0.4) + activejob (= 6.0.4) + activemodel (= 6.0.4) + activerecord (= 6.0.4) + activestorage (= 6.0.4) + activesupport (= 6.0.4) bundler (>= 1.3.0) - railties (= 6.0.3.2) + railties (= 6.0.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (6.0.3.2) - actionpack (= 6.0.3.2) - activesupport (= 6.0.3.2) + railties (6.0.4) + actionpack (= 6.0.4) + activesupport (= 6.0.4) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) - rake (13.0.1) - rb-fsevent (0.10.4) + rake (13.0.4) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) - ruby_dep (1.5.0) - spring (2.1.0) + spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.4.2) - thor (1.0.1) + thor (1.1.0) thread_safe (0.3.6) - tzinfo (1.2.7) + tzinfo (1.2.9) thread_safe (~> 0.1) - websocket-driver (0.7.3) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.4.0) + zeitwerk (2.4.2) PLATFORMS ruby @@ -164,4 +158,4 @@ DEPENDENCIES tzinfo-data BUNDLED WITH - 2.1.2 + 2.1.4 diff --git a/examples/simple_rails_api/WORKSPACE b/examples/simple_rails_api/WORKSPACE index c0febc9..17e28c3 100644 --- a/examples/simple_rails_api/WORKSPACE +++ b/examples/simple_rails_api/WORKSPACE @@ -15,7 +15,7 @@ load( rules_ruby_dependencies() -rules_ruby_select_sdk(version = "2.7.1") +rules_ruby_select_sdk(version = "3.0.1") load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") diff --git a/examples/simple_script/.rubocop.yml b/examples/simple_script/.rubocop.yml index 7b653d9..7a33ed8 100644 --- a/examples/simple_script/.rubocop.yml +++ b/examples/simple_script/.rubocop.yml @@ -1,7 +1,7 @@ inherit_from: .relaxed-rubocop-2.4.yml AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.0 UseCache: true DefaultFormatter: progress DisplayStyleGuide: true @@ -23,6 +23,7 @@ AllCops: - '**/*.ru' - '**/Gemfile' - '**/Rakefile' + NewCops: enable Layout/HashAlignment: Enabled: true diff --git a/examples/simple_script/Gemfile b/examples/simple_script/Gemfile index d677fb5..ae4893b 100644 --- a/examples/simple_script/Gemfile +++ b/examples/simple_script/Gemfile @@ -6,4 +6,4 @@ gem 'awesome_print' gem 'colored2' gem 'rspec', '~> 3.7.0' gem 'rspec-its' -gem 'rubocop', '~> 0.78.0' +gem 'rubocop' diff --git a/examples/simple_script/Gemfile.lock b/examples/simple_script/Gemfile.lock index 6dbbfbb..b5d358f 100644 --- a/examples/simple_script/Gemfile.lock +++ b/examples/simple_script/Gemfile.lock @@ -1,15 +1,16 @@ GEM remote: https://rubygems.org/ specs: - ast (2.4.1) - awesome_print (1.8.0) + ast (2.4.2) + awesome_print (1.9.2) colored2 (3.1.2) diff-lcs (1.4.4) - jaro_winkler (1.5.4) - parallel (1.19.2) - parser (2.7.1.4) + parallel (1.20.1) + parser (3.0.1.1) ast (~> 2.4.1) rainbow (3.0.0) + regexp_parser (2.1.1) + rexml (3.2.5) rspec (3.7.0) rspec-core (~> 3.7.0) rspec-expectations (~> 3.7.0) @@ -26,15 +27,19 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) - rubocop (0.78.0) - jaro_winkler (~> 1.5.1) + rubocop (1.18.3) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.7.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - ruby-progressbar (1.10.1) - unicode-display_width (1.6.1) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.7.0) + parser (>= 3.0.1.1) + ruby-progressbar (1.11.0) + unicode-display_width (2.0.0) PLATFORMS ruby @@ -44,7 +49,7 @@ DEPENDENCIES colored2 rspec (~> 3.7.0) rspec-its - rubocop (~> 0.78.0) + rubocop BUNDLED WITH - 2.1.2 + 2.1.4 diff --git a/examples/simple_script/WORKSPACE b/examples/simple_script/WORKSPACE index 1caa54b..13cf766 100644 --- a/examples/simple_script/WORKSPACE +++ b/examples/simple_script/WORKSPACE @@ -15,13 +15,13 @@ load( rules_ruby_dependencies() -rules_ruby_select_sdk(version = "2.7.1") +rules_ruby_select_sdk(version = "3.0.1") load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle") ruby_bundle( name = "bundle", - bundler_version = "2.1.2", + bundler_version = "2.1.4", excludes = { "mini_portile": ["test/**/*"], }, diff --git a/ruby/private/bundle/create_bundle_build_file.rb b/ruby/private/bundle/create_bundle_build_file.rb index b283b40..96779f0 100755 --- a/ruby/private/bundle/create_bundle_build_file.rb +++ b/ruby/private/bundle/create_bundle_build_file.rb @@ -96,8 +96,11 @@ class Buildifier # @formatter:off class BuildifierError < StandardError; end + class BuildifierNotFoundError < BuildifierError; end + class BuildifierFailedError < BuildifierError; end + class BuildifierNoBuildFileError < BuildifierError; end # @formatter:on diff --git a/ruby/private/constants.bzl b/ruby/private/constants.bzl index 633878f..c74b6ef 100644 --- a/ruby/private/constants.bzl +++ b/ruby/private/constants.bzl @@ -4,7 +4,7 @@ load(":providers.bzl", "RubyLibraryInfo") RULES_RUBY_WORKSPACE_NAME = "@bazelruby_rules_ruby" TOOLCHAIN_TYPE_NAME = "%s//ruby:toolchain_type" % RULES_RUBY_WORKSPACE_NAME -DEFAULT_BUNDLER_VERSION = "2.1.2" +DEFAULT_BUNDLER_VERSION = "2.1.4" DEFAULT_RSPEC_ARGS = {"--format": "documentation", "--force-color": None} DEFAULT_RSPEC_GEMS = ["rspec", "rspec-its"] DEFAULT_BUNDLE_NAME = "@bundle//" diff --git a/ruby/private/dependencies.bzl b/ruby/private/dependencies.bzl index f4be128..0a51d7a 100644 --- a/ruby/private/dependencies.bzl +++ b/ruby/private/dependencies.bzl @@ -9,10 +9,10 @@ def rules_ruby_dependencies(): http_archive( name = "bazel_skylib", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", ], - sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", + sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", ) if "rules_pkg" not in native.existing_rules(): diff --git a/ruby/private/toolchains/ruby_runtime.bzl b/ruby/private/toolchains/ruby_runtime.bzl index 8baf10c..048084f 100644 --- a/ruby/private/toolchains/ruby_runtime.bzl +++ b/ruby/private/toolchains/ruby_runtime.bzl @@ -3,9 +3,9 @@ load("//ruby/private/toolchains:repository_context.bzl", "ruby_repository_contex def _install_ruby_version(ctx, version): ctx.download_and_extract( - url = "https://github.com/rbenv/ruby-build/archive/v20210611.tar.gz", - sha256 = "dba3fd6722c007773ccef2c01cca454152d834f962754a85ae2c746b338f5772", - stripPrefix = "ruby-build-20210611", + url = "https://github.com/rbenv/ruby-build/archive/refs/tags/v20210707.tar.gz", + sha256 = "afd8aa2d05fb2f33c09c78dabcd2fc0bfa7e70dfc6b5288a1b5794337497039b", + stripPrefix = "ruby-build-20210707", ) install_path = "./build"