From ef45abe478676b72b5c43674a3ded9fa7a91ac01 Mon Sep 17 00:00:00 2001 From: Marcel Hoppe Date: Wed, 5 Feb 2025 11:09:26 +0100 Subject: [PATCH 1/2] Add support for mise.toml (#700) Co-authored-by: Benoit Daloze --- README.md | 7 ++++--- action.yml | 4 ++-- dist/index.js | 7 +++++++ index.js | 7 +++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 150f04273..5bc0f1ecc 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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 diff --git a/action.yml b/action.yml index 302149251..3e052125e 100644 --- a/action.yml +++ b/action.yml @@ -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: | @@ -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 diff --git a/dist/index.js b/dist/index.js index 931d9e2ee..9c214dee1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -74913,6 +74913,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') } @@ -74926,6 +74928,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 + 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 diff --git a/index.js b/index.js index eb71b4ed2..e50f92dd9 100644 --- a/index.js +++ b/index.js @@ -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') } @@ -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 + 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 From 8711a86ab6f9aa72890da4123b2ef7283b6b22b6 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 5 Feb 2025 11:11:17 +0100 Subject: [PATCH 2/2] Shorten to avoid horizontal scrolling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bc0f1ecc..fa465375d 100644 --- a/README.md +++ b/README.md @@ -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`, `.tool-versions` or `mise.toml` + 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 ```