Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass redis options via ENV variable #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ OPTIONS:
-v, --version Print the version and exit.
```

#### ENV variables
Options can be set via ENV variables
```
Build ID RSPECQ_BUILD
Worker ID RSPECQ_WORKER
Redis HOST RSPECQ_REDIS
Timings RSPECQ_UPDATE_TIMINGS
File split threshold RSPECQ_FILE_SPLIT_THRESHOLD
Report RSPECQ_REPORT
Report Timeout RSPECQ_REPORT_TIMEOUT
Max requests RSPECQ_MAX_REQUEUES
Queue wait timeout RSPECQ_QUEUE_WAIT_TIMEOUT
Redis URL RSPECQ_REDIS_URL
Redis options (JSON) RSPECQ_REDIS_OPTS
Fail fast RSPECQ_FAIL_FAST

```
### Sentry integration

RSpecQ can optionally emit build events to a
Expand Down Expand Up @@ -194,6 +211,19 @@ on every run (if the `--update-timings` option was used). Also, RSpecQ has a
"slow file threshold" which, currently has to be set manually (but this can be
improved in the future).

### CircleCI integration
As CircleCI does not allow to spin up shared Redis instance, Redis server should be configured outside CircleCI environment.
Redis connection credentials could be set as CircleCI project environment variable `RSPECQ_REDIS_URL`

Secure redis connection is supported via `rediss://` schema, additional TLS options can be specified via `RSPECQ_REDIS_OPTS` env variable in JSON format.
For example `{ "ssl_params": { "ca_file": "spec/support/lib/ca_heroku.crt", "verify_hostname": false } }`

`circle.yml` could run rspecq as:
```yml
- type: shell
command: |
bundle exec rspecq --build=${CIRCLE_BUILD_NUM} --worker=${CIRCLE_NODE_INDEX}
```

## Development

Expand Down
2 changes: 1 addition & 1 deletion bin/rspecq
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ raise OptionParser::MissingArgument.new(:build) if opts[:build].nil?
raise OptionParser::MissingArgument.new(:worker) if !opts[:report] && opts[:worker].nil?
# rubocop:enable Style/RaiseArgs, Layout/EmptyLineAfterGuardClause

redis_opts = {}
redis_opts = JSON.parse(ENV.fetch("RSPECQ_REDIS_OPTS", "{}"), symbolize_names: true)

if opts[:redis_url]
redis_opts[:url] = opts[:redis_url]
Expand Down