Skip to content

Commit

Permalink
Update formatting (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon authored May 3, 2024
1 parent 596bd9c commit c42ae9e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
19 changes: 12 additions & 7 deletions build/scripts/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ type Build =

| [<CliPrefix(CliPrefix.None);SubCommand>] Unit_Test
| [<CliPrefix(CliPrefix.None);SubCommand>] End_To_End

| [<CliPrefix(CliPrefix.None);SubCommand>] Format

| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PristineCheck
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] CheckFormat
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PristineCheck
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GeneratePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidateLicenses
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidatePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateReleaseNotes
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateApiChanges
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidateLicenses
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidatePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateReleaseNotes
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GenerateApiChanges
| [<CliPrefix(CliPrefix.None);SubCommand>] Release

| [<Inherit;AltCommandLine("-s")>] Single_Target
Expand All @@ -49,12 +52,14 @@ with
| End_To_End -> "alias to providing: test --test-suite=e2e"
| Test -> "runs a clean build and then runs all the tests unless --test-suite is provided"
| Release -> "runs build, tests, and create and validates the packages shy of publishing them"
| Format -> "runs dotnet format"

// steps
| PristineCheck
| CheckFormat
| PristineCheck
| GeneratePackages
| ValidateLicenses
| ValidatePackages
| ValidatePackages
| GenerateReleaseNotes
| GenerateApiChanges -> "Undocumented, dependent target"

Expand Down
20 changes: 14 additions & 6 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@ let private clean _ =
let private build _ = exec { run "dotnet" "build" "-c" "release" }

let private release _ = printfn "release"

let private publish _ = printfn "publish"

let private version _ =
let version = Software.Version
printfn $"Informational version: %s{version.AsString}"
printfn $"Semantic version: %s{version.NormalizeToShorter()}"

let private generatePackages _ = exec { run "dotnet" "pack" }


let private format _ = exec { run "dotnet" "format" "--verbosity" "quiet" }

let private checkFormat _ =
match exec { exit_code_of "dotnet" "format" "--verify-no-changes" } with
| 0 -> printfn "There are no dotnet formatting violations, continuing the build."
| _ -> failwithf "There are dotnet formatting violations. Call `dotnet format` to fix or specify -c to ./build.sh to skip this check"

let private pristineCheck (arguments:ParseResults<Build>) =
let skipCheck = arguments.TryGetResult Skip_Dirty_Check |> Option.isSome
match skipCheck, Information.isCleanWorkingCopy "." with
Expand Down Expand Up @@ -157,7 +162,7 @@ let Setup (parsed:ParseResults<Build>) =
// commands
| Version -> Build.Step version
| Clean -> Build.Cmd [Version] [] clean
| Build -> Build.Cmd [Clean] [] build
| Build -> Build.Cmd [Clean; CheckFormat] [] build

| End_To_End -> Build.Cmd [] [Build] <| runTests E2E
| Unit_Test -> Build.Cmd [] [Build] <| runTests Unit
Expand All @@ -168,9 +173,12 @@ let Setup (parsed:ParseResults<Build>) =
[PristineCheck; Test]
[ValidateLicenses; GeneratePackages; ValidatePackages; GenerateReleaseNotes; GenerateApiChanges]
release


| Format -> Build.Step format

// steps
| PristineCheck -> Build.Step pristineCheck
| CheckFormat -> Build.Step checkFormat
| PristineCheck -> Build.Step pristineCheck
| GeneratePackages -> Build.Step generatePackages
| ValidateLicenses -> Build.Step validateLicenses
| ValidatePackages -> Build.Step validatePackages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static LogLevel GetElasticOtelLogLevelFromEnvironmentVariables()

if (string.IsNullOrEmpty(logLevelEnvironmentVariable))
return defaultLogLevel;

var parsedLogLevel = LogLevelHelpers.ToLogLevel(logLevelEnvironmentVariable);
return parsedLogLevel != LogLevel.None ? parsedLogLevel : defaultLogLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Diagnostics.Tracing;
using System.Text;
using System.Text.RegularExpressions;
using Elastic.OpenTelemetry.Configuration;
using Elastic.OpenTelemetry.Diagnostics.Logging;
using Microsoft.Extensions.Logging;
using Elastic.OpenTelemetry.Configuration;

namespace Elastic.OpenTelemetry.Diagnostics;

Expand Down

0 comments on commit c42ae9e

Please sign in to comment.