Skip to content

Commit 5f63d04

Browse files
committed
feat(ci): run all tests on new CI
1 parent a3f2430 commit 5f63d04

File tree

4 files changed

+63
-74
lines changed

4 files changed

+63
-74
lines changed

build/build.fs

Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ let distDir = rootDirectory </> "dist"
5252

5353
let distGlob = distDir </> "*.nupkg"
5454

55-
let coverageThresholdPercent = 0
56-
57-
let coverageReportDir = rootDirectory </> "docs" </> "coverage"
58-
59-
6055
let docsDir = rootDirectory </> "docs"
6156

6257
let docsSrcDir = rootDirectory </> "docsSrc"
@@ -93,8 +88,6 @@ let mutable changelogBackupFilename = ""
9388

9489
let publishUrl = "https://www.nuget.org"
9590

96-
let enableCodeCoverage = environVarAsBoolOrDefault "ENABLE_COVERAGE" false
97-
9891
let githubToken = Environment.environVarOrNone "GITHUB_TOKEN"
9992

10093
let nugetToken = Environment.environVarOrNone "NUGET_KEY"
@@ -103,7 +96,6 @@ let nugetToken = Environment.environVarOrNone "NUGET_KEY"
10396
// Helpers
10497
//-----------------------------------------------------------------------------
10598

106-
10799
let isRelease (targets : Target list) =
108100
targets
109101
|> Seq.map (fun t -> t.Name)
@@ -156,8 +148,6 @@ module dotnet =
156148
DotNet.exec optionConfig command args
157149
|> failOnBadExitAndPrint
158150

159-
let reportgenerator optionConfig args = tool optionConfig "reportgenerator" args
160-
161151
let sourcelink optionConfig args = tool optionConfig "sourcelink" args
162152

163153
let fcswatch optionConfig args = tool optionConfig "fcswatch" args
@@ -244,7 +234,7 @@ let allPublishChecks () = failOnLocalBuild ()
244234
let disableBinLog (p : MSBuild.CliArguments) = { p with DisableInternalBinLog = true }
245235

246236
let clean _ =
247-
[ "bin"; "temp"; distDir; coverageReportDir ]
237+
[ "bin"; "temp"; distDir ]
248238
|> Shell.cleanDirs
249239

250240
!!srcGlob ++ testsGlob
@@ -357,71 +347,78 @@ let fsharpAnalyzers _ =
357347
)
358348

359349
let dotnetTest ctx =
360-
let excludeCoverage =
361-
!!testsGlob
362-
|> Seq.map IO.Path.GetFileNameWithoutExtension
363-
|> String.concat "|"
350+
let args = [ "--no-build" ]
364351

365-
let isGenerateCoverageReport = ctx.Context.TryFindTarget("GenerateCoverageReport").IsSome
352+
// Filter performance tests like in build.fsx
353+
let filterPerformanceTests (p : DotNet.TestOptions) = {
354+
p with
355+
Filter = Some "\"TestCategory!=Performance\""
356+
Configuration = configuration (ctx.Context.AllExecutingTargets)
357+
}
366358

367-
DotNet.test
368-
(fun testOpts ->
369-
if enableCodeCoverage || isGenerateCoverageReport then
370-
let prepareOptions =
371-
{ Primitive.PrepareOptions.Create() with
359+
let testWithCoverageOptions testOpts =
360+
if enableCodeCoverage || isGenerateCoverageReport then
361+
let prepareOptions =
362+
{
363+
Primitive.PrepareOptions.Create () with
372364
AssemblyExcludeFilter = [| excludeCoverage |]
373365
LocalSource = true
374-
}
375-
|> AltCover.PrepareOptions.Primitive
366+
}
367+
|> AltCover.PrepareOptions.Primitive
376368

377-
let collectOptions =
378-
if not isGenerateCoverageReport then
379-
{ Primitive.CollectOptions.Create() with
369+
let collectOptions =
370+
if not isGenerateCoverageReport then
371+
{
372+
Primitive.CollectOptions.Create () with
380373
Threshold = string coverageThresholdPercent
381-
}
382-
else
383-
Primitive.CollectOptions.Create()
384-
|> AltCover.CollectOptions.Primitive
385-
386-
testOpts.WithAltCoverOptions prepareOptions collectOptions (DotNet.CLIOptions.Force(false))
387-
else
388-
testOpts
389-
|> fun opts -> {
390-
opts with
391-
MSBuildParams = disableBinLog opts.MSBuildParams
392-
Configuration = configuration (ctx.Context.AllExecutingTargets)
393-
Common = opts.Common |> DotNet.Options.withAdditionalArgs ["--no-build"]
394-
})
395-
sln
396-
397-
let generateCoverageReport _ =
398-
let coverageReports = !! "tests/**/coverage*.xml" |> String.concat ";"
399-
400-
let sourceDirs = !!srcGlob |> Seq.map Path.getDirectory |> String.concat ";"
401-
402-
let independentArgs = [
403-
$"-reports:\"%s{coverageReports}\""
404-
$"-targetdir:\"%s{coverageReportDir}\""
405-
// Add source dir
406-
$"-sourcedirs:\"%s{sourceDirs}\""
407-
// Ignore Tests and if AltCover.Recorder.g sneaks in
408-
sprintf "-assemblyfilters:\"%s\"" "-*.Tests;-AltCover.Recorder.g"
409-
sprintf "-Reporttypes:%s" "Html"
410-
]
411-
412-
let args = independentArgs |> String.concat " "
374+
}
375+
else
376+
Primitive.CollectOptions.Create ()
377+
|> AltCover.CollectOptions.Primitive
413378

414-
dotnet.reportgenerator id args
379+
testOpts.WithAltCoverOptions prepareOptions collectOptions (DotNet.CLIOptions.Force (false))
380+
else
381+
testOpts
415382

416-
let showCoverageReport _ =
417-
failOnCIBuild ()
383+
// Run the same test projects as in build.fsx
384+
DotNet.test
385+
(filterPerformanceTests
386+
>> testWithCoverageOptions
387+
>> fun opts -> {
388+
opts with
389+
MSBuildParams = disableBinLog opts.MSBuildParams
390+
Common =
391+
opts.Common
392+
|> DotNet.Options.withAdditionalArgs [ "--no-build" ]
393+
})
394+
"tests/FSharpLint.Core.Tests"
418395

419-
coverageReportDir </> "index.html"
420-
|> Command.ShellCommand
421-
|> CreateProcess.fromCommand
422-
|> Proc.start
423-
|> ignore
396+
DotNet.test
397+
(filterPerformanceTests
398+
>> testWithCoverageOptions
399+
>> fun opts -> {
400+
opts with
401+
MSBuildParams = disableBinLog opts.MSBuildParams
402+
Common =
403+
opts.Common
404+
|> DotNet.Options.withAdditionalArgs [ "--no-build" ]
405+
})
406+
"tests/FSharpLint.Console.Tests"
407+
408+
// Restore the functional test project like in build.fsx
409+
DotNet.restore id "tests/FSharpLint.FunctionalTest.TestedProject/FSharpLint.FunctionalTest.TestedProject.sln"
424410

411+
DotNet.test
412+
(filterPerformanceTests
413+
>> testWithCoverageOptions
414+
>> fun opts -> {
415+
opts with
416+
MSBuildParams = disableBinLog opts.MSBuildParams
417+
Common =
418+
opts.Common
419+
|> DotNet.Options.withAdditionalArgs [ "--no-build" ]
420+
})
421+
"tests/FSharpLint.FunctionalTest"
425422

426423
let watchTests _ =
427424
!!testsGlob
@@ -646,8 +643,6 @@ let initTargets (ctx : Context.FakeExecutionContext) =
646643
Target.create "DotnetBuild" dotnetBuild
647644
Target.create "FSharpAnalyzers" fsharpAnalyzers
648645
Target.create "DotnetTest" dotnetTest
649-
Target.create "GenerateCoverageReport" generateCoverageReport
650-
Target.create "ShowCoverageReport" showCoverageReport
651646
Target.create "WatchTests" watchTests
652647
Target.create "GenerateAssemblyInfo" generateAssemblyInfo
653648
Target.create "DotnetPack" dotnetPack
@@ -695,9 +690,6 @@ let initTargets (ctx : Context.FakeExecutionContext) =
695690

696691
"DotnetBuild" ==>! "WatchDocs"
697692

698-
"DotnetTest" ==> "GenerateCoverageReport"
699-
==>! "ShowCoverageReport"
700-
701693
"UpdateChangelog"
702694
==> "GenerateAssemblyInfo"
703695
==> "GitRelease"

tests/FSharpLint.Console.Tests/FSharpLint.Console.Tests.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="altcover" />
1514
<PackageReference Include="FSharp.Core" />
1615
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1716
<PackageReference Include="NUnit" />

tests/FSharpLint.Core.Tests/FSharpLint.Core.Tests.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
</ItemGroup>
9797

9898
<ItemGroup>
99-
<PackageReference Include="altcover" />
10099
<PackageReference Include="FSharp.Core" />
101100
<PackageReference Include="Microsoft.NET.Test.Sdk" />
102101
<PackageReference Include="NUnit" />

tests/FSharpLint.FunctionalTest/FSharpLint.FunctionalTest.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="altcover" />
1615
<PackageReference Include="FSharp.Core" />
1716
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1817
<PackageReference Include="NUnit" />

0 commit comments

Comments
 (0)