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

GOV-1: Adding warning-as-error option for build related actions and workflows #185

Merged
merged 15 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
param (
param (
[string] $Configuration,
[string] $SolutionOrProject,
[string] $Verbosity,
[string] $EnableCodeAnalysis,
[string] $Version,
[string] $Switches,
[string] $ExpectedCodeAnalysisErrors,
[boolean] $CreateBinaryLog)
[boolean] $CreateBinaryLog,
[boolean] $WarningsAsErrors)

function ConvertTo-Array([string] $rawInput)
{
Expand All @@ -24,10 +25,10 @@ $buildSwitches = ConvertTo-Array @"
--configuration:$Configuration
--nologo
--verbosity:$Verbosity
--warnaserror
$($WarningsAsErrors ? '--warnaserror' : '')
--warnAsMessage:MSB3026
--consoleLoggerParameters:NoSummary
-p:TreatWarningsAsErrors=true
-p:TreatWarningsAsErrors=$WarningsAsErrors
-p:RunAnalyzersDuringBuild=$EnableCodeAnalysis
-p:Retries=4
-p:RetryDelayMilliseconds=1000
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/build-dotnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ inputs:
description: >
Duration in days after which the artifact of the binary log (if any) will expire. See
https://github.com/actions/upload-artifact#retention-period for more details.
warnings-as-errors:
required: false
default: "true"
description: >
Whether compiler warnings should be treated as errors during the build process. The default value is "true", the
compiler flag "-warnaserror" will be used, causing the build to fail if any warnings are generated. If set to
"false", the flag "-warnaserror" will not be used, allowing warnings to be generated without causing the build to
fail.

runs:
using: "composite"
Expand Down Expand Up @@ -158,6 +166,7 @@ runs:
Switches = $buildSwitches
ExpectedCodeAnalysisErrors = $expectedCodeAnalysisErrors
CreateBinaryLog = $${{ inputs.create-binary-log }}
WarningsAsErrors = $${{ inputs.warnings-as-errors }}
}

$startTime = [DateTime]::Now
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/build-and-test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ on:
description: >
When set to true, it will be verified whether the NuGet packages of the .NET solution are consolidated, i.e.
the same version of a given package is used in all projects.
warnings-as-errors:
required: false
type: string
default: "true"
description: >
Whether compiler warnings should be treated as errors during the build process. The default value is "true",
the compiler flag "-warnaserror" will be used, causing the build to fail if any warnings are generated. If set
to "false", the flag "-warnaserror" will not be used, allowing warnings to be generated without causing the
build to fail.

jobs:
# While the below steps seem suitable to DRY with build-and-test-orchard-core, since reusable workflows can't call
Expand Down Expand Up @@ -169,6 +178,7 @@ jobs:
solution-or-project-path: ${{ inputs.build-solution-path }}
create-binary-log: ${{ inputs.build-create-binary-log }}
binary-log-artifact-retention-days: ${{ inputs.build-binary-log-artifact-retention-days }}
warnings-as-errors: ${{ inputs.warnings-as-errors }}

- name: Tests
if: inputs.test-disable == 'false'
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/build-and-test-orchard-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ on:
description: >
When set to true, it will be verified whether the NuGet packages of the .NET solution are consolidated, i.e.
the same version of a given package is used in all projects.
warnings-as-errors:
required: false
type: string
default: "true"
description: >
Whether compiler warnings should be treated as errors during the build process. The default value is "true",
the compiler flag "-warnaserror" will be used, causing the build to fail if any warnings are generated. If set
to "false", the flag "-warnaserror" will not be used, allowing warnings to be generated without causing the
build to fail.

jobs:
build-and-test:
Expand Down Expand Up @@ -199,6 +208,7 @@ jobs:
solution-or-project-path: ${{ inputs.build-solution-path }}
create-binary-log: ${{ inputs.build-create-binary-log }}
binary-log-artifact-retention-days: ${{ inputs.build-binary-log-artifact-retention-days }}
warnings-as-errors: ${{ inputs.warnings-as-errors }}

- name: Set up SQL Server
if: inputs.set-up-sql-server == 'true'
Expand Down