2019-07-17 11:01:48 -04:00
# setup-ruby
2019-08-12 15:13:09 -04:00
< p align = "left" >
2020-01-17 15:38:43 -05:00
< a href = "https://github.com/actions/setup-ruby/actions" > < img alt = "test status" src = "https://github.com/actions/setup-ruby/workflows/build-test/badge.svg" > < / a >
< a href = "https://github.com/actions/setup-ruby/actions" > < img alt = "versions status" src = "https://github.com/actions/setup-ruby/workflows/ruby-versions/badge.svg" > < / a >
2019-08-12 15:13:09 -04:00
< / p >
2020-01-17 18:03:39 -06:00
This action sets up a ruby environment for versions which are installed on the [Actions Virtual Environments ](https://github.com/actions/virtual-environments ).
2019-07-17 11:01:48 -04:00
2020-01-17 18:03:39 -06:00
Virtual environments contain only one Ruby version within a 'major.minor' release, and are updated with new releases. Hence, a workflow should only be bound to minor versions.
Note that a `ruby-version:` of `2.6` or `2.6.x` are equivalent.
> Supports `2.4`, `2.5`, `2.6`, and `2.7`.
2019-07-17 11:01:48 -04:00
# Usage
See [action.yml ](action.yml )
Basic:
```yaml
2019-07-25 21:26:06 -04:00
steps:
2020-01-23 22:11:20 -05:00
- uses: actions/checkout@v2
2019-08-01 09:32:52 -04:00
- uses: actions/setup-ruby@v1
2019-07-17 11:01:48 -04:00
with:
2020-01-17 18:03:39 -06:00
ruby-version: '2.6' # Version range or exact version of a Ruby version to use, using semvers version range syntax.
2019-07-17 11:01:48 -04:00
- run: ruby hello.rb
```
Matrix Testing:
```yaml
jobs:
build:
2019-08-01 11:06:53 -04:00
runs-on: ubuntu-16.04
2019-07-17 11:01:48 -04:00
strategy:
matrix:
2020-01-17 18:03:39 -06:00
ruby: [ '2.5', '2.6' ]
2019-07-17 11:01:48 -04:00
name: Ruby ${{ matrix.ruby }} sample
2019-07-25 21:26:06 -04:00
steps:
2020-01-23 22:11:20 -05:00
- uses: actions/checkout@v2
2019-09-21 19:12:14 +02:00
- uses: actions/setup-ruby@v1
2019-07-17 11:01:48 -04:00
with:
2019-08-13 16:29:23 -04:00
ruby-version: ${{ matrix.ruby }}
2019-07-17 11:01:48 -04:00
- run: ruby hello.rb
```
2019-06-26 14:22:50 -04:00
2019-10-02 15:29:57 -06:00
Ruby on Rails Testing:
```yaml
name: Rails Unit Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
services:
db:
image: postgres:11
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
2020-01-23 22:11:20 -05:00
- uses: actions/checkout@v2
2019-10-02 15:29:57 -06:00
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
2020-01-17 18:03:39 -06:00
ruby-version: 2.6
2019-10-02 15:29:57 -06:00
- name: Build and test with Rake
env:
PGHOST: 127.0.0.1
PGUSER: postgres
RAILS_ENV: test
run: |
sudo apt-get -yqq install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails test
```
2020-01-07 15:03:45 -05:00
# Caching Dependencies
See [actions/cache ](https://github.com/actions/cache ) and the [Ruby Gem cache example ](https://github.com/actions/cache/blob/master/examples.md#ruby---gem ).
2019-06-26 14:28:48 -04:00
# License
The scripts and documentation in this project are released under the [MIT License ](LICENSE )
# Contributions
2019-06-27 14:31:32 -04:00
Contributions are welcome! See [Contributor's Guide ](docs/contributors.md )
2020-01-23 22:24:47 -05:00
## Code of Conduct
:wave: Be nice. See [our code of conduct ](CONDUCT )