Skip to content
New issue

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

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

Already on GitHub? # to your account

Add support for mise.toml #700

Merged
merged 6 commits into from
Feb 5, 2025
Merged
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3' # Not needed with a `.ruby-version` or `.tool-versions`
ruby-version: '3.3' # Not needed with a `.ruby-version`, `.tool-versions` or `mise.toml`
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
```
Expand Down Expand Up @@ -139,11 +139,12 @@ and the [condition and expression syntax](https://help.github.com/en/actions/ref
* engine only like `ruby` and `truffleruby`, uses the latest stable release of that implementation
* `.ruby-version` reads from the project's `.ruby-version` file
* `.tool-versions` reads from the project's `.tool-versions` file
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`
* `mise.toml` reads from the project's `mise.toml` file
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`, followed by `mise.toml`

### Working Directory

The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions` and `Gemfile.lock`
The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions`, `mise.toml` and `Gemfile.lock`
if they are not at the root of the repository, see [action.yml](action.yml) for details.

### RubyGems
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ branding:
icon: download
inputs:
ruby-version:
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version or .tool-versions if unset.'
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version, .tool-versions or mise.toml if unset.'
default: 'default'
rubygems:
description: |
Expand All @@ -26,7 +26,7 @@ inputs:
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
default: 'false'
working-directory:
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions, mise.toml and Gemfile.lock.'
cache-version:
description: |
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
Expand Down
7 changes: 7 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ function parseRubyEngineAndVersion(rubyVersion) {
rubyVersion = '.ruby-version'
} else if (fs.existsSync('.tool-versions')) {
rubyVersion = '.tool-versions'
} else if (fs.existsSync('mise.toml')) {
rubyVersion = 'mise.toml'
} else {
throw new Error('input ruby-version needs to be specified if no .ruby-version or .tool-versions file exists')
}
Expand All @@ -130,6 +132,11 @@ function parseRubyEngineAndVersion(rubyVersion) {
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
} else if (rubyVersion === 'mise.toml') { // Read from mise.toml
Copy link
Member

Choose a reason for hiding this comment

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

https://mise.jdx.dev/configuration.html has 6 possible locations 😅
Hopefully mise.toml is the most common one, I don't really want to logic to search all those.
So yeah, let's look for just mise.toml for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i see, you are right 😅 especially the conf.d would be crap 😁

const toolVersions = fs.readFileSync('mise.toml', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s*=\s*/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s*=\s*['"](.+)['"]$/)[1]
console.log(`Using ${rubyVersion} as input from file mise.toml`)
}

let engine, version
Expand Down