Skip to content

Commit

Permalink
Add ruby support to windows CI tests (#415)
Browse files Browse the repository at this point in the history
* add ruby to win tests

* Update version to v0.6.2.

* fix version

* Update version to v0.6.2.

* fix version and remove ts from ci

* add ruby to build step in workflow file

* remove ts from win test build step

---------

Co-authored-by: Praveen Kumar <pkspyder007>
  • Loading branch information
pkspyder007 committed Apr 4, 2023
1 parent e41a8e0 commit b05191c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/windows-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Set up the environment
run: cmd.exe /c "powershell .\tools\metacall-environment.ps1 $Env:METACALL_INSTALL_OPTIONS"
env:
METACALL_INSTALL_OPTIONS: python nodejs typescript java # ruby netcore5 file rpc wasm java c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage
METACALL_INSTALL_OPTIONS: python nodejs java ruby # netcore5 file rpc wasm java c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage

- name: Configure
run: |
Expand All @@ -47,7 +47,7 @@ jobs:
cd "$METACALL_PATH\build"
cmd.exe /c "powershell ..\tools\metacall-configure.ps1 $Env:METACALL_BUILD_OPTIONS"
env:
METACALL_BUILD_OPTIONS: ${{ matrix.buildtype }} scripts ports tests python nodejs typescript java sanitizer # ruby netcore5 file rpc wasm java c cobol rust examples dynamic install pack benchmarks # v8 coverage
METACALL_BUILD_OPTIONS: ${{ matrix.buildtype }} scripts ports tests python nodejs java sanitizer ruby # netcore5 file rpc wasm java c cobol rust examples dynamic install pack benchmarks # v8 coverage

- name: Build
working-directory: ./build
Expand Down
2 changes: 1 addition & 1 deletion tools/metacall-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function sub-build {
# Prerequisites
$files = @(
"$env:ProgramFiles\nodejs\lib\libnode.dll",
".\runtimes\ruby\bin\x64-vcruntime140-ruby310.dll"
"$env:ProgramFiles\ruby\bin\x64-vcruntime140-ruby310.dll"
)

ForEach ($file in $files) {
Expand Down
53 changes: 52 additions & 1 deletion tools/metacall-environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,42 @@ function Set-Java {
Add-to-Path "$RuntimeDir\bin\server"
}

function Set-Ruby {
Write-Output "Setting Ruby..."
$RUBY_VERSION = "3.1.2"

Set-Location $ROOT_DIR
$RuntimeDir = "$env:ProgramFiles\ruby"
$DepsDir = "$ROOT_DIR\dependencies"

if (!(Test-Path -Path "$DepsDir\ruby-mswin.7z")) {
# Download installer
Write-Output "Ruby not found downloading now..."
(New-Object Net.WebClient).DownloadFile("https://github.com/MSP-Greg/ruby-mswin/releases/download/ruby-mswin-builds/Ruby-$RUBY_VERSION-ms.7z", "$DepsDir\ruby-mswin.7z")
}

mkdir "$DepsDir\Ruby31-ms"
7z x "$DepsDir\ruby-mswin.7z" -o"$DepsDir"

robocopy /move /e "$DepsDir\Ruby31-ms\" $RuntimeDir

Add-to-Path "$RuntimeDir\bin"

$Env_Opts = "$ROOT_DIR\build\env_vars.txt"
$RubyDir = $RuntimeDir.Replace('\', '/')

Write-Output "-DRuby_VERSION_STRING=""$RUBY_VERSION""" >> $Env_Opts
Write-Output "-DRuby_INCLUDE_DIR=""$RubyDir/include/ruby-3.1.0""" >> $Env_Opts
Write-Output "-DRuby_EXECUTABLE=""$RubyDir/bin/ruby.exe""" >> $Env_Opts
Write-Output "-DRuby_LIBRARY=""$RubyDir/lib/x64-vcruntime140-ruby310.lib""" >> $Env_Opts
}

function Add-to-Path {
$GivenPath = $args[0]

$NewPath = "$GivenPath;$Env:PATH"
setx /M PATH $NewPath
$Env:PATH = $NewPath

$GivenPath >> $env:GITHUB_PATH

if ( $Null -ne $Env:GITHUB_ENV ) {
Expand All @@ -153,11 +182,32 @@ function Add-to-Path {
Write-Output "PATH:: " $Env:PATH
}


function Set-7z {
Write-Output "Setting 7z..."

$DepsDir = "$ROOT_DIR\dependencies"

if (!(Test-Path -Path "$DepsDir\7zip.exe")) {
# Download installer
Write-Output "7zip not found downloading now..."
(New-Object Net.WebClient).DownloadFile("https://www.7-zip.org/a/7z2201-x64.exe", "$DepsDir\7zip.exe")
}

#source: https://gist.github.com/dansmith65/7dd950f183af5f5deaf9650f2ad3226c
$installerPath = "$DepsDir\7zip.exe"
Start-Process -FilePath $installerPath -Args "/S" -Verb RunAs -Wait
Add-to-Path "$env:ProgramFiles\7-Zip"
}

# Configure
function Configure {
# Create option variables file
mkdir "$ROOT_DIR\build"
New-Item -Path "$ROOT_DIR\build\env_vars.txt"

Set-7z

for ($i = 0; $i -lt $Arguments.Length; $i++) {
$var = $Arguments[$i]
if ( "$var" -eq 'python' ) {
Expand All @@ -166,6 +216,7 @@ function Configure {
}
if ( "$var" -eq 'ruby' ) {
Write-Output "ruby selected"
Set-Ruby
}
if ( "$var" -eq 'netcore' ) {
Write-Output "netcore selected"
Expand Down

0 comments on commit b05191c

Please sign in to comment.