Skip to content

Commit 2ba963f

Browse files
committed
Updates for Actions MSYS2 install, devkit, docs
1 parent 22968c8 commit 2ba963f

File tree

6 files changed

+180
-106
lines changed

6 files changed

+180
-106
lines changed

README.md

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,85 @@
22

33
Cross platform action for Ruby CI that configures build tools and installs packages needed for compiling.
44

5-
The action's input are shown below:
5+
The action's inputs are shown below:
66

77
```yaml
88
- uses: MSP-Greg/setup-ruby-pkgs@v1
99
with:
1010
ruby-version:
11-
apt: # Ubuntu
12-
brew: # macOS
13-
mingw: # Windows mingw
14-
msys2: # mingw
15-
mswin: # Windows mswin
16-
choco: # mswin
17-
vcpkg: # mswin
11+
apt: # Ubuntu
12+
brew: # macOS
13+
mingw: # Windows mingw / mswin
14+
msys2: # mingw
15+
mswin: # Windows mswin
16+
choco: # mswin
17+
vcpkg: # mswin
1818
```
1919
20-
### Input Information
20+
## Input Information
2121
22-
All inputs are optional. If ruby-versions is used, the code for [ruby/setup-ruby](https://github.com/ruby/setup-ruby) is used.
22+
All inputs are optional.
2323
24-
#### apt (Ubuntu)
24+
### ruby-version:
25+
26+
Installs the Ruby version using the code from [ruby/setup-ruby](https://github.com/ruby/setup-ruby). The available versions can be found in its [README](https://github.com/ruby/setup-ruby/blob/master/README.md#supported-versions).
27+
28+
### apt: (Ubuntu)
2529
2630
List of packages to install. Space delimited. Special options are `_update_` and `_upgrade_`.
2731

28-
#### brew (macOS)
32+
### brew: (macOS)
2933

3034
List of packages to install. Space delimited. Special options are `_update_` and `_upgrade_`.
3135

36+
### mingw: (Windows)
37+
38+
<dl>
39+
<dt><b>Ruby 2.4 & later</b></dt>
40+
<dd>List of MSYS2 MinGW packages to install.
41+
Space delimited. The package prefix (<code>mingw-w64-x86_64-</code>) is not required.<br/>If <code>_upgrade_</code> is included in the input, all packages needed by the gcc tools are updated.<br/>If <code>openssl</code> is included, an appropriate package will be installed.
42+
</dd>
43+
<dt><b>Ruby 2.3 & earlier</b></dt>
44+
<dd>The following DevKit packages are available:
45+
<ul>
46+
<li>libffi-3.2.1</li>
47+
<li>openssl-1.0.2j</li>
48+
<li>ragel-6.7</li>
49+
<li>sqlite-3.7.15.2 (sqlite3)</li>
50+
<li>zlib-1.2.8</li>
51+
</ul>
52+
</dd>
53+
<dt><b>Ruby mswin</b></dt>
54+
<dd>If <code>openssl</code> is included, it will be installed for mswin as a convenience.<br/>Likewise, if <code>ragel</code> is included, the MSYS2 ragel package will be installed.
55+
</dl>
56+
57+
### msys2: (Windows)
58+
59+
<dl>
60+
<dt><b>Ruby 2.4 & later</b></dt>
61+
<dd>List of MSYS2 packages to install. Space delimited. These are command line utilities, and are rarely needed.
62+
</dd>
63+
<dt><b>Ruby 2.3 & earlier</b></dt>
64+
<dd>No action, as no utilities are available for the older MSYS/DevKit.</dd>
65+
</dl>
3266

33-
#### mingw (Windows)
67+
### mswin: (Windows)
3468

35-
List of MSYS2 MinGW packages to install. Space delimited. The package prefix (`mingw-w64-x86_64-`) is not required. At present, only 64 bit Rubies and MSYS2 are available.
69+
Installs MSYS2 packages. These are typically build utilities, such as bison, ragel, etc. As in pacman, MinGW packages must be prefixed with `mingw-w64-x86_64-`.
3670

37-
An input string of `_upgrade_` can be included, and will update all packages needed by the gcc tools.
71+
### choco: (Windows)
72+
73+
List of packages to install. Space delimited. Most packages are compiled with msvc, so normally used with mswin builds.
74+
75+
### vcpkg: (Windows)
76+
77+
List of packages to install. Space delimited. All packages are compiled with msvc, so normally used with mswin builds. An environment variable `OPT_DIR` is set to
78+
```
79+
--with-opt-dir=${process.env.VCPKG_INSTALLATION_ROOT}\\installed\\x64-windows
80+
```
3881
39-
TODO: add correct gcc update for Rubies built with older 9.2 and 8.3 gcc.
82+
After install, the tools folder is checked, and if any files are present, it is added to path.
4083
41-
#### msys2 (Windows)
84+
## Ruby and Windows
4285
43-
List of MSYS2 packages to install. Space delimited.
86+
For additional information see [Ruby and Windows](Ruby_and_Windows.md)

Ruby_and_Windows.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[MSYS2]:https://github.com/msys2
2+
[ruby/setup-ruby]:https://github.com/ruby/setup-ruby
3+
4+
# Ruby and Windows
5+
6+
This document is intended to provide information on Windows Ruby builds that may help with Windows CI problems.
7+
8+
Problems are most likely to occur with gems/repos that require compiling. They may also occur when installing dependencies that require compiling.
9+
10+
Much of the below information is general, and may also help with users having problems locally.
11+
12+
## A few specifics
13+
14+
Unlike Ubuntu and macOS, standard Windows does not have native compiling tools, nor does it have package libraries.
15+
16+
* Because of this, Windows Rubies are self-contained. All non-system runtime dlls are packaged with each build, but their lib and header files are not included.
17+
18+
For example, if one has both Ruby 2.4 and Ruby 2.7 installed, 2.4 will use its bundled OpenSSL 1.0.2 dlls, and 2.7 will use its bundled OpenSSL 1.1.1 dlls. Both can be running at the same time.
19+
20+
* Standard Windows Rubies (`RUBY_PLATFORM.include? 'mingw'` is true) are built with either MSYS or [MSYS2](https://github.com/msys2) build tools and packages, and are often referred to as 'mingw' builds. These are available in both 32 and 64 bit builds, but only 64 bit builds are available on GitHub Actions.
21+
22+
* Ruby mswin builds (`RUBY_PLATFORM.include? 'mswin'` is true) are built with the Microsoft Visual C tools. The [ruby/ruby](https://github.com/ruby/ruby) repo runs CI on mswin builds, and several of the stdlib repos do the same.
23+
24+
* Ruby MinGW builds and mswin builds use different versions of Microsoft Visual C. MinGW builds have a dependency on `msvcrt.dll`, while mswin builds have a dependency on `vcruntime140.dll`. Because of this, the compiled code is not compatible.
25+
26+
* All builds from 2.4 and later use a Windows specific mechanism for finding dll's (known simply as 'manifest'). The dlls are located in `bin/ruby_builtin_dlls`. The manifest places them first in the 'lookup resolution'. Hence, testing against a specific dll version requires adjustments.
27+
28+
## MinGW builds - general info
29+
30+
What is DevKit? You may have seen `-rdevkit` or `require 'devkit'` in scripts for Windows Ruby CI. The term 'devkit' is also used to refer to the collection of build tools used to compile both MinGW Ruby and extension gems. So, one might see the phrase 'have you installed devkit?'. As above, the file that 'activates' the devkit thru ENV settings is named `devkit.rb`.
31+
32+
### Ruby 2.4 & later
33+
34+
Compiled with a set of gcc tools that are part of [MSYS2]. [MSYS2] is independent of Ruby and includes four general categories: a set of bash tools (tar, sed, grep, etc), a set of compiler tools (gcc, llvm, cmake, etc), a set of library packages (libffi, openssl, zlib, etc), and applications/languages (git, perl, python, imagemagick, inkscape, etc).
35+
36+
### Ruby 2.3 & earlier
37+
38+
Compiled with a set of gcc tools known as MSYS. MSYS is no longer supported and a limited number of packages are available. The MSYS build tools 'devkit' was packaged by the group that built the Rubies.
39+
40+
### Build Tool Activation
41+
42+
[ruby/setup-ruby] adds all `ENV` information required to use the correct set of build tools. Most of the below information is general background that pertains to local use.
43+
44+
* MinGW Rubies include a file named `devkit.rb`. Requiring it adds the build tools' locations to Path. For CI, the locations are added by [ruby/setup-ruby](https://github.com/ruby/setup-ruby).
45+
46+
* MinGW Rubies also include a file `rubygems/defaults/operating_system.rb`, which essentially performs the same function as `devkit.rb`. When a gem needs to be compiled, it adds the builds tools to `ENV`. It also adds the locations of the devkit package dlls to the dll library 'lookup resolution' chain. This is done with a Windows specific system call.
47+
48+
* The MSYS build tools used in older MinGW Rubies was a proprietary package. The code to generate `devkit.rb` was contained in it, and the location of the tools was hard coded by the install.
49+
50+
* In newer MinGW Rubies, `devkit.rb` and `operating_system.rb` are included in the Ruby build and use vendored code to determine the [MSYS2] location. One can install [MSYS2] independent of Ruby and `devkit.rb` and `operating_system.rb` will still find it.
51+
52+
53+
## MinGW builds - gcc compatibility
54+
55+
Many Windows CI providers only have the most recent Ruby patch/teeny versions installed. With GitHub Actions and [ruby/setup-ruby](https://github.com/ruby/setup-ruby), all Windows versions from Ruby 2.4 and later are available. There may be compatibility issues when using a current MSYS2 gcc with older Ruby patch versions.
56+
57+
| gcc \\ ruby | 2.4 | 2.5 | 2.6 | 2.7 |
58+
| :---: | :--- | :--- | :--- | :--- |
59+
| **6.3.0-3** | 2.4.1 | | | |
60+
| **7.2.0-2** | | 2.5.0 | | |
61+
| **8.2.1-1** | | | 2.6.0 | |
62+
| **8.3.0-2** | 2.4.6 | 2.5.5 | 2.6.3 | |
63+
| **9.2.0-1** | 2.4.7 | 2.5.6 | 2.6.4 | |
64+
| **9.2.0-2** | 2.4.9 | 2.5.7 | 2.6.5 | 2.7.0 |
65+
66+
67+
## Windows OpenSSL
68+
69+
The following lists the OpenSSL versions used for the most recent release:
70+
71+
| Ruby | OpenSSL | Compiler |
72+
| :---: | :---: | :---: |
73+
| **2.2** | 1.0.2j | MSYS gcc |
74+
| **2.3** | 1.0.2j | MSYS gcc |
75+
| **2.4** | 1.0.2t | MSYS2 gcc |
76+
| **2.5** | 1.1.1* | MSYS2 gcc |
77+
| **2.6** | 1.1.1* | MSYS2 gcc |
78+
| **2.7** | 1.1.1* | MSYS2 gcc |
79+
| **mingw** | 1.1.1* | MSYS2 gcc |
80+
| **mswin** | 1.1.1* | msvc |
81+
82+
On the mswin platform, `openssl` can used in either the `mingw:` input or the `choco:` input, both will install an msvc OpenSSL build.
83+
84+
When `openssl` is included, the correct OpenSSL version (based on the Ruby version and platform) will be installed. For the mswin platform, the environment variable `SSL_DIR` is set to the following, which is the location of the msvc OpenSSL package:
85+
```
86+
--with-openssl-dir=C:\openssl-win
87+
```

dist/index.js

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ const baseUri = 'https://dl.bintray.com/oneclick/OpenKnapsack/x64'
120120
const baseSuf64 = 'x64-windows.tar.lzma'
121121

122122
const old_pkgs = {
123-
'libffi' : `${baseUri}/libffi-3.2.1-${baseSuf64}`,
124-
'openssl': `${baseUri}/openssl-1.0.2j-${baseSuf64}`,
125-
'ragel' : `${baseUri}/ragel-6.7-${baseSuf64}`,
126-
'sqlite' : `${baseUri}/sqlite-3.7.15.2-${baseSuf64}`,
127-
'zlib' : `${baseUri}/zlib-1.2.8-${baseSuf64}`
123+
'libffi' : `${baseUri}/libffi-3.2.1-${baseSuf64}`,
124+
'openssl' : `${baseUri}/openssl-1.0.2j-${baseSuf64}`,
125+
'ragel' : `${baseUri}/ragel-6.7-${baseSuf64}`,
126+
'sqlite3' : `${baseUri}/sqlite-3.7.15.2-${baseSuf64}`,
127+
'zlib' : `${baseUri}/zlib-1.2.8-${baseSuf64}`
128128
}
129129

130130

@@ -460,9 +460,10 @@ const core = __webpack_require__(276)
460460

461461
const { download, execSync, getInput } = __webpack_require__(498)
462462

463-
/* setting to string uses release MSYS2, setting to null uses pre-installed MSYS2
464-
* release contains all Ruby building dependencies,
465-
* used when MSYS2 has server issues
463+
/* setting to string uses specified release asset for MSYS2,
464+
* setting to null uses pre-installed MSYS2
465+
* release contains all Ruby building dependencies,
466+
* used when MSYS2 install or server have problems
466467
*/
467468
const RELEASE_ASSET = fs.lstatSync('C:\\msys64').isSymbolicLink() ?
468469
'msys2-2020-03-20' : null
@@ -471,6 +472,7 @@ const RELEASE_ASSET = fs.lstatSync('C:\\msys64').isSymbolicLink() ?
471472
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
472473

473474
const tar = 'C:\\msys64\\usr\\bin\\tar.exe'
475+
const msys2UsrBin = 'C:\\msys64\\usr\\bin'
474476

475477
// below are for setup of old Ruby DevKit
476478
const dirDK = `${drive}:\\DevKit64`
@@ -566,37 +568,6 @@ const installMSYS2 = async () => {
566568
core.info('Installed MSYS2 for Ruby 2.4 and later')
567569
}
568570

569-
// Ruby 2.2 and 2.3 - install old DevKit
570-
const installDevKit = async () => {
571-
const uri = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
572-
const fn = `${dlPath}\\DevKit64.7z`
573-
const cmd = `7z x ${fn} -o${dirDK}`
574-
575-
await download(uri, fn)
576-
execSync(cmd)
577-
578-
core.exportVariable('RI_DEVKIT', dirDK)
579-
core.exportVariable('CC' , 'gcc')
580-
core.exportVariable('CXX', 'g++')
581-
core.exportVariable('CPP', 'cpp')
582-
core.info('Installed RubyInstaller DevKit for Ruby 2.2 or 2.3')
583-
}
584-
585-
/* Ruby 2.2 and 2.3 - sets Path for old DevKit
586-
* We need MSYS2 in path to install DK packages (for tar lzma), so remove after
587-
* all packages are installed
588-
*/
589-
const setPathDevKit = () => {
590-
let aryPath = process.env.PATH.split(path.delimiter)
591-
const rubyPath = aryPath.shift()
592-
// remove two msys2 paths, add devkit paths
593-
aryPath.splice(0, 2,
594-
rubyPath, `${dirDK}\\mingw\\x86_64-w64-mingw32\\bin`,
595-
`${dirDK}\\mingw\\bin`, `${dirDK}\\bin`
596-
)
597-
core.exportVariable('Path', aryPath.join(path.delimiter))
598-
}
599-
600571
// install MinGW packages from mingw input
601572
const runMingw = async () => {
602573
if (mingw.includes('_upgrade_')) {
@@ -623,6 +594,7 @@ const runMingw = async () => {
623594
execSync(`pacman.exe -S ${args} ${pkgs.join(pre)}`)
624595
}
625596
} else {
597+
// install old DevKit package
626598
let toInstall = []
627599
let pkgs = mingw.split(/\s+/)
628600
pkgs.forEach( (pkg) => {
@@ -633,13 +605,17 @@ const runMingw = async () => {
633605
}
634606
})
635607
if (toInstall.length !== 0) {
608+
// add to Path to make sure MSYS2 tar is in Path for extraction
609+
const curPath = process.env.Path
610+
process.env.Path = `${msys2UsrBin}${path.delimiter}${curPath}`
636611
for (const item of toInstall) {
637612
let fn = `${dlPath}\\${item.pkg}.tar.lzma`
638613
await download(item.uri, fn)
639614
fn = fn.replace(/:/, '').replace(/\\/g, '/')
640615
let cmd = `${tar} --lzma -C ${dirDKTar} -xf /${fn}`
641616
execSync(cmd)
642617
}
618+
process.env.Path = curPath
643619
}
644620
}
645621
}
@@ -663,8 +639,6 @@ const run = async () => {
663639
if (fs.existsSync(bad)) { fs.renameSync(bad, `${bad}_`) }
664640
})
665641

666-
if (ruby.abiVers < '2.4.0') { await installDevKit() }
667-
668642
if (mingw !== '' || msys2 !== '') {
669643
if (ruby.abiVers >= '2.4.0') {
670644
if (RELEASE_ASSET) { await installMSYS2() }
@@ -679,8 +653,6 @@ const run = async () => {
679653
if (msys2 !== '') { await runMSYS2() }
680654
}
681655

682-
if (ruby.abiVers < '2.4.0') { setPathDevKit() }
683-
684656
} catch (error) {
685657
core.setFailed(error.message)
686658
}
@@ -1614,7 +1586,7 @@ module.exports = require("fs");
16141586

16151587
if (core.getInput('ruby-version') !== '') {
16161588
const fn = `${process.env.RUNNER_TEMP}\\setup_ruby.js`
1617-
await common.download('https://raw.githubusercontent.com/MSP-Greg/ruby-setup-ruby/v1exp/dist/index.js', fn)
1589+
await common.download('https://raw.githubusercontent.com/ruby/setup-ruby/v1/dist/index.js', fn)
16181590
await require(fn).run()
16191591
}
16201592

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
if (core.getInput('ruby-version') !== '') {
1414
const fn = `${process.env.RUNNER_TEMP}\\setup_ruby.js`
15-
await common.download('https://raw.githubusercontent.com/MSP-Greg/ruby-setup-ruby/v1exp/dist/index.js', fn)
15+
await common.download('https://raw.githubusercontent.com/ruby/setup-ruby/v1/dist/index.js', fn)
1616
await require(fn).run()
1717
}
1818

0 commit comments

Comments
 (0)