From aea16b71ec94c2b17e4444da96e36f5a16b9bd87 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 12 Dec 2024 18:07:23 +0800 Subject: [PATCH] Simplify CI config (#4117) Some cleanup in preparation for https://github.com/com-lihaoyi/mill/pull/4118 Set default `--jobs=0.5C` in `.mill-opts` so we don't need to specify it explicitly in CI, and it also works on laptops and other environments with different core counts correctly. TBH could probably go with even less parallelism due to how heavy our integration tests are - with all the compilation and JVM subprocess spawning they can probably easily take up all 4 cores on a Github Actions worker - but I'm leaving it at 0.5C X 4 cores = 2x parallelism in CI for now Also simplified the windows CI setup: now that we have `./mill.bat` in the project root, we can just call `./mill` in the windows terminal. I had to delete the `.ps1` version because it was taking priority over `.bat` and failing with the following error: ``` Run ./mill -i -k __.compile mill.ps1: D:\a\_temp\93d23[8](https://github.com/com-lihaoyi/mill/actions/runs/12292451871/job/34303135448#step:11:8)[8](https://github.com/com-lihaoyi/mill/actions/runs/12292451871/job/34303135448#step:11:9)4-066d-433e-bb26-8539b01a4aee.ps1:2 Line | 2 | ./mill -i -k __.compile | ~~ | Parameter cannot be processed because the parameter name 'i' is ambiguous. Possible matches include: | -InformationAction -InformationVariable. Error: Process completed with exit code 1. ``` --- .github/workflows/run-mill-action.yml | 9 +- .mill-opts | 1 + docs/modules/ROOT/pages/cli/flags.adoc | 4 +- mill.ps1 | 137 ------------------------- 4 files changed, 5 insertions(+), 146 deletions(-) create mode 100644 .mill-opts delete mode 100644 mill.ps1 diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index f77fd86ad93..7bd5109903e 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -80,13 +80,8 @@ jobs: if: inputs.buildcmd != '' - name: Run Mill '${{ inputs.millargs }}' - # Mill tests are pretty heavy so run them only 3x parallel on 4 core Github Actions runners - run: ./mill -i -j3 -k ${{ inputs.millargs }} - if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - - - name: Run Mill (on Windows) '${{ inputs.millargs }}' - run: cmd /C %GITHUB_WORKSPACE%\mill.bat -i -j3 -k ${{ inputs.millargs }} - if: inputs.millargs != '' && startsWith(inputs.os, 'windows') + run: ./mill -i -k ${{ inputs.millargs }} + if: inputs.millargs != '' - name: Run Mill (on Windows) Worker Cleanup run: 'taskkill -f -im java* && rm -rf out/mill-server/*' diff --git a/.mill-opts b/.mill-opts new file mode 100644 index 00000000000..be51e1c2201 --- /dev/null +++ b/.mill-opts @@ -0,0 +1 @@ +--jobs=0.5C \ No newline at end of file diff --git a/docs/modules/ROOT/pages/cli/flags.adoc b/docs/modules/ROOT/pages/cli/flags.adoc index fc4a83bbf35..844dc476553 100644 --- a/docs/modules/ROOT/pages/cli/flags.adoc +++ b/docs/modules/ROOT/pages/cli/flags.adoc @@ -11,7 +11,7 @@ flags or options: 3. The Mill build tool process, e.g. `./mill --jobs 10`. These can be passed directly after the `./mill` executable name, or set in a `.mill-opts` file as shown below in - xref:#_custom_mill_options[Custom mill options] + xref:#_repo_level_mill_options[Repo-Level Mill Options] 4. The JVM running the Mill build tool process, which may take flags. e.g. `java -Xss10m -Xmx10G`. These are passed via `JAVA_OPTs` or via a `.mill-jvm-opts` flag @@ -158,7 +158,7 @@ available as well as the task and module structure of your project, as tasks tha depend on one another other cannot be processed in parallel -== Custom Mill Options +== Repo-Level Mill Options Mill supports the `.mill-opts` file for passing a default set of command line options to Mill itself. For example, if your project's tasks are CPU heavy, you diff --git a/mill.ps1 b/mill.ps1 deleted file mode 100644 index 605d15ef197..00000000000 --- a/mill.ps1 +++ /dev/null @@ -1,137 +0,0 @@ -# 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 \ No newline at end of file