Skip to content

Commit

Permalink
Make it possible to run both tfm 8 and 9 in one run
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Nov 16, 2024
1 parent 7f9b53d commit 460b8dd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 50 deletions.
14 changes: 11 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {}
"version": 1,
"isRoot": true,
"tools": {
"fantomas": {
"version": "6.3.16",
"commands": [
"fantomas"
],
"rollForward": false
}
}
}
42 changes: 7 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
39 changes: 27 additions & 12 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -70,22 +64,43 @@ 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

Target.create "Test:net8.0" (fun _ -> testTFM "net8.0")
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

Expand Down

0 comments on commit 460b8dd

Please sign in to comment.