Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Support .ruby-version #31

Open
scottohara opened this issue Sep 28, 2019 · 11 comments
Open

Support .ruby-version #31

scottohara opened this issue Sep 28, 2019 · 11 comments
Labels
enhancement New feature or request

Comments

@scottohara
Copy link

scottohara commented Sep 28, 2019

Many ruby projects include a .ruby-version file in the root directory, containing the version of Ruby needed.

Tools such as rvm, rbenv and chruby all recognise and use this file.

This is not unlike the .nvmrc file often used in Node projects, and the setup-node action has a discussion on potentially using the contents of that file as the node version if no with: argument is specified. (actions/setup-node#32)

I would suggest that setup-ruby might consider a similar approach, where if no explicit ruby version is given, look for a .ruby-version file and use the version contained within.

@tisba
Copy link

tisba commented Nov 28, 2019

I was wondering if there is a workaround available, like

- name: Set up Ruby
  uses: actions/setup-ruby@v1
  with:
    ruby-version: "{{ cat('.ruby-version') }}"

However I was not able to figure out how to do that yet :(

@sobstel
Copy link

sobstel commented Dec 3, 2019

I found a workaround in actions/setup-node repo.

- run: echo "::set-output name=RUBY_VERSION::$(cat .ruby-version)"
  id: rbenv

- uses: actions/setup-ruby@v1
  with:
   ruby-version: "${{ steps.rbenv.outputs.RUBY_VERSION }}"

@bryanmacfarlane bryanmacfarlane added the enhancement New feature or request label Jan 7, 2020
@bryanmacfarlane
Copy link
Member

happy to see the workaround ☝️ - leaving as an enhancement for consideration

@vvo
Copy link

vvo commented Jan 10, 2020

@bryanmacfarlane To be honest, and without any anger or nothing, I want to point out that supporting .ruby-version should not be seen as an "enhancement" but as a requirement for the ruby community. When any company starts a Ruby project they will first choose between rvm or rbenv, most of them. And the next step will be to create a .ruby-version file to easily create a reproducible environment for devs and continuous integration, which is supported by both rbenv and rvm.

Thus I think we should consider supporting the .ruby-version really as a requirement to consider "setup-ruby" good enough for any Ruby project. Right now a lot of people are just not using it and instead using https://github.com/eregon/use-ruby-action or https://github.com/masa-iwasaki/setup-rbenv.

I think it's fine and great that people are creating actions on the marketplace but for some very popular actions, the ones from GitHub should really cover most use cases otherwise we'll endup with a marketplace like the npm registry where you spend half a day trying to find the "right" ruby action that works well..

Thanks for consideration!

PS: Maybe @eregon, creator of use-ruby-action you have some thoughts about this too? Thanks!

@eregon
Copy link
Contributor

eregon commented Jan 10, 2020

I implemented it in use-ruby-action (issue: ruby/setup-ruby#4).
It's really trivial.

I think longer term we'll want most (all maybe) features of use-ruby-action in this repo: #44

lawrence-forooghian added a commit to dxw/transition that referenced this issue Jan 17, 2020
There a GitHub issue open for the setup-ruby action in which they are
considering making this happen automatically, but somebody gave this way
of implementing it for now:
actions/setup-ruby#31 (comment)
lawrence-forooghian added a commit to dxw/transition that referenced this issue Jan 17, 2020
There a GitHub issue open for the setup-ruby action in which they are
considering making this happen automatically, but somebody gave this way
of implementing it for now:
actions/setup-ruby#31 (comment)
Floppy pushed a commit to dxw/transition that referenced this issue Feb 14, 2020
There a GitHub issue open for the setup-ruby action in which they are
considering making this happen automatically, but somebody gave this way
of implementing it for now:
actions/setup-ruby#31 (comment)
waltz added a commit to waltz/imploder that referenced this issue Mar 1, 2020
* Try installing a few deps

* Install Node, Ruby, and attach a Postgres instance

* Match the installed version of ruby with the one in ruby-version

* Use a clever method for finding the current ruby version

actions/setup-ruby#31 (comment)

* Oops, gotta checkout the code before reading the version

* Bump to the latest patch version of Ruby

* Bump the Gemfile too

* Health check the Postgres instance and split out the bundle step

* use the latest Postgres, reformat the heallth check

* Point Rails at the service container

* Switch back to port mapping postgres to the local machine

* Manually set up the postgres instance and use DATABASE_URL for telling Rails where to look

* Deploy using GitHub workflows

* Use secrets store

* Setup both api. and git. for Heroku

* Specify the Heroku app to deploy to

* Double check current config

* debug heroku auth

* Work that netrc

* try and preserve newlines when writing netrc

* Be extra specific with the GH branch we want to push

* Only deploy on master

* I read the docs

* Install specific node versions

* Cache Node Modules runs

* Cache Ruby dependencies

* Ditch Travis
waltz added a commit to waltz/imploder that referenced this issue Mar 1, 2020
* Try installing a few deps

* Install Node, Ruby, and attach a Postgres instance

* Match the installed version of ruby with the one in ruby-version

* Use a clever method for finding the current ruby version

actions/setup-ruby#31 (comment)

* Oops, gotta checkout the code before reading the version

* Bump to the latest patch version of Ruby

* Bump the Gemfile too

* Health check the Postgres instance and split out the bundle step

* use the latest Postgres, reformat the heallth check

* Point Rails at the service container

* Switch back to port mapping postgres to the local machine

* Manually set up the postgres instance and use DATABASE_URL for telling Rails where to look

* Deploy using GitHub workflows

* Use secrets store

* Setup both api. and git. for Heroku

* Specify the Heroku app to deploy to

* Double check current config

* debug heroku auth

* Work that netrc

* try and preserve newlines when writing netrc

* Be extra specific with the GH branch we want to push

* Only deploy on master

* I read the docs

* Install specific node versions

* Cache Node Modules runs

* Cache Ruby dependencies

* Ditch Travis

Switch the build badge from Travis to GH Actions

ayy

wow
waltz added a commit to waltz/imploder that referenced this issue Mar 1, 2020
* Try installing a few deps

* Install Node, Ruby, and attach a Postgres instance

* Match the installed version of ruby with the one in ruby-version

* Use a clever method for finding the current ruby version

actions/setup-ruby#31 (comment)

* Oops, gotta checkout the code before reading the version

* Bump to the latest patch version of Ruby

* Bump the Gemfile too

* Health check the Postgres instance and split out the bundle step

* use the latest Postgres, reformat the heallth check

* Point Rails at the service container

* Switch back to port mapping postgres to the local machine

* Manually set up the postgres instance and use DATABASE_URL for telling Rails where to look

* Deploy using GitHub workflows

* Use secrets store

* Setup both api. and git. for Heroku

* Specify the Heroku app to deploy to

* Double check current config

* debug heroku auth

* Work that netrc

* try and preserve newlines when writing netrc

* Be extra specific with the GH branch we want to push

* Only deploy on master

* I read the docs

* Install specific node versions

* Cache Node Modules runs

* Cache Ruby dependencies

* Ditch Travis

Switch the build badge from Travis to GH Actions

ayy

wow

Clobber the remote ref

Fix a Gemfile Ruby version issue

Fetch the whole repository because Heroku wants it

Keep the Heroku app names secret and Deploy to Production
waltz added a commit to waltz/imploder that referenced this issue Mar 1, 2020
* Try installing a few deps

* Install Node, Ruby, and attach a Postgres instance

* Match the installed version of ruby with the one in ruby-version

* Use a clever method for finding the current ruby version

actions/setup-ruby#31 (comment)

* Oops, gotta checkout the code before reading the version

* Bump to the latest patch version of Ruby

* Bump the Gemfile too

* Health check the Postgres instance and split out the bundle step

* use the latest Postgres, reformat the heallth check

* Point Rails at the service container

* Switch back to port mapping postgres to the local machine

* Manually set up the postgres instance and use DATABASE_URL for telling Rails where to look

* Deploy using GitHub workflows

* Use secrets store

* Setup both api. and git. for Heroku

* Specify the Heroku app to deploy to

* Double check current config

* debug heroku auth

* Work that netrc

* try and preserve newlines when writing netrc

* Be extra specific with the GH branch we want to push

* Only deploy on master

* I read the docs

* Install specific node versions

* Cache Node Modules runs

* Cache Ruby dependencies

* Ditch Travis

Switch the build badge from Travis to GH Actions

ayy

wow

Clobber the remote ref

Fix a Gemfile Ruby version issue

Fetch the whole repository because Heroku wants it

Keep the Heroku app names secret and Deploy to Production
lawrence-forooghian added a commit to lawrence-forooghian/git-update-messages that referenced this issue Mar 26, 2020
This is GitHub’s default template, plus an extra step to respect `.ruby-version`, which is taken from actions/setup-ruby#31 (comment).
lawrence-forooghian added a commit to lawrence-forooghian/git-update-messages that referenced this issue Mar 26, 2020
This is GitHub’s default template, plus an extra step to respect `.ruby-version`, which is taken from actions/setup-ruby#31 (comment).
lawrence-forooghian added a commit to lawrence-forooghian/git-update-messages that referenced this issue Mar 26, 2020
This is GitHub’s default template, plus an extra step to respect `.ruby-version`, which is taken from actions/setup-ruby#31 (comment).
lawrence-forooghian added a commit to lawrence-forooghian/git-update-messages that referenced this issue Mar 26, 2020
The step to respect `.ruby-version` is taken from
actions/setup-ruby#31 (comment).
lawrence-forooghian added a commit to lawrence-forooghian/git-update-messages that referenced this issue Mar 26, 2020
The step to respect `.ruby-version` is taken from
actions/setup-ruby#31 (comment).
@mo-rubikal
Copy link

I saw the same concept works for user-ruby-action as following: (tested and working)


      - name: Install Ruby version from .ruby-version
        uses: eregon/use-ruby-action@master

It would be nice if that supported the same way here.

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Apr 6, 2020

Given that someone may be AFK...

eregon/use-ruby-action@master has moved to ruby/setup-ruby.

For info specific to .ruby_version, see supported-version-syntax.

ruby/setup-ruby supports almost all Ruby versions since 2.2, fully tested head/master builds, and all platforms are supported. Understandably, GitHub prefers not to host EOL software, but others can, as does ruby/setup-ruby. I'm not recommending using it.

Also, most actions that are past development stage are not using master. Or, master may be dangerous, as new features may be developed there. So, use

uses: ruby/setup-ruby@v1

instead of

uses: ruby/setup-ruby@master

@mo-rubikal
Copy link

That got me confused as I was trying to install my ruby version which I can't give as an argument for setup-ruby, and the only way mentioned as in the example:

    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.6

Until I landed in an example that does so as my last comment, I wonder why that not specified in the docs here, if that is the official one!

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Apr 6, 2020

Forgive me, I'm confused.

why that not specified in the docs here

here is actions/setup-ruby, which is the action supported by GitHub.

My post was mostly referring to ruby/setup-ruby (which is where eregon/use-ruby-action moved to) which is within the Ruby organization, and is not supported by GitHub.

If, using ruby/setup-ruby, you want to read Ruby version info from the .ruby-version file, use:

- uses: ruby/setup-ruby@v1
  with:
    ruby-version: .ruby-version

You can also not include the ruby-version: input, but specifying .ruby-version makes it very clear where the info is retrieved from.

@mo-rubikal
Copy link

mo-rubikal commented Apr 6, 2020

Thanks, @MSP-Greg for clarification, both have the same name really confused me, between Ruby and Actions, and BTW when I used:

uses: ruby/setup-ruby@v1

without with clause it worked as well

Screen Shot 2020-04-06 at 4 12 24 AM

@eregon
Copy link
Contributor

eregon commented Apr 6, 2020

@mo-rubikal Glad you found how to use it.
Do you think the docs at https://github.com/ruby/setup-ruby#usage are clear enough about this?
If not, please file an issue and I'll try to improve them.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants