From 558057564b472b2f3f1ef9dae78f1a8f66ceff66 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Tue, 16 Jan 2024 21:11:16 -0600 Subject: [PATCH 1/2] Add windows-toolchain input --- .github/workflows/test.yml | 13 +++++++++++++ action.yml | 10 ++++++++++ common.js | 3 ++- dist/index.js | 13 ++++++++++--- index.js | 1 + windows.js | 9 +++++++-- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 433c64361..37d380749 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/action.yml b/action.yml index e67fe6c34..48c441b1d 100644 --- a/action.yml +++ b/action.yml @@ -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' + outputs: ruby-prefix: description: 'The prefix of the installed ruby' diff --git a/common.js b/common.js index 96704ff1b..d283e0235 100644 --- a/common.js +++ b/common.js @@ -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' diff --git a/dist/index.js b/dist/index.js index 872610b2a..6114d8bbd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -701,7 +701,8 @@ 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' @@ -65232,12 +65233,17 @@ 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 @@ -65748,6 +65754,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 diff --git a/index.js b/index.js index 9e393de04..743616a5c 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/windows.js b/windows.js index 28789b134..6053911f0 100644 --- a/windows.js +++ b/windows.js @@ -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 From 5daca165445f0ae10478593083f72ca2625e241d Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 22 Jan 2024 11:08:37 +0100 Subject: [PATCH 2/2] Remove default in action.yml for windows-toolchain * Otherwise it shows up in every usage of the action even if not set. * Consistent with other non-required inputs. --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 48c441b1d..302149251 100644 --- a/action.yml +++ b/action.yml @@ -44,7 +44,6 @@ inputs: 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' outputs: ruby-prefix: