Skip to content

Commit

Permalink
the od linter
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Oct 12, 2023
1 parent d9250db commit 351e2dc
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions code/__odlint.dm
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 27 additions & 0 deletions tools/ci/lints.dm
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tools/ci/run_od.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -eo pipefail
dotnet OpenDream/DMCompiler/bin/Release/net7.0/DMCompiler.dll --suppress-unimplemented colonialmarines.dme
8 changes: 8 additions & 0 deletions tools/ci/setup_od.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tools/ci/validate_dme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 351e2dc

Please sign in to comment.