Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formatting #13

Merged
merged 6 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"fantomas": {
"version": "5.0.0-beta-009",
"commands": [
"fantomas"
]
}
}
}
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

# Source https://github.com/G-Research/fsharp-formatting-conventions/blob/master/.editorconfig
[*.fs]
fsharp_space_before_uppercase_invocation=true
fsharp_space_before_member=true
fsharp_space_before_colon=true
fsharp_space_before_semicolon=true
fsharp_multiline_block_brackets_on_same_column=true
fsharp_newline_between_type_definition_and_members=true
fsharp_align_function_signature_to_indentation=true
fsharp_alternative_long_member_definitions=true
fsharp_multi_line_lambda_closing_newline=true
fsharp_experimental_keep_indent_in_branch=true
fsharp_bar_before_discriminated_union_declaration=true
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Initial format
b1c1ebd2dd454425b7b10e3f46c9441f6dcf36e4
4 changes: 4 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Restore tools
run: dotnet tool restore
- name: Check formatting
run: dotnet fantomas . -r --check
- name: Restore dependencies
run: dotnet restore ./FCSBenchmark.sln
- name: Build
Expand Down
90 changes: 42 additions & 48 deletions FCSCheckouts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ open FCSBenchmark.Generator.RepoSetup
open LibGit2Sharp
open Serilog.Events

type FCSGeneralRepoSpec =
{
GitUrl : string
Revision : string
}

type FCSMainRepoSpec =
{
Revision : string
}
type FCSGeneralRepoSpec = { GitUrl : string ; Revision : string }

type FCSMainRepoSpec = { Revision : string }

type FCSRepoSpec =
| Main of FCSMainRepoSpec
Expand All @@ -25,11 +18,7 @@ type FCSRepoSpec =
module FCSRepoSpec =
let toFullSpec (options : FCSRepoSpec) =
match options with
| FCSRepoSpec.Main {Revision = revision} ->
{
GitUrl = ""
Revision = revision
}
| FCSRepoSpec.Main { Revision = revision } -> { GitUrl = "" ; Revision = revision }
| FCSRepoSpec.Custom spec -> spec
|> function
| spec ->
Expand All @@ -40,74 +29,79 @@ module FCSRepoSpec =
}

let private fcsDllPath (checkoutDir : string) =
Path.Combine(checkoutDir, "artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Compiler.Service.dll")

let checkoutContainsBuiltFcs (checkoutDir : string) =
File.Exists(fcsDllPath checkoutDir)
Path.Combine (
checkoutDir,
"artifacts/bin/FSharp.Compiler.Service/Release/netstandard2.0/FSharp.Compiler.Service.dll"
)

let checkoutContainsBuiltFcs (checkoutDir : string) = File.Exists (fcsDllPath checkoutDir)

let buildAndPackFCS (repoRootDir : string) (forceFCSBuild : bool) : unit =
let packagesDir = Path.Combine(repoRootDir, "artifacts", "packages", "Release", "Release")
let packagesDir =
Path.Combine (repoRootDir, "artifacts", "packages", "Release", "Release")

let packagesExist =
if Directory.Exists(packagesDir) then
match Directory.EnumerateFiles(packagesDir, "FSharp.Compiler.Service.*.nupkg") |> Seq.toList with
if Directory.Exists (packagesDir) then
match
Directory.EnumerateFiles (packagesDir, "FSharp.Compiler.Service.*.nupkg")
|> Seq.toList
with
| [] -> false
| _ -> true
else
log.Information($"PackagesDir {packagesDir} DOES NOT exist")
log.Information ($"PackagesDir {packagesDir} DOES NOT exist")
false

let build () =
log.Information("Building and packing FCS in {repo}.", repoRootDir)
log.Information ("Building and packing FCS in {repo}.", repoRootDir)
Utils.runProcess "cmd" $"/C build.cmd -c Release -pack -noVisualStudio" repoRootDir [] LogEventLevel.Verbose

match packagesExist, forceFCSBuild with
| false, _ ->
log.Information($"packages don't exist - building")
log.Information ($"packages don't exist - building")
build ()
| true, false ->
log.Information("FCS nupkg file exists in {repo} codebase - not building again.", repoRootDir)
| true, false -> log.Information ("FCS nupkg file exists in {repo} codebase - not building again.", repoRootDir)
| true, true ->
log.Information("FCS nupkg file exists in {repo} codebase, but forceFCSBuild was set.", repoRootDir)
log.Information ("FCS nupkg file exists in {repo} codebase, but forceFCSBuild was set.", repoRootDir)
build ()

type FCSCheckout =
{
Spec : FCSRepoSpec
Repo : Repository
}
with
member this.FullSpec = this.Spec |> FCSRepoSpec.toFullSpec
member this.Dir = this.Repo.Info.WorkingDirectory
member this.PackDir = this.Dir // Root dir can be provided to the runner instead of the packages directory

member this.FullSpec = this.Spec |> FCSRepoSpec.toFullSpec
member this.Dir = this.Repo.Info.WorkingDirectory
member this.PackDir = this.Dir // Root dir can be provided to the runner instead of the packages directory

let checkoutAndBuild (config : Config) (fcsSpec : FCSRepoSpec) : FCSCheckout =
let spec = FCSRepoSpec.toFullSpec fcsSpec
let repo = prepareRepo config spec
buildAndPackFCS repo.Info.WorkingDirectory config.ForceFCSBuild
{
Spec = fcsSpec
Repo = repo
}

type NuGetVersion = NuGetVersion of string
{ Spec = fcsSpec ; Repo = repo }

type NuGetVersion = | NuGetVersion of string

[<RequireQualifiedAccess>]
type FCSVersion =
| OfficialNuGet of NuGetVersion
| Local of DirectoryInfo // Root directory or package directory
| Git of FCSRepoSpec

[<RequireQualifiedAccess>]
type NuGetFCSVersion =
| Official of version : string
| Local of sourceDir : string

let prepareFCSVersions (config : Config) (versions : FCSVersion list) : NuGetFCSVersion list =
versions
|> List.map (
function
| FCSVersion.OfficialNuGet (NuGetVersion version) -> NuGetFCSVersion.Official version
| FCSVersion.Local root -> NuGetFCSVersion.Local root.FullName
| FCSVersion.Git spec ->
let checkout = checkoutAndBuild config spec
NuGetFCSVersion.Local checkout.Dir
)
| FCSVersion.OfficialNuGet (NuGetVersion version) -> NuGetFCSVersion.Official version
| FCSVersion.Local root -> NuGetFCSVersion.Local root.FullName
| FCSVersion.Git spec ->
let checkout = checkoutAndBuild config spec
NuGetFCSVersion.Local checkout.Dir

)
Loading