Skip to content

Commit

Permalink
Add win-ruby-platform-override input
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Jan 17, 2024
1 parent b203567 commit 9860681
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,22 @@ jobs:
bundler-cache: true
- run: bundle list | grep nokogiri

testWinRubyPlatformOverride:
name: "Test input win-platform: none"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
ruby-version: '2.7'
win-ruby-platform-override: none
bundler: none
- name: C:/msys64/mingw64/bin/gcc.exe not installed
run: |
if (Test-Path -Path "C:/msys64/mingw64/bin/gcc.exe" -PathType Leaf ) {
exit 1
}
lint:
runs-on: ubuntu-20.04
steps:
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ inputs:
Consider the runner as a self-hosted runner, which means not using prebuilt Ruby binaries which only work
on GitHub-hosted runners or self-hosted runners with a very similar image to the ones used by GitHub runners.
The default is to detect this automatically based on the OS, OS version and architecture.
win-ruby-platform-override:
description: |
This only affect Windows runners. Allows Windows platform setup to override the setup based on RUBY_PLATFORM.
At present, the only allowed setting is "none", which only adds Ruby to PATH.
No build tools are installed, nor are any ENV setting changed to activate them.
default: 'default'

outputs:
ruby-prefix:
description: 'The prefix of the installed ruby'
Expand Down
3 changes: 2 additions & 1 deletion common.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ export function setupPath(newPathEntries) {

// Then add new path entries using core.addPath()
let newPath
if (windows) {
const winRubyPlatformOverride = core.getInput('win-ruby-platform-override')
if (windows && winRubyPlatformOverride !== 'none') {
// main Ruby dll determines whether mingw or ucrt build
msys2Type = rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'

Expand Down
13 changes: 10 additions & 3 deletions dist/index.js

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

1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const inputDefaults = {
'working-directory': '.',
'cache-version': bundler.DEFAULT_CACHE_VERSION,
'self-hosted': 'false',
'win-ruby-platform-override': 'default',
}

// entry point when this action is run on its own
Expand Down
9 changes: 7 additions & 2 deletions windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ export async function install(platform, engine, version) {
rubyPrefix = `${drive}:\\${base}`
}

let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)

if (!inToolCache) {
await downloadAndExtract(engine, version, url, base, rubyPrefix);
}

const winRubyPlatformOverride = core.getInput('win-ruby-platform-override')
if (winRubyPlatformOverride === 'none') {
common.setupPath([`${rubyPrefix}\\bin`])
return rubyPrefix
}

let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
const msys2Type = common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])

// install msys2 tools for all Ruby versions, only install mingw or ucrt for Rubies >= 2.4
Expand Down

0 comments on commit 9860681

Please sign in to comment.