From ee2d4801e387d960ff92e36023667cc25776a1a2 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Sat, 16 Nov 2024 11:58:48 -0500 Subject: [PATCH 1/6] Make it possible to run both tfm 8 and 9 in one run --- .config/dotnet-tools.json | 14 ++++++++++--- .github/workflows/build.yml | 42 +++++++------------------------------ build/Program.fs | 39 +++++++++++++++++++++++----------- 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index eb3eba5..a14a6d5 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -1,5 +1,13 @@ { - "version": 1, - "isRoot": true, - "tools": {} + "version": 1, + "isRoot": true, + "tools": { + "fantomas": { + "version": "6.3.16", + "commands": [ + "fantomas" + ], + "rollForward": false + } + } } \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8fdd77..caaaa58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,33 +10,12 @@ jobs: build: strategy: matrix: + # Builds for Debug and Release configurations + configuration: [Debug, Release] + # Builds for Ubuntu, Windows, and macOS os: [ubuntu-latest, windows-latest, macOS-latest] - dotnet-version: ["", "8.0.x", "9.0.x"] - # these entries will mesh with the above combinations - include: - # just use what's in the repo - - global-json-file: "global.json" - dotnet-version: "" - label: "repo global.json" - build_net9: false - globaljson-command: "dotnet new globaljson --sdk-version 8.0.400" - # latest 8.0 stable - - global-json-file: "global.json" - dotnet-version: "8.0.x" - label: "8.0 stable" - build_net9: false - globaljson-command: "dotnet new globaljson --sdk-version 8.0.0 --roll-forward latestMinor" - # latest 9.0 stable - - global-json-file: "global.json" - dotnet-version: "9.0.x" - label: "9.0 stable" - build_net9: true - globaljson-command: "dotnet new globaljson --sdk-version 9.0.0 --roll-forward latestMinor" - fail-fast: false # we have timing issues on some OS, so we want them all to run + fail-fast: false runs-on: ${{ matrix.os }} - timeout-minutes: 15 - - name: Build on ${{matrix.os}} for ${{ matrix.label }} steps: - uses: actions/checkout@v3 @@ -49,14 +28,9 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - global-json-file: ${{ matrix.global-json-file }} - dotnet-version: ${{ matrix.dotnet-version }} - - # remove global.json, create new one to protect against CI machine installed defaults. Then the env configuration takes precedence - - name: Purge global.json - run: | - rm global.json - ${{ matrix.globaljson-command }} + dotnet-version: | + 8.x + 9.x # let's make sure we're on the version we think we are. - name: Announce .NET version @@ -67,8 +41,6 @@ jobs: - name: Run build and test run: dotnet run --project build - env: - BuildNet9: ${{ matrix.build_net9 }} - name: Archive test results uses: actions/upload-artifact@v3 diff --git a/build/Program.fs b/build/Program.fs index 46803d6..4b54f9f 100644 --- a/build/Program.fs +++ b/build/Program.fs @@ -11,10 +11,11 @@ System.Environment.CurrentDirectory <- (Path.combine __SOURCE_DIRECTORY__ "..") // -------------------------------------------------------------------------------------- let isNullOrWhiteSpace = System.String.IsNullOrWhiteSpace -let exec cmd args dir = +let exec cmd args dir env = let proc = CreateProcess.fromRawCommandLine cmd args |> CreateProcess.ensureExitCodeWithMessage (sprintf "Error while running '%s' with args: %s" cmd args) + |> CreateProcess.withEnvironment (Map.toList env) (if isNullOrWhiteSpace dir then proc @@ -34,13 +35,6 @@ let DoNothing = ignore let init args = initializeContext args - let buildNet9 = - match - System.Environment.GetEnvironmentVariable("BuildNet9") - |> bool.TryParse - with - | true, v -> v - | _ -> false let ignoreTests = match @@ -70,9 +64,30 @@ let init args = Target.create "Build" (fun _ -> DotNet.build buildOpts "") + let tfmToSdkMap = + Map.ofSeq [ + "net8.0", "8.0.100" + "net9.0", "9.0.100" + ] + + let tfmToBuildNet9Map = + Map.ofSeq [ + "net8.0", false + "net9.0", true + ] + let testTFM tfm = - exec "dotnet" $"test --blame --blame-hang-timeout 60s --no-build --framework {tfm} --logger trx --logger GitHubActions -c Release .\\test\\Ionide.ProjInfo.Tests\\Ionide.ProjInfo.Tests.fsproj" "." - |> ignore + try + exec "dotnet" $"new globaljson --force --sdk-version {tfmToSdkMap.[tfm]} --roll-forward LatestMinor" "test" Map.empty + + exec + "dotnet" + $"test --blame --blame-hang-timeout 60s --framework {tfm} --logger trx --logger GitHubActions -c Release .\\Ionide.ProjInfo.Tests\\Ionide.ProjInfo.Tests.fsproj" + "test" + (Map.ofSeq [ "BuildNet9", tfmToBuildNet9Map.[tfm].ToString() ]) + |> ignore + finally + System.IO.File.Delete "test\\global.json" Target.create "Test" DoNothing @@ -80,12 +95,12 @@ let init args = Target.create "Test:net9.0" (fun _ -> testTFM "net9.0") "Build" - =?> ("Test:net8.0", not buildNet9) + ==> ("Test:net8.0") =?> ("Test", not ignoreTests) |> ignore "Build" - =?> ("Test:net9.0", buildNet9) + ==> ("Test:net9.0") =?> ("Test", not ignoreTests) |> ignore From 8e9198e2b7891349a1b9e09a006c06f4309e0e57 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Sat, 16 Nov 2024 12:04:04 -0500 Subject: [PATCH 2/6] use configuration properly --- .github/workflows/build.yml | 9 ++------- build/Program.fs | 8 +++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index caaaa58..295a019 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,8 +10,6 @@ jobs: build: strategy: matrix: - # Builds for Debug and Release configurations - configuration: [Debug, Release] # Builds for Ubuntu, Windows, and macOS os: [ubuntu-latest, windows-latest, macOS-latest] fail-fast: false @@ -20,14 +18,11 @@ jobs: steps: - uses: actions/checkout@v3 - # setup .NET per the repo global.json - - name: Setup .NET - uses: actions/setup-dotnet@v4 - - # setup .NET per test session + # setup .NET SDK - name: Setup .NET uses: actions/setup-dotnet@v4 with: + global-json-file: 'global.json' dotnet-version: | 8.x 9.x diff --git a/build/Program.fs b/build/Program.fs index 4b54f9f..68ee155 100644 --- a/build/Program.fs +++ b/build/Program.fs @@ -32,9 +32,14 @@ let initializeContext args = let getBuildParam = Environment.environVar let DoNothing = ignore + let init args = initializeContext args + let configuration = + match getBuildParam "CONFIGURATION" with + | s when not (isNullOrWhiteSpace s) -> s + | _ -> "Release" let ignoreTests = match @@ -60,6 +65,7 @@ let init args = opts.MSBuildParams with DisableInternalBinLog = true } + Configuration = DotNet.BuildConfiguration.fromString configuration } Target.create "Build" (fun _ -> DotNet.build buildOpts "") @@ -82,7 +88,7 @@ let init args = exec "dotnet" - $"test --blame --blame-hang-timeout 60s --framework {tfm} --logger trx --logger GitHubActions -c Release .\\Ionide.ProjInfo.Tests\\Ionide.ProjInfo.Tests.fsproj" + $"test --blame --blame-hang-timeout 60s --framework {tfm} --logger trx --logger GitHubActions -c {configuration} .\\Ionide.ProjInfo.Tests\\Ionide.ProjInfo.Tests.fsproj" "test" (Map.ofSeq [ "BuildNet9", tfmToBuildNet9Map.[tfm].ToString() ]) |> ignore From 62027069fd797e12da70cc32f8ac6a58e07930af Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Tue, 19 Nov 2024 08:47:16 -0500 Subject: [PATCH 3/6] fixup vscode configs --- .vscode/launch.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 099a561..fc6f692 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,10 +2,10 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch Tool 6.0 graph resolver", + "name": "Launch Tool 8.0 graph resolver", "type": "coreclr", "request": "launch", - "program": "${workspaceFolder}/src/Ionide.ProjInfo.Tool/bin/Debug/net6.0/Ionide.ProjInfo.Tool.dll", + "program": "${workspaceFolder}/src/Ionide.ProjInfo.Tool/bin/Debug/net8.0/Ionide.ProjInfo.Tool.dll", "args": [ "--project", "", @@ -17,10 +17,10 @@ "justMyCode": true, }, { - "name": "Launch Tool 6.0 normal resolver", + "name": "Launch Tool 8.0 normal resolver", "type": "coreclr", "request": "launch", - "program": "${workspaceFolder}/src/Ionide.ProjInfo.Tool/bin/Debug/net6.0/Ionide.ProjInfo.Tool.dll", + "program": "${workspaceFolder}/src/Ionide.ProjInfo.Tool/bin/Debug/net8.0/Ionide.ProjInfo.Tool.dll", "args": [ "--project", "", @@ -54,8 +54,8 @@ "id": "tfm", "description": "The TFM of the test to run", "options": [ - "net6.0", - "net7.0" + "net8.0", + "net9.0" ], "default": "net7.0", "type": "pickString" From b1eb73e0eae62a9a7551a4ae3211a81978de6b92 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Tue, 19 Nov 2024 08:57:21 -0500 Subject: [PATCH 4/6] cleanup contributing --- CONTRIBUTING.md | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fb6270..8c3b4e6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,12 +14,24 @@ Our current algorithm is So if you set global.json to a 9.0.xxx SDK, you'll _always_ use the 9.x MSBuild libraries, which will require the 9.0 runtime to load. If you want to test while loading older MSBuilds, you'll need to somehow constraint the tests to 8.0.xxx SDKs, and the easiest way to do this is to make a global.json with a 8.0.xxx version and a `rollForward: latestPatch` constraint on it. -### Against LTS (net8.0) -1. Run tests with `dotnet run --project .\build\ -- -t Test` - 1. This should chose the `Test:net8.0` target and run against that runtime +### Running tests from FAKE +Our FAKE build project will handle creating/deleting a temporary `global.json` file in the `test` directory for you. -### Against STS (net9.0) +1. `dotnet run --project .\build\ -- -t Test` + 1. This should chose the `Test:net8.0` and `Test:net9.0` targets and run against that respective runtime. + +### Manually invoking dotnet test + +If you want to run `dotnet test` directly, you'll need to set the `global.json` file and environment variables yourself. + +#### Against LTS (net8.0) +1. Move to the test project + 1. `cd test/Ionide.ProjInfo.Tests` +2. Run tests with `dotnet test` + + +#### Against STS (net9.0) 1. Change global.json to use net9.0 ```json "sdk": { @@ -28,11 +40,16 @@ So if you set global.json to a 9.0.xxx SDK, you'll _always_ use the 9.x MSBuild "allowPrerelease": true } ``` -2. Set environment variable `BuildNet9` to `true` +1. Move to the test project + 1. `cd test/Ionide.ProjInfo.Tests` +3. Set environment variable `BuildNet9` to `true` 1. Bash: `export BuildNet9=true` 2. PowerShell: `$env:BuildNet9 = "true"` -3. Run tests with `dotnet run --project .\build\ -- -t Test` - 1. This should chose the `Test:net9.0` target and run against that runtime +4. Run tests with `dotnet test` + + + + ## Release From fa3a001ac6ca696f4c8b4b06b8a17a585c9408b7 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Tue, 19 Nov 2024 08:57:29 -0500 Subject: [PATCH 5/6] Add to fantomasignore --- .fantomasignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.fantomasignore b/.fantomasignore index e001d74..7736941 100644 --- a/.fantomasignore +++ b/.fantomasignore @@ -1,2 +1,3 @@ test/examples obj/**/*.fs +test/testrun_ws/ From 68e27fa1d018a3c2704c9e91d9b5a3fa3f242489 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Tue, 19 Nov 2024 09:33:32 -0600 Subject: [PATCH 6/6] allow dotnet --info to fail without crashing the whole build --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 295a019..5f7da2c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,7 @@ jobs: # let's make sure we're on the version we think we are. - name: Announce .NET version + continue-on-error: true run: dotnet --info - name: Restore tools