Skip to content

Commit 3ff7d63

Browse files
author
Konstantin Gredeskoul
committed
Renaming and making consistent all scripts
* Updating README * Adding WIKI page on Building Ruby Projects * Adding info on gotchas and current issues (to the wiki) * SImplifying and making all scripts behave the same way. * Documenting all on README.
1 parent 6cf3d00 commit 3ff7d63

File tree

10 files changed

+572
-339
lines changed

10 files changed

+572
-339
lines changed

.circleci/config.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ jobs:
4747
- run:
4848
name: "Show Bazel Info"
4949
command: |
50-
51-
/usr/bin/env bash bin/ci bazel-info
50+
/usr/bin/env bash bin/test-suite bazel-info
5251
5352
- run:
5453
name: "Bazel Build & Test Workspace"
5554
command: |
56-
/usr/bin/env bash bin/ci workspace
55+
/usr/bin/env bash bin/test-suite workspace
5756
5857
bazel_build_examples:
5958
<<: *bazel_defaults

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ cache:
88
directories:
99
${HOME}/.rbenv
1010
${HOME}/.bundle/gems
11-
#${HOME}/.cache/bazel/_bazel_${USER}
1211

1312
addons:
1413
apt:
@@ -19,7 +18,7 @@ addons:
1918

2019
script:
2120
- /usr/bin/env bash bin/setup
22-
- /usr/bin/env bash bin/ci
21+
- /usr/bin/env bash bin/test-suite
2322

2423
after_script:
2524
- /usr/bin/env bash bin/show-env

README.md

Lines changed: 99 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
1+
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
22

33
* [Status:](#status)
4-
* [USAGE](#usage)
4+
* [Usage](#usage)
55
* [Rules](#rules)
66
* [ruby_library](#ruby_library)
77
* [ruby_binary](#ruby_binary)
@@ -10,7 +10,13 @@
1010
* [What's coming next](#whats-coming-next)
1111
* [Contributing](#contributing)
1212
* [Setup](#setup)
13+
* [Using the Script](#using-the-script)
14+
* [OS-Specific Setup](#os-specific-setup)
15+
* [Issues During Setup](#issues-during-setup)
16+
* [Developing Rules](#developing-rules)
1317
* [Running Tests](#running-tests)
18+
* [Test Script](#test-script)
19+
* [Linter](#linter)
1420
* [Copyright](#copyright)
1521

1622
<!-- /TOC -->
@@ -33,7 +39,9 @@ Ruby rules for [Bazel](https://bazel.build).
3339

3440
**Work in progress.**
3541

36-
## USAGE
42+
We have a 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.
43+
44+
## Usage
3745

3846
Add `ruby_rules_dependencies` and `ruby_register_toolchains` into your `WORKSPACE` file.
3947

@@ -421,66 +429,123 @@ bundle_install(name, gemfile, gemfile_lock)
421429

422430
## Contributing
423431

424-
1. Setup dev tools as described in the [setup](#setup) section.
425-
2. hack, hack, hack...
426-
3. Make sure all tests pass
427-
* `bazel test //...`
428-
* `cd examples/simple_script && bazel test //...`
429-
4. Open a pull request in Github
432+
We welcome contributions to RulesRuby. Please make yourself familiar with the [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) document.
433+
434+
You may notice that there is more than one Bazel WORKSPACE inside this repo. There is one in `examples/simple_script` for instance, because
435+
we use this example to validate and test the rules. So be mindful whether your current directory contains `WORKSPACE` file or not.
430436

431437
### Setup
432438

433-
To get the initial stuff setup required by this repo, please run the script:
439+
#### Using the Script
440+
441+
You will need Homebrew installed prior to running the script.
442+
443+
After that, cd into the top level folder and run the setup script in your Terminal:
434444

435445
```bash
436-
bin/setup
446+
bin/setup
437447
```
438448

439-
This script does a couple of very useful things, including setting up a git commit
440-
hook that performs rubocop fixes and buildifier fixes of the Bazel build files.
441-
442-
You can run partial setup comamnds like so:
449+
This runs a complete setup, shouldn't take too long. You can explore various script options with the `help` command:
443450

444451
```bash
445-
❯ bin/setup -h
452+
❯ bin/setup help
453+
USAGE
454+
# without any arguments runs a complete setup.
455+
bin/setup
446456

447-
USAGE:
448-
bin/setup [ gems | git-hook | help | install | main | no-git-hook ]
457+
# alternatively, a sub-setup function name can be passed:
458+
bin/setup [ gems | git-hook | help | os-specific | main | remove-git-hook ]
449459

450460
DESCRIPTION:
451461
Runs full setup without any arguments.
452462

453-
Accepts one argument — one of the actions that typically run
454-
as part of setup.
463+
Accepts one optional argument — one of the actions that typically run
464+
as part of setup, with one exception — remove-git-hook.
465+
This action removes the git commit hook installed by the setup.
455466

456-
For instance, to perform full setup:
467+
EXAMPLES:
468+
bin/setup — runs the entire setup.
469+
```
457470

458-
bin/setup
471+
#### OS-Specific Setup
459472

460-
Or, to run only one of the sub-functions (actions), pass
461-
it as an argument:
473+
Note that the setup contains `os-specific` section. This is because there are two extension scripts:
462474

463-
bin/setup help
464-
bin/setup no-git-hook
475+
* `bin/setup-linux`
476+
* `bin/setup-darwin`
465477

466-
etc.
467-
```
478+
Those will install Bazel and everything else you need on either platform. In fact, we use the linux version on CI.
479+
480+
##### Issues During Setup
481+
482+
**Please report any errors to `bin/setup` as Issues on Github. You can assign them to @kigster.**
483+
484+
### Developing Rules
485+
486+
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:
487+
488+
1. Setup dev tools as described in the [setup](#Setup) section.
489+
3. hack, hack, hack...
490+
4. Make sure all tests pass — you can run a single command for that (but see more on it [below](#test-script).
491+
492+
```bash
493+
bin/test-suite
494+
```
495+
496+
OR you can run individual Bazel test commands from the inside.
497+
498+
* `bazel test //...`
499+
* `cd examples/simple_script && bazel test //...`
468500

469-
Whenever you'll commit something, a pre-commit hook will run as well. If it
470-
finds anything that needs fixing, it will attempt to fix it. If the resulting
471-
git state is different than before the commit, the commit is aborted and the user
472-
should add any auto-fixed modifications to the list of staged files for commit.
501+
4. Open a pull request in Github, and please be as verbose as possible in your description.
502+
503+
In general, it's always a good idea to ask questions first — you can do so by creating an issue.
473504
474505
### Running Tests
475506
476-
We have a pretty useful script you can use to run all tests in the repo that run on CI:
507+
After running setup, and since this is a bazel repo you can use Bazel commands:
508+
509+
```bazel
510+
bazel build //...:all
511+
bazel query //...:all
512+
bazel test //...:all
513+
```
514+
515+
But to run tests inside each sub-WORKSPACE, you will need to repeat that in each sub-folder. Luckily, there is a better way.
516+
517+
#### Test Script
518+
519+
This script runs all tests (including sub-workspaces) when ran without arguments:
520+
521+
```bash
522+
bin/test-suite
523+
```
524+
525+
Run it with `help` command to see other options, and to see what parts you can run individually. At the moment they are:
477526
478527
```bash
479-
bin/ci
528+
# alternatively, a partial test name can be passed:
529+
bin/test-suite [ all | bazel-info | buildifier | help | rspec | rubocop | simple-script | workspace ]
480530
```
481531
482532
On a MacBook Pro it takes about 3 minutes to run.
483533
534+
### Linter
535+
536+
We are using RuboCop for ruby and Buildifier for Bazel. Both are represented by a single script `bin/linter`, which just like the scripts above runs ALL linters when ran without arguments, accepts `help` commnd, and can be run on a subset of linting strategies:
537+
538+
```bash
539+
bin/linter
540+
```
541+
542+
The following are the partial linting functions you can run:
543+
544+
```bash
545+
# alternatively, a partial linter name can be passed:
546+
bin/linter [ all | buildifier | help | rubocop ]
547+
```
548+
484549
## Copyright
485550
486551
© 2018-2019 Yuki Yugui Sonoda & BazelRuby Authors

0 commit comments

Comments
 (0)