diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index 683f3909b447..68c6eb4de756 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -60,6 +60,19 @@ jobs: with: outputFile: output-annotations.txt + + odlint: + name: Lint with OpenDream + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Setup OD + run: | + bash tools/ci/setup_od.sh + - name: Run OD + run: | + bash tools/ci/run_od.sh + compile_all_maps: if: "!contains(github.event.head_commit.message, '[ci skip]')" name: Compile Maps diff --git a/code/__odlint.dm b/code/__odlint.dm new file mode 100644 index 000000000000..47301d6cf7bd --- /dev/null +++ b/code/__odlint.dm @@ -0,0 +1,11 @@ +// This file is included right at the start of the DME. +// Its purpose is to enable multiple lints (pragmas) that are supported by OpenDream to better validate the codebase +// These are essentially nitpicks the DM compiler should pick up on but doesnt + +#ifndef SPACEMAN_DMM +#ifdef OPENDREAM +// These are in their own file as you need to do it with an include as a hack to avoid +// SpacemanDMM evaluating the #pragma lines, even if its outside a block it cares about +#include "tools/ci/lints.dm" +#endif +#endif diff --git a/colonialmarines.dme b/colonialmarines.dme index 63140be5e458..88f4acfff7de 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -11,6 +11,7 @@ s// DM Environment file for colonialmarines.dme. #define DEBUG // END_PREFERENCES // BEGIN_INCLUDE +#include "code\__odlint.dm" #include "code\_byond_version_compat.dm" #include "code\_compile_options.dm" #include "code\_experiments.dm" diff --git a/tools/ci/lints.dm b/tools/ci/lints.dm new file mode 100644 index 000000000000..39c14e1bbc95 --- /dev/null +++ b/tools/ci/lints.dm @@ -0,0 +1,27 @@ +//1000-1999 +#pragma FileAlreadyIncluded error +#pragma MissingIncludedFile error +#pragma MisplacedDirective error +#pragma UndefineMissingDirective error +#pragma DefinedMissingParen error +#pragma ErrorDirective error +#pragma WarningDirective error +#pragma MiscapitalizedDirective error + +//2000-2999 +#pragma SoftReservedKeyword error +#pragma DuplicateVariable error +#pragma DuplicateProcDefinition error +#pragma TooManyArguments error +#pragma PointlessParentCall error +#pragma PointlessBuiltinCall error +#pragma SuspiciousMatrixCall error +#pragma MalformedRange error +#pragma InvalidRange error +#pragma InvalidSetStatement error +#pragma InvalidOverride error +#pragma DanglingVarType error +#pragma MissingInterpolatedExpression error + +//3000-3999 +#pragma EmptyBlock error diff --git a/tools/ci/run_od.sh b/tools/ci/run_od.sh new file mode 100644 index 000000000000..fa7438568fb1 --- /dev/null +++ b/tools/ci/run_od.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -eo pipefail +dotnet OpenDream/DMCompiler/bin/Release/net7.0/DMCompiler.dll --suppress-unimplemented colonialmarines.dme diff --git a/tools/ci/setup_od.sh b/tools/ci/setup_od.sh new file mode 100644 index 000000000000..aad45f2bc971 --- /dev/null +++ b/tools/ci/setup_od.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -eo pipefail + +git clone https://github.com/OpenDreamProject/OpenDream.git OpenDream +cd OpenDream +git submodule update --init --recursive +dotnet restore +dotnet build -c Release diff --git a/tools/ci/validate_dme.py b/tools/ci/validate_dme.py index 33066f72e75e..03136949ae0c 100644 --- a/tools/ci/validate_dme.py +++ b/tools/ci/validate_dme.py @@ -17,6 +17,9 @@ # Included by BSQL/includes.dm r'code/__HELPERS/BSQL/**/*.dm', + + # Included as part of OD lints + r'tools/ci/lints.dm' ] lines = []