Skip to content

Commit cc1d57f

Browse files
authored
Merge branch 'develop' into dir.children
2 parents 5a81b11 + fe99221 commit cc1d57f

File tree

4 files changed

+165
-30
lines changed

4 files changed

+165
-30
lines changed

README.md

Lines changed: 162 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
22

3+
* [Rules Development Status](#rules-development-status)
34
* [Usage](#usage)
4-
* [WORKSPACE File](#workspace-file)
5-
* [BUILD.bazel files](#buildbazel-files)
5+
* [`WORKSPACE` File](#workspace-file)
6+
* [`BUILD.bazel` files](#buildbazel-files)
67
* [Rules](#rules)
7-
* [ruby_library](#ruby_library)
8-
* [ruby_binary](#ruby_binary)
9-
* [ruby_test](#ruby_test)
10-
* [ruby_bundle](#ruby_bundle)
11-
* [ruby_gem](#rb_gem)
8+
* [`ruby_library`](#ruby_library)
9+
* [`ruby_binary`](#ruby_binary)
10+
* [`ruby_test`](#ruby_test)
11+
* [`ruby_bundle`](#ruby_bundle)
12+
* [Limitations](#limitations)
13+
* [Conventions](#conventions)
14+
* [Example: `WORKSPACE`:](#example-workspace)
15+
* [Example: `lib/BUILD.bazel`:](#example-libbuildbazel)
16+
* [`ruby_rspec`](#ruby_rspec)
17+
* [`ruby_gem`](#ruby_gem)
1218
* [What's coming next](#whats-coming-next)
1319
* [Contributing](#contributing)
1420
* [Setup](#setup)
@@ -27,44 +33,49 @@
2733

2834
| Build | Status |
2935
|---------: |--------------------------------------------------------------------------------------------------------------------------------------------------- |
30-
| CircleCI Develop: | [![CircleCI](https://circleci.com/gh/bazelruby/rules_ruby/tree/develop.svg?style=svg)](https://circleci.com/gh/bazelruby/rules_ruby/tree/develop) |
31-
| CircleCI Default: | [![CircleCI](https://circleci.com/gh/bazelruby/rules_ruby.svg?style=svg)](https://circleci.com/gh/bazelruby/rules_ruby) |
32-
| Develop: | [![Build Status](https://travis-ci.org/bazelruby/rules_ruby.svg?branch=develop)](https://travis-ci.org/bazelruby/rules_ruby) |
33-
| Master: | [![Build Status](https://travis-ci.org/bazelruby/rules_ruby.svg?branch=master)](https://travis-ci.org/bazelruby/rules_ruby) |
36+
| CircleCI | [![CircleCI](https://circleci.com/gh/bazelruby/rules_ruby/tree/develop.svg?style=svg)](https://circleci.com/gh/bazelruby/rules_ruby/tree/develop) |
37+
| TravisCI | [![Build Status](https://travis-ci.org/bazelruby/rules_ruby.svg?branch=develop)](https://travis-ci.org/bazelruby/rules_ruby) |
3438

3539

3640
# Rules Ruby
3741

38-
Ruby rules for [Bazel](https://bazel.build).
42+
This is the README for Ruby Rules for the [Bazel Build](https://bazel.build) system.
43+
44+
## Rules Development Status
45+
46+
| **Readiness** | **Types of Applications** |
47+
|:-------------------------------------------------------------------------------| :----------|
48+
| ![Ready](docs/img/status-ready.svg) | ruby apps, ruby gems, micro-services, ideally in a mono-repo |
49+
| ![Wait](docs/img/status-wait.svg) | medium-sized Ruby on Rails apps, ideally in a mono-repo |
50+
| ![Not Ready](docs/img/status-not-ready.svg) | complex Ruby on Rails monoliths, single-repo |
3951

40-
** Current Status:** *Work in progress.*
4152

4253
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.
4354

4455
## Usage
4556

4657
### `WORKSPACE` File
4758

48-
Add `ruby_rules_dependencies` and `ruby_register_toolchains` into your `WORKSPACE` file.
59+
Add `ruby_rules_dependencies` and `ruby_rules_toolchains` into your `WORKSPACE` file.
4960

5061
```python
5162
# To get the latest, grab the 'develop' branch.
5263

5364
git_repository(
54-
name = "bazelruby_ruby_rules",
65+
name = "bazelruby_rules_ruby",
5566
remote = "https://github.com/bazelruby/rules_ruby.git",
5667
branch = "develop",
5768
)
5869

5970
load(
60-
"@bazelruby_ruby_rules//ruby:deps.bzl",
61-
"ruby_register_toolchains",
71+
"@bazelruby_rules_ruby//ruby:deps.bzl",
72+
"ruby_rules_toolchains",
6273
"ruby_rules_dependencies",
6374
)
6475

6576
ruby_rules_dependencies()
6677

67-
ruby_register_toolchains()
78+
ruby_rules_toolchains()
6879
```
6980

7081
Next, add any external Gem dependencies you may have via `ruby_bundle` command.
@@ -98,7 +109,7 @@ Add `ruby_library`, `ruby_binary` or `ruby_test` into your `BUILD.bazel` files.
98109

99110
```python
100111
load(
101-
"@bazelruby_ruby_rules//ruby:defs.bzl",
112+
"@bazelruby_rules_ruby//ruby:defs.bzl",
102113
"ruby_binary",
103114
"ruby_library",
104115
"ruby_test",
@@ -139,10 +150,13 @@ ruby_rspec(
139150

140151
## Rules
141152

153+
> NOTE: this diagram is slightly outdated.
154+
142155
The following diagram attempts to capture the implementation behind `ruby_library` that depends on the result of `bundle install`, and a `ruby_binary` that depends on both:
143156

144157
![Ruby Rules](docs/img/ruby_rules.png)
145158

159+
----
146160

147161
### `ruby_library`
148162

@@ -219,6 +233,8 @@ ruby_library(name, deps, srcs, data, compatible_with, deprecation, distribs, fea
219233
</tbody>
220234
</table>
221235

236+
----
237+
222238
### `ruby_binary`
223239

224240
<pre>
@@ -300,6 +316,8 @@ ruby_binary(name, deps, srcs, data, main, compatible_with, deprecation, distribs
300316
</tbody>
301317
</table>
302318

319+
----
320+
303321
### `ruby_test`
304322

305323
<pre>
@@ -381,39 +399,57 @@ ruby_test(name, deps, srcs, data, main, compatible_with, deprecation, distribs,
381399
</tbody>
382400
</table>
383401

402+
----
403+
384404
### `ruby_bundle`
385405

386-
Installs gems with Bundler, and make them available as a `ruby_library`.
406+
**NOTE: This is a repository rule, and can only be used in a `WORKSPACE` file.**
407+
408+
This rule installs gems defined in a Gemfile using Bundler, and exports individual gems from the bundle, as well as the entire bundle, available as a `ruby_library` that can be depended upon from other targets.
387409

388-
Example: `WORKSPACE`:
410+
#### Limitations
411+
412+
Installing using a `Gemfile` that uses the `gemspec` keyword is not currently supported.
413+
414+
#### Conventions
415+
416+
`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`:
417+
418+
* `@app_bundle//:bundler` — references just the Bundler from the bundle.
419+
* `@app_bundle//:gems` — references *all* gems in the bundle (i.e. "the entire bundle").
420+
* `@app_bundle//:gem-name` — references *just the specified* gem in the bundle, eg. `@app_bundle//:awesome_print`.
421+
* `@app_bundle//:bin` — references to all installed executables from this bundle, with individual executables accessible via eg. `@app_bundle//:bin/rubocop`
422+
423+
##### Example: `WORKSPACE`:
389424

390425
```python
391426
git_repository(
392-
name = "bazelruby_ruby_rules",
427+
name = "bazelruby_rules_ruby",
393428
remote = "https://github.com/bazelruby/rules_ruby.git",
394429
tag = "v0.1.0",
395430
)
396431

397432
load(
398-
"@bazelruby_ruby_rules//ruby:deps.bzl",
399-
"ruby_register_toolchains",
433+
"@bazelruby_rules_ruby//ruby:deps.bzl",
434+
"ruby_rules_toolchains",
400435
"ruby_rules_dependencies",
401436
)
402437

403438
ruby_rules_dependencies()
404439

405-
ruby_register_toolchains()
440+
ruby_rules_toolchains()
406441

407-
load("@bazelruby_ruby_rules//ruby:defs.bzl", "ruby_bundle")
442+
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle")
408443

409444
ruby_bundle(
445+
bundler_version = '2.1.2',
410446
name = "gems",
411447
gemfile = "//:Gemfile",
412448
gemfile_lock = "//:Gemfile.lock",
413449
)
414450
```
415451

416-
Example: `lib/BUILD.bazel`:
452+
##### Example: `lib/BUILD.bazel`:
417453

418454
```python
419455
ruby_library(
@@ -484,11 +520,105 @@ ruby_bundle(name, gemfile, gemfile_lock, bundler_version = "2.1.2")
484520
</tbody>
485521
</table>
486522

487-
## rb_gem
523+
----
524+
525+
### `ruby_rspec`
526+
527+
<pre>
528+
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, shard_count)
529+
</pre>
530+
531+
<table class="table table-condensed table-bordered table-params">
532+
<colgroup>
533+
<col class="col-param" />
534+
<col class="param-description" />
535+
</colgroup>
536+
<thead>
537+
<tr>
538+
<th colspan="2">Attributes</th>
539+
</tr>
540+
</thead>
541+
<tbody>
542+
<tr>
543+
<td><code>name</code></td>
544+
<td>
545+
<code>Name, required</code>
546+
<p>A unique name for this rule.</p>
547+
</td>
548+
</tr>
549+
<tr>
550+
<td><code>srcs</code></td>
551+
<td>
552+
<code>List of Labels, required</code>
553+
<p>
554+
List of <code>.rb</code> files.
555+
</p>
556+
</td>
557+
</tr>
558+
<tr>
559+
<td><code>deps</code></td>
560+
<td>
561+
<code>List of labels, optional</code>
562+
<p>
563+
List of targets that are required by the <code>srcs</code> Ruby
564+
files.
565+
</p>
566+
</td>
567+
</tr>
568+
<tr>
569+
<td><code>main</code></td>
570+
<td>
571+
<code>Label, optional</code>
572+
<p>The entrypoint file. It must be also in <code>srcs</code>.</p>
573+
<p>If not specified, <code><var>$(NAME)</var>.rb</code> where <code>$(NAME)</code> is the <code>name</code> of this rule.</p>
574+
</td>
575+
</tr>
576+
<tr>
577+
<td><code>rspec_args</code></td>
578+
<td>
579+
<code>List of strings, optional</code>
580+
<p>Command line arguments to the <code>rspec</code> binary, eg <code>["--progress", "-p2", "-b"]</code></p>
581+
<p>If not specified, the default arguments defined in `constants.bzl` are used: <code> --format=documentation --force-color</code>.</p>
582+
</td>
583+
</tr>
584+
<tr>
585+
<td><code>includes</code></td>
586+
<td>
587+
<code>List of strings, optional</code>
588+
<p>
589+
List of paths to be added to <code>$LOAD_PATH</code> at runtime.
590+
The paths must be relative to the the workspace which this rule belongs to.
591+
</p>
592+
</td>
593+
</tr>
594+
<tr>
595+
<td><code>rubyopt</code></td>
596+
<td>
597+
<code>List of strings, optional</code>
598+
<p>
599+
List of options to be passed to the Ruby interpreter at runtime.
600+
</p>
601+
<p>
602+
NOTE: <code>-I</code> option should usually go to <code>includes</code> attribute.
603+
</p>
604+
</td>
605+
</tr>
606+
</tbody>
607+
<tbody>
608+
<tr>
609+
<td colspan="2">And other <a href="https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes">common attributes</a></td>
610+
</tr>
611+
</tbody>
612+
</table>
613+
614+
----
615+
616+
### `ruby_gem`
617+
488618
Used to generate a zipped gem containing its srcs, dependencies and a gemspec.
489619

490620
<pre>
491-
rb_gem(name, gem_name, version, srcs, authors, deps, data, includes)
621+
ruby_gem(name, gem_name, gem_version, srcs, authors, deps, data, includes)
492622
</pre>
493623
<table class="table table-condensed table-bordered table-params">
494624
<colgroup>
@@ -517,7 +647,7 @@ rb_gem(name, gem_name, version, srcs, authors, deps, data, includes)
517647
</tr>
518648
<tr>
519649
<tr>
520-
<td><code>version</code></td>
650+
<td><code>gem_version</code></td>
521651
<td>
522652
<code>Label, required</code>
523653
<p>
@@ -696,3 +826,5 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
696826

697827
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
698828
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.
829+
830+
<!-- @import "[TOC]" {cmd="toc" depthFrom=1 depthTo=6 orderedList=false} -->

docs/img/status-not-ready.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/img/status-ready.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/img/status-wait.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)