[Helix] Try running node services tests on helix again (#9046)

This commit is contained in:
Hao Kung 2019-05-29 21:15:29 -07:00 committed by GitHub
parent abd70031cb
commit 0b54783877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 115 additions and 10 deletions

View File

@ -0,0 +1,71 @@
<#
.SYNOPSIS
Installs NodeJs from http://nodejs.org/dist on a machine
.DESCRIPTION
This script installs NodeJs from http://nodejs.org/dist on a machine.
.PARAMETER Version
The version of NodeJS to install.
.PARAMETER InstallDir
The directory to install NodeJS to.
.LINK
https://nodejs.org/en/
#>
param(
[Parameter(Mandatory = $true)]
$Version,
[Parameter(Mandatory = $true)]
$InstallDir
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
Set-StrictMode -Version 1
if (Get-Command "node.exe" -ErrorAction SilentlyContinue)
{
Write-Host "Found node.exe in PATH"
exit
}
if (Test-Path "$output_dir\node.exe")
{
Write-Host "Node.exe found at $output_dir"
exit
}
$nodeFile="node-v$Version-win-x64"
$url="http://nodejs.org/dist/v$Version/$nodeFile.zip"
Write-Host "Starting download of NodeJs ${Version} from $url"
Invoke-WebRequest -UseBasicParsing -Uri "$url" -OutFile "nodejs.zip"
Write-Host "Done downloading NodeJS ${Version}"
$tempPath = [System.IO.Path]::GetTempPath()
$tempDir = Join-Path $tempPath nodejs
New-Item -Path "$tempDir" -ItemType "directory" -Force
Write-Host "Extracting to $tempDir"
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
# Use built-in commands where possible as they are cross-plat compatible
Microsoft.PowerShell.Archive\Expand-Archive -Path "nodejs.zip" -DestinationPath $tempDir
}
else {
# Fallback to old approach for old installations of PowerShell
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("nodejs.zip", $tempDir)
}
Write-Host "Expanded NodeJs"
New-Item -Path "$InstallDir" -ItemType "directory" -Force
Write-Host "Copying $tempDir\$nodeFile\node.exe to $InstallDir"
Copy-Item "$tempDir\$nodeFile\node.exe" "$InstallDir\node.exe"
if (Test-Path "$InstallDir\node.exe")
{
Write-Host "Node.exe copied to $InstallDir"
}
else
{
Write-Host "Node.exe not copied to $InstallDir"
}

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Cause the script to fail if any subcommand fails
set -e
if type -P "node" &>/dev/null; then
echo "node is in \$PATH"
exit
fi
node_version=$1
osname=`uname -s`
echo $osname
if [ "$osname" = "Darwin" ]; then
platformarch='darwin-x64'
else
platformarch='linux-x64'
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
output_dir="$DIR/node"
url="http://nodejs.org/dist/v$node_version/node-v$node_version-$platformarch.tar.gz"
tmp="$(mktemp -d -t install-node.XXXXXX)"
trap "rm -rf $tmp" EXIT
cd "$tmp"
curl -Lsfo $(basename $url) "$url"
echo "Installing node from $(basename $url) $url"
mkdir $output_dir
echo "Unpacking to $output_dir"
tar --strip-components 1 -xzf "node-v$node_version-$platformarch.tar.gz" --no-same-owner --directory "$output_dir"

View File

@ -14,7 +14,7 @@ set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_MULTILEVEL_LOOKUP=0
set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home
set PATH=%DOTNET_ROOT%;%PATH%
set PATH=%DOTNET_ROOT%;%PATH%;%HELIX_CORRELATION_PAYLOAD%\node\bin
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture x64 -Version %sdkVersion% -InstallDir %DOTNET_ROOT%"
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture x64 -Runtime dotnet -Version %runtimeVersion% -InstallDir %DOTNET_ROOT%"

View File

@ -16,7 +16,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DOTNET_ROOT="$DIR/.dotnet$RANDOM"
# Ensure dotnet comes first on PATH
export PATH="$DOTNET_ROOT:$PATH"
export PATH="$DOTNET_ROOT:$PATH:$DIR/node/bin"
# Prevent fallback to global .NET locations. This ensures our tests use the shared frameworks we specify and don't rollforward to something else that might be installed on the machine
export DOTNET_MULTILEVEL_LOOKUP=0

View File

@ -17,6 +17,7 @@
<HelixTestName>$(MSBuildProjectName)/$(TargetFramework)</HelixTestName>
<HelixUseArchive>false</HelixUseArchive>
<LoggingTestingDisableFileLogging Condition="'$(IsHelixJob)' == 'true'">true</LoggingTestingDisableFileLogging>
<NodeVersion>10.15.3</NodeVersion>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
@ -35,4 +36,12 @@
<HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
</ItemGroup>
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false'">
<HelixPreCommand Include="./installnode.sh $(NodeVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
</ItemGroup>
</Project>

View File

@ -2,19 +2,14 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<!-- Tests do not work on Helix or when bin/ directory is not in project directory due to undeclared dependency on test content. -->
<!-- https://github.com/aspnet/AspNetCore/issues/8044 -->
<BuildHelixPayload>false</BuildHelixPayload>
<BaseOutputPath />
<OutputPath />
<TestDependsOnNode>true</TestDependsOnNode>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.NodeServices" />
<Reference Include="Microsoft.AspNetCore.TestHost" />
<Reference Include="Microsoft.Extensions.Logging.Testing" />
<Content Include="js\**\*" />
</ItemGroup>
</Project>

View File

@ -4,6 +4,7 @@
using Microsoft.AspNetCore.NodeServices.HostingModels;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using System.Threading.Tasks;
using Xunit;
@ -115,7 +116,7 @@ namespace Microsoft.AspNetCore.NodeServices
}
private static string ModulePath(string testModuleName)
=> $"../../../js/{testModuleName}";
=> Path.Combine(AppContext.BaseDirectory, "js", testModuleName);
public void Dispose()
{