Compare commits

...
8 Commits
Author SHA1 Message Date
Benoit Daloze 108b3a2c8a Various cleanups 2020-09-03 13:42:03 +02:00
Benoit Daloze 25ccf0aad8 Fix interpolation in addVCVARSEnv() 2020-09-03 13:42:03 +02:00
Benoit Daloze 9ec93a2370 Print the full $PATH with bash to help debugging 2020-09-03 13:21:50 +02:00
MSP-Greg a096b998ad Add Actions 'bash test' and 'Windows JRuby' (gem install sassc) steps 2020-09-03 12:13:49 +02:00
MSP-Greg 6ead459c74 Add envPreInstall, common.setupPath, use MSYS2 bash for Windows bash
envPreInstall - sets ENV values for runners

common.setupPath - collects all Path operations into one function, runs before Ruby install

Add MSYS2 paths to all Windows builds for MSYS2 Bash use
2020-09-03 12:13:49 +02:00
MSP-Greg 45ec312a6e windows.js - remove code for embedded MSYS2 2020-09-03 12:13:49 +02:00
Benoit Daloze 568cdbf232 Revert "Add support for gems.rb/gems.locked during bundle install."
* This reverts commit 638e8fff19.
* Needs some fixes and review.
2020-09-03 11:58:37 +02:00
Samuel Williams 638e8fff19 Add support for gems.rb/gems.locked during bundle install. 2020-09-03 10:48:45 +12:00
6 changed files with 184 additions and 164 deletions
+9
View File
@@ -41,6 +41,9 @@ jobs:
ruby-version: ${{ matrix.ruby }} ruby-version: ${{ matrix.ruby }}
bundler-cache: true bundler-cache: true
- run: ruby -v - run: ruby -v
- name: PATH
shell: bash
run: echo $PATH
- name: build compiler - name: build compiler
run: | run: |
@@ -85,6 +88,12 @@ jobs:
else { echo "Can't find $e" } else { echo "Can't find $e" }
echo '' echo ''
} }
- name: bash test
shell: bash
run: echo ~
- name: Windows JRuby
if: startsWith(matrix.os, 'windows') && startsWith(matrix.ruby, 'jruby')
run: gem install sassc -N
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
+36 -1
View File
@@ -1,4 +1,5 @@
const os = require('os') const os = require('os')
const path = require('path')
const fs = require('fs') const fs = require('fs')
const util = require('util') const util = require('util')
const stream = require('stream') const stream = require('stream')
@@ -6,6 +7,10 @@ const crypto = require('crypto')
const core = require('@actions/core') const core = require('@actions/core')
const { performance } = require('perf_hooks') const { performance } = require('perf_hooks')
export const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
export async function measure(name, block) { export async function measure(name, block) {
return await core.group(name, async () => { return await core.group(name, async () => {
const start = performance.now() const start = performance.now()
@@ -55,10 +60,40 @@ function findUbuntuVersion() {
} }
// convert windows path like C:\Users\runneradmin to /c/Users/runneradmin // convert windows path like C:\Users\runneradmin to /c/Users/runneradmin
export function win2nix(path) { export function win2nix(path) {
if (/^[A-Z]:/i.test(path)) { if (/^[A-Z]:/i.test(path)) {
// path starts with drive // path starts with drive
path = `/${path[0].toLowerCase()}${path.split(':', 2)[1]}` path = `/${path[0].toLowerCase()}${path.split(':', 2)[1]}`
} }
return path.replace(/\\/g, '/').replace(/ /g, '\\ ') return path.replace(/\\/g, '/').replace(/ /g, '\\ ')
} }
export function setupPath(newPathEntries) {
const envPath = windows ? 'Path' : 'PATH'
const originalPath = process.env[envPath].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
// First remove the conflicting path entries
if (cleanPath.length !== originalPath.length) {
core.startGroup(`Cleaning ${envPath}`)
console.log(`Entries removed from ${envPath} to avoid conflicts with Ruby:`)
for (const entry of originalPath) {
if (!cleanPath.includes(entry)) {
console.log(` ${entry}`)
}
}
core.exportVariable(envPath, cleanPath.join(path.delimiter))
core.endGroup()
}
// Then add new path entries using core.addPath()
let newPath
if (windows) {
// add MSYS2 in path for all Rubies on Windows, as it provides a better bash shell and a native toolchain
const msys2 = ['C:\\msys64\\mingw64\\bin', 'C:\\msys64\\usr\\bin']
newPath = [...newPathEntries, ...msys2]
} else {
newPath = newPathEntries
}
core.addPath(newPath.join(path.delimiter))
}
Generated Vendored
+89 -82
View File
@@ -27670,20 +27670,14 @@ const tc = __webpack_require__(188)
const common = __webpack_require__(390) const common = __webpack_require__(390)
const rubyInstallerVersions = __webpack_require__(223).versions const rubyInstallerVersions = __webpack_require__(223).versions
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14 const drive = common.drive
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
// needed for 2.1, 2.2, 2.3, and mswin, cert file used by Git for Windows // needed for 2.1, 2.2, 2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// standard MSYS2 location, found by 'devkit.rb'
const msys2 = 'C:\\msys64'
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.1, 2.2 and 2.3 // location & path for old RubyInstaller DevKit (MSYS), Ruby 2.1, 2.2 and 2.3
const msys = `${drive}:\\DevKit64` const msys = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`]
`${msys}\\mingw\\bin`, `${msys}\\bin`]
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
if (engine === 'ruby') { if (engine === 'ruby') {
@@ -27701,6 +27695,12 @@ async function install(platform, engine, version) {
} }
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length) const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
const rubyPrefix = `${drive}:\\${base}`
let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
const downloadPath = await common.measure('Downloading Ruby', async () => { const downloadPath = await common.measure('Downloading Ruby', async () => {
console.log(url) console.log(url)
return await tc.downloadTool(url) return await tc.downloadTool(url)
@@ -27708,26 +27708,8 @@ async function install(platform, engine, version) {
await common.measure('Extracting Ruby', async () => await common.measure('Extracting Ruby', async () =>
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })) exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }))
const rubyPrefix = `${drive}:\\${base}`
let toolchainPaths = (version === 'mswin') ? return rubyPrefix
await setupMSWin() : await setupMingw(version)
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
return [rubyPrefix, newPathEntries]
}
// Remove when Actions Windows image contains MSYS2 install
async function symLinkToEmbeddedMSYS2() {
const toolCacheVersions = tc.findAllVersions('Ruby')
toolCacheVersions.sort()
if (toolCacheVersions.length === 0) {
throw new Error('Could not find MSYS2 in the toolcache')
}
const latestVersion = toolCacheVersions.slice(-1)[0]
const hostedRuby = tc.find('Ruby', latestVersion)
await common.measure('Linking MSYS2', async () =>
exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`))
} }
async function setupMingw(version) { async function setupMingw(version) {
@@ -27735,17 +27717,10 @@ async function setupMingw(version) {
if (version.match(/^2\.[123]/)) { if (version.match(/^2\.[123]/)) {
core.exportVariable('SSL_CERT_FILE', certFile) core.exportVariable('SSL_CERT_FILE', certFile)
await common.measure('Installing MSYS1', async () => await common.measure('Installing MSYS', async () => installMSYS(version))
installMSYS(version))
return msysPathEntries return msysPathEntries
} else { } else {
// Remove when Actions Windows image contains MSYS2 install return []
if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
return msys2PathEntries
} }
} }
@@ -27778,15 +27753,7 @@ async function setupMSWin() {
fs.copyFileSync(certFile, cert) fs.copyFileSync(certFile, cert)
} }
// Remove when Actions Windows image contains MSYS2 install return await common.measure('Setting up MSVC environment', async () => addVCVARSEnv())
if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
const VCPathEntries = await common.measure('Setting up MSVC environment', async () =>
addVCVARSEnv())
return [...VCPathEntries, ...msys2PathEntries]
} }
/* Sets MSVC environment for use in Actions /* Sets MSVC environment for use in Actions
@@ -27809,8 +27776,9 @@ function addVCVARSEnv() {
let newPathEntries = undefined let newPathEntries = undefined
for (let [k, v] of newEnv) { for (let [k, v] of newEnv) {
if (process.env[k] !== v) { if (process.env[k] !== v) {
if (k === 'Path') { if (/^Path$/i.test(k)) {
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter) const newPathStr = v.replace(`${path.delimiter}${process.env['Path']}`, '')
newPathEntries = newPathStr.split(path.delimiter)
} else { } else {
core.exportVariable(k, v) core.exportVariable(k, v)
} }
@@ -32085,12 +32053,16 @@ exports.default = _default;
"use strict"; "use strict";
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "windows", function() { return windows; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drive", function() { return drive; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hashFile", function() { return hashFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "win2nix", function() { return win2nix; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "win2nix", function() { return win2nix; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupPath", function() { return setupPath; });
const os = __webpack_require__(87) const os = __webpack_require__(87)
const path = __webpack_require__(622)
const fs = __webpack_require__(747) const fs = __webpack_require__(747)
const util = __webpack_require__(669) const util = __webpack_require__(669)
const stream = __webpack_require__(413) const stream = __webpack_require__(413)
@@ -32098,6 +32070,10 @@ const crypto = __webpack_require__(373)
const core = __webpack_require__(186) const core = __webpack_require__(186)
const { performance } = __webpack_require__(630) const { performance } = __webpack_require__(630)
const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
async function measure(name, block) { async function measure(name, block) {
return await core.group(name, async () => { return await core.group(name, async () => {
const start = performance.now() const start = performance.now()
@@ -32147,7 +32123,7 @@ function findUbuntuVersion() {
} }
// convert windows path like C:\Users\runneradmin to /c/Users/runneradmin // convert windows path like C:\Users\runneradmin to /c/Users/runneradmin
function win2nix(path) { function win2nix(path) {
if (/^[A-Z]:/i.test(path)) { if (/^[A-Z]:/i.test(path)) {
// path starts with drive // path starts with drive
path = `/${path[0].toLowerCase()}${path.split(':', 2)[1]}` path = `/${path[0].toLowerCase()}${path.split(':', 2)[1]}`
@@ -32155,6 +32131,36 @@ function win2nix(path) {
return path.replace(/\\/g, '/').replace(/ /g, '\\ ') return path.replace(/\\/g, '/').replace(/ /g, '\\ ')
} }
function setupPath(newPathEntries) {
const envPath = windows ? 'Path' : 'PATH'
const originalPath = process.env[envPath].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
// First remove the conflicting path entries
if (cleanPath.length !== originalPath.length) {
core.startGroup(`Cleaning ${envPath}`)
console.log(`Entries removed from ${envPath} to avoid conflicts with Ruby:`)
for (const entry of originalPath) {
if (!cleanPath.includes(entry)) {
console.log(` ${entry}`)
}
}
core.exportVariable(envPath, cleanPath.join(path.delimiter))
core.endGroup()
}
// Then add new path entries using core.addPath()
let newPath
if (windows) {
// add MSYS2 in path for all Rubies on Windows, as it provides a better bash shell and a native toolchain
const msys2 = ['C:\\msys64\\mingw64\\bin', 'C:\\msys64\\usr\\bin']
newPath = [...newPathEntries, ...msys2]
} else {
newPath = newPathEntries
}
core.addPath(newPath.join(path.delimiter))
}
/***/ }), /***/ }),
/* 391 */, /* 391 */,
@@ -51350,6 +51356,8 @@ const exec = __webpack_require__(514)
const cache = __webpack_require__(799) const cache = __webpack_require__(799)
const common = __webpack_require__(390) const common = __webpack_require__(390)
const windows = common.windows
const inputDefaults = { const inputDefaults = {
'ruby-version': 'default', 'ruby-version': 'default',
'bundler': 'default', 'bundler': 'default',
@@ -51370,7 +51378,7 @@ async function run() {
async function setupRuby(options = {}) { async function setupRuby(options = {}) {
const inputs = { ...options } const inputs = { ...options }
for (const key in inputDefaults) { for (const key in inputDefaults) {
if (!inputs.hasOwnProperty(key)) { if (!Object.prototype.hasOwnProperty.call(inputs, key)) {
inputs[key] = core.getInput(key) || inputDefaults[key] inputs[key] = core.getInput(key) || inputDefaults[key]
} }
} }
@@ -51391,10 +51399,9 @@ async function setupRuby(options = {}) {
const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
createGemRC() createGemRC()
envPreInstall()
const [rubyPrefix, newPathEntries] = await installer.install(platform, engine, version) const rubyPrefix = await installer.install(platform, engine, version)
setupPath(newPathEntries)
// When setup-ruby is used by other actions, this allows code in them to run // When setup-ruby is used by other actions, this allows code in them to run
// before 'bundle install'. Installed dependencies may require additional // before 'bundle install'. Installed dependencies may require additional
@@ -51479,22 +51486,18 @@ function createGemRC() {
} }
} }
function setupPath(newPathEntries) { // sets up ENV variables
const originalPath = process.env['PATH'].split(path.delimiter) // currently only used on Windows runners
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry)) function envPreInstall() {
const ENV = process.env
if (cleanPath.length !== originalPath.length) { if (windows) {
core.startGroup('Cleaning PATH') // puts normal Ruby temp folder on SSD
console.log('Entries removed from PATH to avoid conflicts with Ruby:') core.exportVariable('TMPDIR', ENV['RUNNER_TEMP'])
for (const entry of originalPath) { // bash - sets home to match native windows, normally C:\Users\<user name>
if (!cleanPath.includes(entry)) { core.exportVariable('HOME', ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
console.log(` ${entry}`) // bash - needed to maintain Path from Windows
} core.exportVariable('MSYS2_PATH_TYPE', 'inherit')
}
core.endGroup()
} }
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
} }
function readBundledWithFromGemfileLock(path) { function readBundledWithFromGemfileLock(path) {
@@ -53066,23 +53069,28 @@ const rubyBuilderVersions = __webpack_require__(694)
const builderReleaseTag = 'enable-shared' const builderReleaseTag = 'enable-shared'
const releasesURL = 'https://github.com/ruby/ruby-builder/releases' const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
const windows = common.windows
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
return rubyBuilderVersions.getVersions(platform)[engine] return rubyBuilderVersions.getVersions(platform)[engine]
} }
async function install(platform, engine, version) { async function install(platform, engine, version) {
const rubyPrefix = await downloadAndExtract(platform, engine, version) return await downloadAndExtract(platform, engine, version)
let newPathEntries
if (engine === 'rubinius') {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else {
newPathEntries = [path.join(rubyPrefix, 'bin')]
}
return [rubyPrefix, newPathEntries]
} }
async function downloadAndExtract(platform, engine, version) { async function downloadAndExtract(platform, engine, version) {
const rubiesDir = path.join(os.homedir(), '.rubies') const rubiesDir = windows ? `${common.drive}:` : path.join(os.homedir(), '.rubies')
const rubyPrefix = path.join(rubiesDir, `${engine}-${version}`)
// Set the PATH now, so the MSYS2 'tar' is in Path on Windows
if (engine === 'rubinius') {
common.setupPath([path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')])
} else {
common.setupPath([path.join(rubyPrefix, 'bin')])
}
await io.mkdirP(rubiesDir) await io.mkdirP(rubiesDir)
const downloadPath = await common.measure('Downloading Ruby', async () => { const downloadPath = await common.measure('Downloading Ruby', async () => {
@@ -53092,16 +53100,15 @@ async function downloadAndExtract(platform, engine, version) {
}) })
await common.measure('Extracting Ruby', async () => { await common.measure('Extracting Ruby', async () => {
if (process.env.ImageOS === 'win16') { if (windows) {
const tar = '"C:\\Program Files\\Git\\usr\\bin\\tar.exe"' // Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
await exec.exec(tar, [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ]) await exec.exec('tar', [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ])
} else { } else {
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar' await exec.exec('tar', [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
} }
}) })
return path.join(rubiesDir, `${engine}-${version}`) return rubyPrefix
} }
function getDownloadURL(platform, engine, version) { function getDownloadURL(platform, engine, version) {
+16 -19
View File
@@ -6,6 +6,8 @@ const exec = require('@actions/exec')
const cache = require('@actions/cache') const cache = require('@actions/cache')
const common = require('./common') const common = require('./common')
const windows = common.windows
const inputDefaults = { const inputDefaults = {
'ruby-version': 'default', 'ruby-version': 'default',
'bundler': 'default', 'bundler': 'default',
@@ -26,7 +28,7 @@ export async function run() {
export async function setupRuby(options = {}) { export async function setupRuby(options = {}) {
const inputs = { ...options } const inputs = { ...options }
for (const key in inputDefaults) { for (const key in inputDefaults) {
if (!inputs.hasOwnProperty(key)) { if (!Object.prototype.hasOwnProperty.call(inputs, key)) {
inputs[key] = core.getInput(key) || inputDefaults[key] inputs[key] = core.getInput(key) || inputDefaults[key]
} }
} }
@@ -47,10 +49,9 @@ export async function setupRuby(options = {}) {
const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
createGemRC() createGemRC()
envPreInstall()
const [rubyPrefix, newPathEntries] = await installer.install(platform, engine, version) const rubyPrefix = await installer.install(platform, engine, version)
setupPath(newPathEntries)
// When setup-ruby is used by other actions, this allows code in them to run // When setup-ruby is used by other actions, this allows code in them to run
// before 'bundle install'. Installed dependencies may require additional // before 'bundle install'. Installed dependencies may require additional
@@ -135,22 +136,18 @@ function createGemRC() {
} }
} }
function setupPath(newPathEntries) { // sets up ENV variables
const originalPath = process.env['PATH'].split(path.delimiter) // currently only used on Windows runners
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry)) function envPreInstall() {
const ENV = process.env
if (cleanPath.length !== originalPath.length) { if (windows) {
core.startGroup('Cleaning PATH') // puts normal Ruby temp folder on SSD
console.log('Entries removed from PATH to avoid conflicts with Ruby:') core.exportVariable('TMPDIR', ENV['RUNNER_TEMP'])
for (const entry of originalPath) { // bash - sets home to match native windows, normally C:\Users\<user name>
if (!cleanPath.includes(entry)) { core.exportVariable('HOME', ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
console.log(` ${entry}`) // bash - needed to maintain Path from Windows
} core.exportVariable('MSYS2_PATH_TYPE', 'inherit')
}
core.endGroup()
} }
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
} }
function readBundledWithFromGemfileLock(path) { function readBundledWithFromGemfileLock(path) {
+19 -15
View File
@@ -9,23 +9,28 @@ const rubyBuilderVersions = require('./ruby-builder-versions')
const builderReleaseTag = 'enable-shared' const builderReleaseTag = 'enable-shared'
const releasesURL = 'https://github.com/ruby/ruby-builder/releases' const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
const windows = common.windows
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
return rubyBuilderVersions.getVersions(platform)[engine] return rubyBuilderVersions.getVersions(platform)[engine]
} }
export async function install(platform, engine, version) { export async function install(platform, engine, version) {
const rubyPrefix = await downloadAndExtract(platform, engine, version) return await downloadAndExtract(platform, engine, version)
let newPathEntries
if (engine === 'rubinius') {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else {
newPathEntries = [path.join(rubyPrefix, 'bin')]
}
return [rubyPrefix, newPathEntries]
} }
async function downloadAndExtract(platform, engine, version) { async function downloadAndExtract(platform, engine, version) {
const rubiesDir = path.join(os.homedir(), '.rubies') const rubiesDir = windows ? `${common.drive}:` : path.join(os.homedir(), '.rubies')
const rubyPrefix = path.join(rubiesDir, `${engine}-${version}`)
// Set the PATH now, so the MSYS2 'tar' is in Path on Windows
if (engine === 'rubinius') {
common.setupPath([path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')])
} else {
common.setupPath([path.join(rubyPrefix, 'bin')])
}
await io.mkdirP(rubiesDir) await io.mkdirP(rubiesDir)
const downloadPath = await common.measure('Downloading Ruby', async () => { const downloadPath = await common.measure('Downloading Ruby', async () => {
@@ -35,16 +40,15 @@ async function downloadAndExtract(platform, engine, version) {
}) })
await common.measure('Extracting Ruby', async () => { await common.measure('Extracting Ruby', async () => {
if (process.env.ImageOS === 'win16') { if (windows) {
const tar = '"C:\\Program Files\\Git\\usr\\bin\\tar.exe"' // Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
await exec.exec(tar, [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ]) await exec.exec('tar', [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ])
} else { } else {
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar' await exec.exec('tar', [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
} }
}) })
return path.join(rubiesDir, `${engine}-${version}`) return rubyPrefix
} }
function getDownloadURL(platform, engine, version) { function getDownloadURL(platform, engine, version) {
+15 -47
View File
@@ -10,20 +10,14 @@ const tc = require('@actions/tool-cache')
const common = require('./common') const common = require('./common')
const rubyInstallerVersions = require('./windows-versions').versions const rubyInstallerVersions = require('./windows-versions').versions
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14 const drive = common.drive
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
// needed for 2.1, 2.2, 2.3, and mswin, cert file used by Git for Windows // needed for 2.1, 2.2, 2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// standard MSYS2 location, found by 'devkit.rb'
const msys2 = 'C:\\msys64'
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.1, 2.2 and 2.3 // location & path for old RubyInstaller DevKit (MSYS), Ruby 2.1, 2.2 and 2.3
const msys = `${drive}:\\DevKit64` const msys = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`]
`${msys}\\mingw\\bin`, `${msys}\\bin`]
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (engine === 'ruby') { if (engine === 'ruby') {
@@ -41,6 +35,12 @@ export async function install(platform, engine, version) {
} }
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length) const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
const rubyPrefix = `${drive}:\\${base}`
let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
const downloadPath = await common.measure('Downloading Ruby', async () => { const downloadPath = await common.measure('Downloading Ruby', async () => {
console.log(url) console.log(url)
return await tc.downloadTool(url) return await tc.downloadTool(url)
@@ -48,26 +48,8 @@ export async function install(platform, engine, version) {
await common.measure('Extracting Ruby', async () => await common.measure('Extracting Ruby', async () =>
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })) exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }))
const rubyPrefix = `${drive}:\\${base}`
let toolchainPaths = (version === 'mswin') ? return rubyPrefix
await setupMSWin() : await setupMingw(version)
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
return [rubyPrefix, newPathEntries]
}
// Remove when Actions Windows image contains MSYS2 install
async function symLinkToEmbeddedMSYS2() {
const toolCacheVersions = tc.findAllVersions('Ruby')
toolCacheVersions.sort()
if (toolCacheVersions.length === 0) {
throw new Error('Could not find MSYS2 in the toolcache')
}
const latestVersion = toolCacheVersions.slice(-1)[0]
const hostedRuby = tc.find('Ruby', latestVersion)
await common.measure('Linking MSYS2', async () =>
exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`))
} }
async function setupMingw(version) { async function setupMingw(version) {
@@ -75,17 +57,10 @@ async function setupMingw(version) {
if (version.match(/^2\.[123]/)) { if (version.match(/^2\.[123]/)) {
core.exportVariable('SSL_CERT_FILE', certFile) core.exportVariable('SSL_CERT_FILE', certFile)
await common.measure('Installing MSYS1', async () => await common.measure('Installing MSYS', async () => installMSYS(version))
installMSYS(version))
return msysPathEntries return msysPathEntries
} else { } else {
// Remove when Actions Windows image contains MSYS2 install return []
if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
return msys2PathEntries
} }
} }
@@ -118,15 +93,7 @@ async function setupMSWin() {
fs.copyFileSync(certFile, cert) fs.copyFileSync(certFile, cert)
} }
// Remove when Actions Windows image contains MSYS2 install return await common.measure('Setting up MSVC environment', async () => addVCVARSEnv())
if (!fs.existsSync(msys2)) {
await symLinkToEmbeddedMSYS2()
}
const VCPathEntries = await common.measure('Setting up MSVC environment', async () =>
addVCVARSEnv())
return [...VCPathEntries, ...msys2PathEntries]
} }
/* Sets MSVC environment for use in Actions /* Sets MSVC environment for use in Actions
@@ -149,8 +116,9 @@ export function addVCVARSEnv() {
let newPathEntries = undefined let newPathEntries = undefined
for (let [k, v] of newEnv) { for (let [k, v] of newEnv) {
if (process.env[k] !== v) { if (process.env[k] !== v) {
if (k === 'Path') { if (/^Path$/i.test(k)) {
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter) const newPathStr = v.replace(`${path.delimiter}${process.env['Path']}`, '')
newPathEntries = newPathStr.split(path.delimiter)
} else { } else {
core.exportVariable(k, v) core.exportVariable(k, v)
} }