Skip to content

Commit

Permalink
Typescript windows CI tests (#432)
Browse files Browse the repository at this point in the history
* init ts win ci

* fix ts loader bootstrap path normalization issue

* Update metacall-environment.ps1

---------

Co-authored-by: Praveen Kumar <pkspyder007>
Co-authored-by: Vicente Eduardo Ferrer Garcia <7854099+viferga@users.noreply.github.com>
  • Loading branch information
pkspyder007 and viferga authored May 17, 2023
1 parent 78a0466 commit efe08a3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 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 java ruby # netcore5 file rpc wasm java c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage
METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript # 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 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 typescript # 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 source/loaders/ts_loader/bootstrap/lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const getMetacallExportTypes = (
const exportTypes: MetacallExports = {};
const files = paths.length === 0 ?
p.getRootFileNames() :
paths.map(fileResolveNoThrow).filter(file => p.getRootFileNames().includes(file));
paths.map(fileResolveNoThrow).filter(file => p.getRootFileNames().map(path.normalize).includes(path.normalize(file)));
const sourceFiles = files.map((name) =>
[name, p.getSourceFile(name)] as const
);
Expand Down
71 changes: 41 additions & 30 deletions tools/metacall-environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $Global:PROGNAME = $(Get-Item $PSCommandPath).Basename
$Global:Arguments = $args

function Set-Python {
Write-Output "configure python"
Write-Output "Install Python"
Set-Location $ROOT_DIR

$PythonVersion = '3.9.7'
Expand Down Expand Up @@ -57,7 +57,7 @@ function Set-Python {
}

function Set-Nodejs {
Write-Output "Setting up Node.js"
Write-Output "Install Node.js"
Set-Location $ROOT_DIR

$DepsDir = "$ROOT_DIR\dependencies"
Expand Down Expand Up @@ -109,29 +109,29 @@ function Set-Nodejs {
}

function Set-Java {
Write-Output "Setting up Java..."
$JAVA_VERSION = "17.0.5"
$RuntimeDir = "$env:ProgramFiles\openjdk"
$DepsDir = "$ROOT_DIR\dependencies"
Write-Output "Install Java"
$JAVA_VERSION = "17.0.5"
$RuntimeDir = "$env:ProgramFiles\openjdk"
$DepsDir = "$ROOT_DIR\dependencies"

Set-Location $DepsDir
Set-Location $DepsDir

if (!(Test-Path -Path "$DepsDir\openjdk.zip")) {
# Download installer
Write-Output "OpenJDK not found downloading now..."
(New-Object Net.WebClient).DownloadFile("https://aka.ms/download-jdk/microsoft-jdk-$JAVA_VERSION-windows-x64.zip", "$DepsDir\openjdk.zip")
}
if (!(Test-Path -Path "$DepsDir\openjdk.zip")) {
# Download installer
Write-Output "OpenJDK not found downloading now..."
(New-Object Net.WebClient).DownloadFile("https://aka.ms/download-jdk/microsoft-jdk-$JAVA_VERSION-windows-x64.zip", "$DepsDir\openjdk.zip")
}

Expand-Archive -Path "openjdk.zip" -DestinationPath "$RuntimeDir"
robocopy /move /e "$RuntimeDir\jdk-$JAVA_VERSION+8" "$RuntimeDir" /NFL /NDL /NJH /NJS /NC /NS /NP
Expand-Archive -Path "openjdk.zip" -DestinationPath "$RuntimeDir"
robocopy /move /e "$RuntimeDir\jdk-$JAVA_VERSION+8" "$RuntimeDir" /NFL /NDL /NJH /NJS /NC /NS /NP

Add-to-Path "JAVA_HOME=$RuntimeDir"
Add-to-Path "$RuntimeDir\bin"
Add-to-Path "$RuntimeDir\bin\server"
Add-to-Path "JAVA_HOME=$RuntimeDir"
Add-to-Path "$RuntimeDir\bin"
Add-to-Path "$RuntimeDir\bin\server"
}

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

Set-Location $ROOT_DIR
Expand Down Expand Up @@ -178,21 +178,30 @@ function Add-to-Path {
}


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

function Set-Base {
$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")
# Check if 7zip is installed
$zipInstalled = Get-WmiObject Win32_Product | Where {Name -match '7(-)?zip'}
if (!$zipInstalled) {
Write-Output "Install 7zip"

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

# 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"
}
}

#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"
function Set-TypeScript {
Write-Output "Install TypeScript"
npm i react@latest -g
npm i react-dom@latest -g
}

# Configure
Expand All @@ -201,7 +210,8 @@ function Configure {
mkdir "$ROOT_DIR\build"
New-Item -Path "$ROOT_DIR\build\CMakeConfig.txt"

Set-7z
# Install base requirements
Set-Base

for ($i = 0; $i -lt $Arguments.Length; $i++) {
$var = $Arguments[$i]
Expand Down Expand Up @@ -249,6 +259,7 @@ function Configure {
}
if ( "$var" -eq 'typescript' ) {
Write-Output "typescript selected"
Set-TypeScript
}
if ( "$var" -eq 'file' ) {
Write-Output "file selected"
Expand Down

0 comments on commit efe08a3

Please sign in to comment.