@@ -29,12 +29,20 @@ let environVarAsBoolOrDefault varName defaultValue =
2929 with _ ->
3030 defaultValue
3131
32+
33+ let isCI = lazy environVarAsBoolOrDefault " CI" false
34+
3235//-----------------------------------------------------------------------------
3336// Metadata and Configuration
3437//-----------------------------------------------------------------------------
3538
3639let productName = " MyLib.1"
3740
41+
42+ let rootDirectory =
43+ __ SOURCE_ DIRECTORY__
44+ </> " .."
45+
3846let sln =
3947 __ SOURCE_ DIRECTORY__
4048 </> " .."
@@ -175,16 +183,16 @@ let failOnBadExitAndPrint (p: ProcessResult) =
175183 failwithf " failed with exitcode %d " p.ExitCode
176184
177185let rec retryIfInCI times fn =
178- match Environment.environVarOrNone " CI" with
179- | Some _ ->
186+ if isCI.Value then
180187 if times > 1 then
181188 try
182189 fn ()
183190 with _ ->
184191 retryIfInCI ( times - 1 ) fn
185192 else
186193 fn ()
187- | _ -> fn ()
194+ else
195+ fn ()
188196
189197
190198let allReleaseChecks () =
@@ -544,14 +552,15 @@ let githubRelease _ =
544552 |> GitHub.publishDraft
545553 |> Async.RunSynchronously
546554
555+
547556let formatCode _ =
548- let result = dotnet.fantomas " . "
557+ let result = dotnet.fantomas $ " {rootDirectory} "
549558
550559 if not result.OK then
551560 printfn " Errors while formatting all files: %A " result.Messages
552561
553- let checkFormatCode _ =
554- let result = dotnet.fantomas " --check . "
562+ let checkFormatCode ctx =
563+ let result = dotnet.fantomas $ " {rootDirectory} --check"
555564
556565 if result.ExitCode = 0 then
557566 Trace.log " No files need formatting"
@@ -560,6 +569,7 @@ let checkFormatCode _ =
560569 else
561570 Trace.logf " Errors while formatting: %A " result.Errors
562571
572+
563573let initTargets () =
564574 BuildServer.install [ GitHubActions.Installer ]
565575
@@ -635,7 +645,7 @@ let initTargets () =
635645 ==>! " GitRelease"
636646
637647 " DotnetRestore"
638- ==> " CheckFormatCode"
648+ =?> ( " CheckFormatCode" , isCI.Value )
639649 ==> " DotnetBuild"
640650 // ==> "FSharpAnalyzers"
641651 ==> " DotnetTest"
0 commit comments