Skip to content

Commit e3a5f03

Browse files
Run Java tests on Helix (#18938)
1 parent 1e44386 commit e3a5f03

File tree

17 files changed

+188
-24
lines changed

17 files changed

+188
-24
lines changed

.azure/pipelines/jobs/default-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ jobs:
233233
condition: always()
234234
inputs:
235235
testRunner: junit
236-
testResultsFiles: '**/TEST-com.microsoft.signalr*.xml'
236+
testResultsFiles: '**/TEST-junit-jupiter.xml'
237237
buildConfiguration: $(BuildConfiguration)
238238
buildPlatform: $(AgentOsName)
239239
mergeTestResults: true

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
###############################################################################
99
*.sh eol=lf
1010

11+
###############################################################################
12+
# Make gradlew always have LF as line endings
13+
###############################################################################
14+
gradlew eol=lf
15+
1116
###############################################################################
1217
# Set default behavior for command prompt diff.
1318
#

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,6 @@
187187
<Import Project="eng\targets\CSharp.Common.props" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
188188
<Import Project="eng\targets\Wix.Common.props" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
189189
<Import Project="eng\targets\Npm.Common.props" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
190+
<Import Project="eng\targets\Helix.props" Condition="'$(IsTestProject)' == 'true'" />
190191

191192
</Project>

Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,6 @@
163163
<Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
164164
<Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
165165
<Import Project="eng\targets\ReferenceAssembly.targets" Condition=" '$(HasReferenceAssembly)' == 'true' " />
166+
<Import Project="eng\targets\Helix.targets" Condition="'$(IsTestProject)' == 'true'" />
166167

167168
</Project>

eng/helix/content/InstallJdk.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#
2+
.SYNOPSIS
3+
Installs JDK into a folder in this repo.
4+
.DESCRIPTION
5+
This script downloads an extracts the JDK.
6+
.PARAMETER JdkVersion
7+
The version of the JDK to install. If not set, the default value is read from global.json
8+
.PARAMETER Force
9+
Overwrite the existing installation
10+
#>
11+
param(
12+
[string]$JdkVersion,
13+
[Parameter(Mandatory = $false)]
14+
$InstallDir
15+
)
16+
$ErrorActionPreference = 'Stop'
17+
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
18+
19+
Set-StrictMode -Version 1
20+
21+
if ($InstallDir) {
22+
$installDir = $InstallDir;
23+
}
24+
else {
25+
$repoRoot = Resolve-Path "$PSScriptRoot\..\.."
26+
$installDir = "$repoRoot\.tools\jdk\win-x64\"
27+
}
28+
$tempDir = "$installDir\obj"
29+
if (-not $JdkVersion) {
30+
$globalJson = Get-Content "$repoRoot\global.json" | ConvertFrom-Json
31+
$JdkVersion = $globalJson.tools.jdk
32+
}
33+
34+
if (Test-Path $installDir) {
35+
if ($Force) {
36+
Remove-Item -Force -Recurse $installDir
37+
}
38+
else {
39+
Write-Host "The JDK already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite."
40+
exit 0
41+
}
42+
}
43+
44+
Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
45+
mkdir $tempDir -ea Ignore | out-null
46+
mkdir $installDir -ea Ignore | out-null
47+
Write-Host "Starting download of JDK ${JdkVersion}"
48+
Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -OutFile "$tempDir/jdk.zip"
49+
Write-Host "Done downloading JDK ${JdkVersion}"
50+
51+
Add-Type -assembly "System.IO.Compression.FileSystem"
52+
[System.IO.Compression.ZipFile]::ExtractToDirectory("$tempDir/jdk.zip", "$tempDir/jdk/")
53+
54+
Write-Host "Expanded JDK to $tempDir"
55+
Write-Host "Installing JDK to $installDir"
56+
Move-Item "$tempDir/jdk/jdk-${JdkVersion}/*" $installDir
57+
Write-Host "Done installing JDK to $installDir"
58+
Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
59+
60+
if ($env:TF_BUILD) {
61+
Write-Host "##vso[task.prependpath]$installDir\bin"
62+
}

eng/helix/content/installjdk.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
# Cause the script to fail if any subcommand fails
4+
set -e
5+
6+
pushd .
7+
8+
if [ "$JAVA_HOME" != "" ]; then
9+
echo "JAVA_HOME is set"
10+
exit
11+
fi
12+
13+
java_version=$1
14+
arch=$2
15+
osname=`uname -s`
16+
if [ "$osname" = "Darwin" ]; then
17+
echo "macOS not supported, relying on the machine providing java itself"
18+
exit 1
19+
else
20+
platformarch="linux-$arch"
21+
fi
22+
echo "PlatformArch: $platformarch"
23+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
24+
output_dir="$DIR/java"
25+
url="https://netcorenativeassets.blob.core.windows.net/resource-packages/external/linux/java/jdk-${java_version}_${platformarch}_bin.tar.gz"
26+
echo "Downloading from: $url"
27+
tmp="$(mktemp -d -t install-jdk.XXXXXX)"
28+
29+
cleanup() {
30+
exitcode=$?
31+
if [ $exitcode -ne 0 ]; then
32+
echo "Failed to install java with exit code: $exitcode"
33+
fi
34+
rm -rf "$tmp"
35+
exit $exitcode
36+
}
37+
38+
trap "cleanup" EXIT
39+
cd "$tmp"
40+
curl -Lsfo $(basename $url) "$url"
41+
echo "Installing java from $(basename $url) $url"
42+
mkdir $output_dir
43+
echo "Unpacking to $output_dir"
44+
tar --strip-components 1 -xzf "jdk-${java_version}_${platformarch}_bin.tar.gz" --no-same-owner --directory "$output_dir"
45+
46+
popd

eng/helix/content/installnode.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ output_dir="$DIR/node"
2222
url="http://nodejs.org/dist/v$node_version/node-v$node_version-$platformarch.tar.gz"
2323
echo "Downloading from: $url"
2424
tmp="$(mktemp -d -t install-node.XXXXXX)"
25-
trap "rm -rf $tmp" EXIT
25+
26+
cleanup() {
27+
exitcode=$?
28+
if [ $exitcode -ne 0 ]; then
29+
echo "Failed to install node with exit code: $exitcode"
30+
fi
31+
rm -rf "$tmp"
32+
exit $exitcode
33+
}
34+
35+
trap "cleanup" EXIT
2636
cd "$tmp"
2737
curl -Lsfo $(basename $url) "$url"
2838
echo "Installing node from $(basename $url) $url"

eng/targets/CSharp.Common.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,5 @@
3535
</ItemDefinitionGroup>
3636

3737
<Import Project="CSharp.ReferenceAssembly.props" Condition="'$(IsReferenceAssemblyProject)' == 'true'" />
38-
<Import Project="Helix.props" Condition="'$(IsTestProject)' == 'true'" />
3938

4039
</Project>

eng/targets/CSharp.Common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030

3131
<Import Project="Packaging.targets" />
3232
<Import Project="ResolveReferences.targets" />
33-
<Import Project="Helix.targets" Condition="'$(IsTestProject)' == 'true'" />
33+
3434
</Project>

eng/targets/Helix.props

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<RunQuarantinedTests>false</RunQuarantinedTests>
1616
<IsWindowsHelixQueue>false</IsWindowsHelixQueue>
1717
<IsWindowsHelixQueue Condition="$(HelixTargetQueue.Contains('Windows')) or $(HelixTargetQueue.Contains('windows'))">true</IsWindowsHelixQueue>
18+
<IsMacHelixQueue>false</IsMacHelixQueue>
19+
<IsMacHelixQueue Condition="$(HelixTargetQueue.Contains('OSX')) or $(HelixTargetQueue.Contains('macOs'))">true</IsMacHelixQueue>
1820
<HelixTestName>$(MSBuildProjectName)--$(TargetFramework)</HelixTestName>
1921
<HelixUseArchive>false</HelixUseArchive>
2022
<LoggingTestingDisableFileLogging Condition="'$(IsHelixJob)' == 'true'">false</LoggingTestingDisableFileLogging>
@@ -33,16 +35,4 @@
3335
<HelixContent Include="$(RepoRoot)eng\helix\content\**\*" />
3436
</ItemGroup>
3537

36-
<ItemGroup Condition="'$(TestDependsOnMssql)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
37-
<HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
38-
</ItemGroup>
39-
40-
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false'">
41-
<HelixPreCommand Include="./installnode.sh $(NodeVersion) $(TargetArchitecture)" />
42-
</ItemGroup>
43-
44-
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
45-
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
46-
</ItemGroup>
47-
4838
</Project>

0 commit comments

Comments
 (0)