Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<img alt="YourBase" src="images/Logo-Horiz-On-White@1x.jpg" width="384" height="112">

# Quick Start Acceleration

- [YourBase Ruby Acceleration](yourbase-ruby.md)


# CI and CLI Documentation

- [Installation](installation.md)
Expand All @@ -8,3 +13,4 @@
- [Package Configuration Reference](configuration.md)
- [CI Acceleration and Caching](ci-caching.md)
- [Design Philosophy](design-philosophy.md)

73 changes: 73 additions & 0 deletions docs/yourbase-ruby.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# YourBase Ruby Acceleration

Tests are important. For large monoliths, they're also a major source of drag on velocity.

YourBase is a tool that traces your tests to determine which functions each test depends on. It can later use this information to determine which tests do not need to run because their code paths have not changed. These tests are skipped automatically.

YourBase works with Ruby versions >= 2.3

## Getting Started
No configuration, setup, or babysitting required. To get started, you need the YourBase gem and a download token. To request a token, please visit [YourBase.io](https://yourbase.io/download)

Once you have a token, simply follow the steps below:
```sh
bundle add yourbase-rspec --git "https://${YOURBASE_DOWNLOAD_TOKEN?}:x-oauth-basic@github.com/yourbase/yourbase-rspec-skipper-engine.git" && bundle install
```

## First run
After installing yourbase-rspec, if you are not using Rails you must add
"require 'yourbase-rspec'" in your spec folder.

```sh
# Add require for non Rails projects
echo "require 'yourbase-rspec'" >> spec/yourbase_spec.rb
```

Run your tests with the same command you typically use. You should see a rocket ship at the beginning the RSpec test section.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Run your tests with the same command you typically use. You should see a rocket ship at the beginning the RSpec test section.
Run your specs as you normally do-- `yourbase-rspec` is compatible with any `rspec` command line options. You will see a rocket ship at the top of the `rspec` output if `yourbase-rspec` is successfully running! 🚀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you would not like to take the change verbatim, can you update the text to include the information about compatibility with command line arguments and the literal emoji? It's not clear to me that everyone (especially devs with a different native language) will automatically know "rocketship" means "🚀"


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a section about Spring here, because it's the most common reason they won't see the rocketship.

Right now, they need to run spring stop from the command line to turn it off, but it would be better if we could figure out if manually requiring yourbase-rspec at the top of the spec_helper.rb gets around the incompatibility, so that we could tell them to do that instead of having to stop Spring. Stopping Spring is definitely fine in the CI but is a little kludgier for local dev where Spring does actual useful things, including shorten the spin-up time for "loading the rails environment" for specs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Have this in my notes but wanted to try it out first. Will add it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now it is sufficient to say that if you do not see the rocketship but ARE running Spring, that it should be turned off to accelerate the tests.

```plain
🚀
```

The first run will be cold, so if you just want to see YourBase in action and your tests are going to take a while, you can run a subset of tests. Tracing data for the subset will be used correctly even if you later run all tests.

After the run finishes, running again will skip all tests. Modifying a dependency will run only tests whose code paths touched the changed code. You're YourBased! 🚀

## RSpec Output

YourBase enhances the output so that you can clearly see the results of the Gem.

For an accelerated run, you will see the number of skipped tested added to your
RSpec summary line:
```plain
1 examples, 0 failures, 1 skipped with YourBase🚀
```

YourBase adds additional details when using the RSpec formatter option with the
progress and documentation formatters.

## Cohorting / Sharding
YourBase supports sharding your tests without negatively affecting tracing or acceleration. It uses consistent hashing to split tests into cohorts that stay the same between runs, even as the test pool grows or shrinks.

1) Set YB_COHORT_COUNT to the number of cohorts your tests should be split into. This should be the same among all shards.
1) Set YB_TEST_COHORT to the cohort ID this run should identify as, starting with 1. This should be different among all shards.
Without these set, YourBase assumes a value of "1" for both, meaning one shard will run one cohort; that cohort will contain all tests.

Note that tests are only guaranteed to remain in the same cohort as long as
YB_COHORT_COUNT doesn't change.

## Observation Mode
The yourbase-rspec gem includes an "observation mode" which will run all [command-line specified] examples. "Observation mode" allows you to test drive the plugin without actually skipping any tests.

To enable observation mode, set YOURBASE_OBSERVATION_MODE to true in the environment. The documentation formatter isn't strictly required, but it will print the reasons why YourBase would run or skip a given example group.

```sh
YOURBASE_OBSERVATION_MODE=true bundle exec rspec --format documentation
```

Instead of a single rocketship, you'll see the following at the top of the rspec output for observation mode:

```plain
🚀 YourBase test selection is in observation mode. All example groups will be run. 🚀
```