diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index eb3eba54..a14a6d5d 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/.fantomasignore b/.fantomasignore index e001d747..7736941d 100644 --- a/.fantomasignore +++ b/.fantomasignore @@ -1,2 +1,3 @@ test/examples obj/**/*.fs +test/testrun_ws/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8fdd773..5f7da2c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,56 +10,26 @@ jobs: build: strategy: matrix: + # 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 - # 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: ${{ 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 }} + global-json-file: 'global.json' + dotnet-version: | + 8.x + 9.x # 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 @@ -67,8 +37,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/.vscode/launch.json b/.vscode/launch.json index 099a5617..fc6f6925 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" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fb6270f..8c3b4e6d 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 diff --git a/build/Program.fs b/build/Program.fs index 46803d61..68ee1553 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 @@ -31,16 +32,14 @@ let initializeContext args = let getBuildParam = Environment.environVar let DoNothing = ignore + let init args = initializeContext args - let buildNet9 = - match - System.Environment.GetEnvironmentVariable("BuildNet9") - |> bool.TryParse - with - | true, v -> v - | _ -> false + let configuration = + match getBuildParam "CONFIGURATION" with + | s when not (isNullOrWhiteSpace s) -> s + | _ -> "Release" let ignoreTests = match @@ -66,13 +65,35 @@ let init args = opts.MSBuildParams with DisableInternalBinLog = true } + Configuration = DotNet.BuildConfiguration.fromString configuration } 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 {configuration} .\\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 +101,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