Skip to content

Add windows-toolchain input #563

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2024
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
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,19 @@ jobs:
bundler-cache: true
- run: bundle list | grep nokogiri

testWindowsToolchain:
name: "Test windows-toolchain: none"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
ruby-version: '2.7'
windows-toolchain: none
bundler: none
- name: C:/msys64/mingw64/bin/gcc.exe not installed
run: ruby -e "abort if File.exist?('C:/msys64/mingw64/bin/gcc.exe')"

lint:
runs-on: ubuntu-20.04
steps:
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ 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.
windows-toolchain:
description: |
This input allows to override the default toolchain setup on Windows.
The default setting ('default') installs a toolchain based on the selected Ruby.
Specifically, it installs MSYS2 if not already there and installs mingw/ucrt/mswin build tools and packages.
It also sets environment variables using 'ridk' or 'vcvars64.bat' based on the selected Ruby.
At present, the only other setting than 'default' is 'none', which only adds Ruby to PATH.
No build tools or packages are installed, nor are any ENV setting changed to activate them.
default: 'default'
Copy link
Member

Choose a reason for hiding this comment

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

Having the default here is nice documentation-wise, but OTOH it has the side effect to always show this input (e.g. https://github.com/ruby/setup-ruby/actions/runs/7586102328/job/20663507608?pr=563#step:3:5) even though this input is likely to be used by very few.
So I'll remove this line to be consistent with other "non-required inputs".


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 windowsToolchain = core.getInput('windows-toolchain')
if (windows && windowsToolchain !== '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',
'windows-toolchain': '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 windowsToolchain = core.getInput('windows-toolchain')
if (windowsToolchain === '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