-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More Mill launcher integration work (#4087)
Fixes #2161 - Adds some integration tests for older mill versions - Includes the `mill.ps1` file
- Loading branch information
Showing
5 changed files
with
195 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
43 changes: 43 additions & 0 deletions
43
integration/feature/launcher-old-versions/src/LauncherOldVersionsTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package mill.integration | ||
|
||
import mill.testkit.UtestIntegrationTestSuite | ||
|
||
import utest._ | ||
|
||
class LauncherOldVersionsTests(version: String) extends UtestIntegrationTestSuite { | ||
val tests: Tests = Tests { | ||
test - integrationTest { tester => | ||
val launcherEnv = | ||
if (mill.main.client.Util.isWindows) "MILL_LAUNCHER_BAT" | ||
else "MILL_LAUNCHER" | ||
|
||
val workspacePath = tester.workspacePath | ||
|
||
val launcherScript = sys.env(launcherEnv) | ||
os.write.over(workspacePath / ".mill-version", version) | ||
|
||
// Run Mill once beforehand just to make sure it gets initialized and | ||
// none of the initialization output gets into `outText` | ||
os.call(cmd = (launcherScript, "version"), cwd = workspacePath, stderr = os.Pipe) | ||
|
||
val res = os.call(cmd = (launcherScript, "version"), cwd = workspacePath, stderr = os.Pipe) | ||
val outText = res.out.text().trim | ||
assert(outText == version) | ||
} | ||
} | ||
} | ||
|
||
// Split these into separate test groups so they can run in parallel | ||
// | ||
// Older versions of Mill do not work on latest macbook pros | ||
//object LauncherVersionTests_0_1 extends LauncherOldVersionsTests("0.1.7") | ||
//object LauncherVersionTests_0_2 extends LauncherOldVersionsTests("0.2.7") | ||
//object LauncherVersionTests_0_3 extends LauncherOldVersionsTests("0.3.6") | ||
//object LauncherVersionTests_0_4 extends LauncherOldVersionsTests("0.4.2") | ||
//object LauncherVersionTests_0_5 extends LauncherOldVersionsTests("0.5.9") | ||
//object LauncherVersionTests_0_6 extends LauncherOldVersionsTests("0.6.3") | ||
//object LauncherVersionTests_0_7 extends LauncherOldVersionsTests("0.7.4") | ||
//object LauncherVersionTests_0_8 extends LauncherOldVersionsTests("0.8.0") | ||
object LauncherVersionTests_0_9 extends LauncherOldVersionsTests("0.9.12") | ||
object LauncherVersionTests_0_10 extends LauncherOldVersionsTests("0.10.15") | ||
object LauncherVersionTests_0_11 extends LauncherOldVersionsTests("0.11.13") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# This is a wrapper script, that automatically download mill from GitHub release pages | ||
# You can give the required mill version with --mill-version parameter | ||
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION | ||
# | ||
# Project page: https://github.com/lefou/millw | ||
# Script Version: 0.4.12 | ||
# | ||
# If you want to improve this script, please also contribute your changes back! | ||
# | ||
# Licensed under the Apache License, Version 2.0 | ||
|
||
[CmdletBinding(PositionalBinding = $false)] | ||
|
||
param( | ||
[Parameter(ValueFromRemainingArguments = $true, Position = 0)] | ||
[string[]] $remainingArgs | ||
) | ||
|
||
$DEFAULT_MILL_VERSION = $Env:DEFAULT_MILL_VERSION ?? '0.11.6' | ||
|
||
$GITHUB_RELEASE_CDN = $Env:GITHUB_RELEASE_CDN ?? '' | ||
|
||
$MILL_REPO_URL = 'https://github.com/com-lihaoyi/mill' | ||
|
||
$MILL_VERSION = $null | ||
|
||
if ($null -ne $remainingArgs) { | ||
if ($remainingArgs[0] -eq '--mill-version') { | ||
$remainingArgs = Select-Object -InputObject $remainingArgs -Skip 1 | ||
if ($null -ne $remainingArgs) { | ||
$MILL_VERSION = $remainingArgs[0] | ||
$remainingArgs = Select-Object -InputObject $remainingArgs -Skip 1 | ||
} | ||
else { | ||
Write-Error -Message "Please provide a version that matches one provided on $MILL_REPO_URL/releases" | ||
throw [System.ArgumentNullException] '--mill-version' | ||
} | ||
} | ||
} | ||
|
||
if ($null -eq $MILL_VERSION) { | ||
if (Test-Path -Path '.mill-version' -PathType Leaf) { | ||
$MILL_VERSION = Get-Content -Path '.mill-version' -TotalCount 1 | ||
} | ||
elseif (Test-Path -Path '.config/mill-version' -PathType Leaf) { | ||
$MILL_VERSION = Get-Content -Path '.config/mill-version' -TotalCount 1 | ||
} | ||
} | ||
|
||
$MILL_USER_CACHE_DIR = Join-Path -Path $Env:LOCALAPPDATA -ChildPath 'mill' | ||
|
||
$MILL_DOWNLOAD_PATH = $Env:MILL_DOWNLOAD_PATH ?? @(Join-Path -Path ${MILL_USER_CACHE_DIR} -ChildPath 'download') | ||
|
||
if (-not (Test-Path -Path $MILL_DOWNLOAD_PATH)) { | ||
New-Item -Path $MILL_DOWNLOAD_PATH -ItemType Directory | Out-Null | ||
} | ||
|
||
if ($null -eq $MILL_VERSION) { | ||
Write-Warning -Message 'No mill version specified.' | ||
Write-Warning -Message "You should provide a version via '.mill-version' file or --mill-version option." | ||
|
||
if (-not (Test-Path -Path "$MILL_DOWNLOAD_PATH" -PathType Container)) { | ||
New-Item "$MILL_DOWNLOAD_PATH" -ItemType Directory | Out-Null | ||
} | ||
|
||
$MILL_LATEST_PATH = Join-Path -Path $MILL_DOWNLOAD_PATH -ChildPath '.latest' | ||
|
||
if (Test-Path -Path $MILL_LATEST_PATH -PathType Leaf) { | ||
if ($(Get-Item -Path $MILL_LATEST_PATH).LastWriteTime -lt $(Get-Date).AddHours(-1)) { | ||
$MILL_VERSION = Get-Content -Path $MILL_LATEST_PATH -TotalCount 1 | ||
} | ||
} | ||
|
||
if ($null -eq $MILL_VERSION) { | ||
Write-Output 'Retrieving latest mill version ...' | ||
|
||
# https://github.com/PowerShell/PowerShell/issues/20964 | ||
$targetUrl = try { | ||
Invoke-WebRequest -Uri "$MILL_REPO_URL/releases/latest" -MaximumRedirection 0 | ||
} | ||
catch { | ||
$_.Exception.Response.Headers.Location.AbsoluteUri | ||
} | ||
|
||
$targetUrl -match "^$MILL_REPO_URL/releases/tag/(.+)$" | Out-Null | ||
|
||
$MILL_VERSION = $Matches.1 | ||
|
||
if ($null -ne $MILL_VERSION) { | ||
Set-Content -Path $MILL_LATEST_PATH -Value $MILL_VERSION | ||
} | ||
} | ||
|
||
if ($null -eq $MILL_VERSION) { | ||
$MILL_VERSION = $DEFAULT_MILL_VERSION | ||
Write-Warning "Falling back to hardcoded mill version $MILL_VERSION" | ||
} | ||
else { | ||
Write-Output "Using mill version $MILL_VERSION" | ||
} | ||
} | ||
|
||
$MILL = "$MILL_DOWNLOAD_PATH/$MILL_VERSION.bat" | ||
|
||
if (-not (Test-Path -Path $MILL -PathType Leaf)) { | ||
$DOWNLOAD_SUFFIX, $DOWNLOAD_FROM_MAVEN = switch -Regex ($MILL_VERSION) { | ||
'^0\.[0-4]\..*$' { '', $false } | ||
'0\.(?:[5-9]\.|10\.|11\.0-M).*' { '-assembly', $false } | ||
Default { '-assembly', $true } | ||
} | ||
|
||
if ($DOWNLOAD_FROM_MAVEN) { | ||
$DOWNLOAD_URL = "https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/$MILL_VERSION/mill-dist-$MILL_VERSION.jar" | ||
} | ||
else { | ||
$MILL_VERSION -match '(\d+\.\d+\.\d+(?:-M\d+)?)' | Out-Null | ||
$MILL_VERSION_TAG = $Matches.1 | ||
$DOWNLOAD_URL = "$GITHUB_RELEASE_CDN$MILL_REPO_URL/releases/download/$MILL_VERSION_TAG/$MILL_VERSION$DOWNLOAD_SUFFIX" | ||
} | ||
Write-Output "Downloading mill $MILL_VERSION from $DOWNLOAD_URL ..." | ||
|
||
Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile $MILL | ||
} | ||
|
||
$MILL_MAIN_CLI = $Env:MILL_MAIN_CLI ?? $PSCommandPath | ||
|
||
$MILL_FIRST_ARG = $null | ||
$REMAINING_ARGUMENTS = $remainingArgs | ||
|
||
if ($null -ne $remainingArgs) { | ||
if ($remainingArgs[0] -eq '--bsp' -or $remainingArgs -eq '-i' -or $remainingArgs -eq '--interactive' -or $remainingArgs -eq '--no-server') { | ||
$MILL_FIRST_ARG = $remainingArgs[0] | ||
$REMAINING_ARGUMENTS = Select-Object -InputObject $remainingArgs -Skip 1 | ||
} | ||
} | ||
|
||
& $MILL $MILL_FIRST_ARG -D "mill.main.cli=$MILL_MAIN_CLI" $REMAINING_ARGUMENTS |