diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb64f70bcd..6ebaa71fb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: run: | sudo apt-get install lua5.1 make check-scripts - make test + make TREAT_WARNINGS_AS_ERRORS=true test linux-mono: name: Linux (mono) @@ -48,7 +48,7 @@ jobs: - name: Check Mods run: | # check-scripts does not depend on .net/mono, so is not needed here - make RUNTIME=mono test + make RUNTIME=mono TREAT_WARNINGS_AS_ERRORS=true test windows: name: Windows (.NET 6.0) @@ -76,5 +76,6 @@ jobs: run: | chocolatey install lua --version 5.1.5.52 $ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\" + $ENV:TREAT_WARNINGS_AS_ERRORS = "true" .\make.ps1 check-scripts .\make.ps1 test diff --git a/Makefile b/Makefile index 7e8ceea556..903b7f6992 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ help: @echo ' make [RUNTIME=net6] TARGETPLATFORM=unix-generic' @echo @echo 'to check the official mods for erroneous yaml files, run:' - @echo ' make [RUNTIME=net6] test' + @echo ' make [RUNTIME=net6] [TREAT_WARNINGS_AS_ERRORS=false] test' @echo @echo 'to check the engine and official mod dlls for code style violations, run:' @echo ' make [RUNTIME=net6] check' diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs index ad1eacc909..267827235a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs @@ -41,11 +41,14 @@ namespace OpenRA.Mods.Common.UtilityCommands return true; } + bool warningAsError = false; + [Desc("[MAPFILE]", "Check a mod or map for certain yaml errors.")] void IUtilityCommand.Run(Utility utility, string[] args) { // HACK: The engine code assumes that Game.modData is set. var modData = Game.ModData = utility.ModData; + warningAsError = Environment.GetEnvironmentVariable("TREAT_WARNINGS_AS_ERRORS")?.Equals("true", StringComparison.CurrentCultureIgnoreCase) ?? false; try { @@ -77,7 +80,7 @@ namespace OpenRA.Mods.Common.UtilityCommands try { var customPass = (ILintPass)modData.ObjectCreator.CreateBasic(customPassType); - customPass.Run(EmitError, EmitWarning, modData); + customPass.Run(EmitError, warningAsError ? EmitError : EmitWarning, modData); } catch (Exception e) { @@ -140,7 +143,7 @@ namespace OpenRA.Mods.Common.UtilityCommands try { var customMapPass = (ILintMapPass)modData.ObjectCreator.CreateBasic(customMapPassType); - customMapPass.Run(EmitError, EmitWarning, modData, map); + customMapPass.Run(EmitError, warningAsError ? EmitError : EmitWarning, modData, map); } catch (Exception e) { @@ -156,7 +159,7 @@ namespace OpenRA.Mods.Common.UtilityCommands try { var customRulesPass = (ILintRulesPass)modData.ObjectCreator.CreateBasic(customRulesPassType); - customRulesPass.Run(EmitError, EmitWarning, modData, rules); + customRulesPass.Run(EmitError, warningAsError ? EmitError : EmitWarning, modData, rules); } catch (Exception e) { @@ -172,7 +175,7 @@ namespace OpenRA.Mods.Common.UtilityCommands try { var customRulesPass = (ILintSequencesPass)modData.ObjectCreator.CreateBasic(customSequencesPassType); - customRulesPass.Run(EmitError, EmitWarning, modData, rules, sequences); + customRulesPass.Run(EmitError, warningAsError ? EmitError : EmitWarning, modData, rules, sequences); } catch (Exception e) {