Skip to content

Commit 144bb59

Browse files
Merge pull request #5247 from out-of-phaze/fix/modpack-lint
Lint modpack testing map instead of default map
2 parents 17f2c5e + 68c44e1 commit 144bb59

File tree

6 files changed

+111
-29
lines changed

6 files changed

+111
-29
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: Run Dreamchecker
3434
run: |
3535
set -o pipefail
36-
~/dreamchecker 2>&1 | tee ${GITHUB_WORKSPACE}/output-annotations.txt
3736
./test/lint-all-modpacks.sh nebula.dme
37+
./test/lint-each-modpack.sh nebula.dme
3838
- name: Annotate Lints
3939
uses: yogstation13/DreamAnnotate@v2
4040
if: always()
@@ -67,7 +67,7 @@ jobs:
6767
fileName: "DMCompiler_linux-x64.tar.gz"
6868
extract: true
6969
- name: Run OpenDream
70-
run: ./DMCompiler_linux-x64/DMCompiler nebula.dme --define=UNIT_TEST --suppress-unimplemented --skip-anything-typecheck --version=${BYOND_MAJOR}.${BYOND_MINOR} | bash test/annotate_od.sh
70+
run: ./test/compile-od-all-modpacks.sh nebula.dme
7171
Code:
7272
runs-on: ubuntu-latest
7373
steps:

mods/content/undead/mods/undead_zombie.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
limb.createwound(BURN, rand(limb.max_damage * 0.25, limb.max_damage * 0.5))
5353

5454
set_max_health(round(species.total_health / 2))
55-
vessel.remove_any(vessel.total_volume * rand(0.2, 0.5))
55+
vessel.remove_any(REAGENT_TOTAL_VOLUME(vessel) * rand(0.2, 0.5))
5656
update_body()
5757

5858
/mob/living/human/zombie

test/annotate_od.sh

100644100755
File mode changed.

test/compile-od-all-modpacks.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
set -o pipefail
4+
5+
dmepath=""
6+
7+
for var; do
8+
if [[ $var != -* && $var == *.dme ]]; then
9+
dmepath=$(echo $var | sed -r 's/.{4}$//')
10+
break
11+
fi
12+
done
13+
14+
if [[ $dmepath == "" ]]; then
15+
echo "No .dme file specified, aborting."
16+
exit 1
17+
fi
18+
19+
if [[ -a $dmepath.m.dme ]]; then
20+
rm $dmepath.m.dme
21+
fi
22+
23+
cp $dmepath.dme $dmepath.m.dme
24+
if [[ $? != 0 ]]; then
25+
echo "Failed to make modified dme, aborting."
26+
exit 2
27+
fi
28+
29+
sed -i '1s/^/#define MAP_OVERRIDE\n/' $dmepath.m.dme
30+
sed -i 's!#include "maps\\_map_include.dm"!#include "maps\\modpack_testing\\modpack_testing.dm"!' $dmepath.m.dme
31+
failed=0
32+
./DMCompiler_linux-x64/DMCompiler "$dmepath.m.dme" --define=UNIT_TEST --suppress-unimplemented --skip-anything-typecheck --version=${BYOND_MAJOR}.${BYOND_MINOR} | bash test/annotate_od.sh
33+
# Check the return value
34+
if [[ $? -ne 0 ]]; then
35+
failed=1
36+
fi
37+
rm $dmepath.m.dme
38+
if [[ $failed -eq 1 ]]; then
39+
echo "Modpack testing map failed to pass validation."
40+
exit 1
41+
fi

test/lint-all-modpacks.sh

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -o pipefail
44

55
dmepath=""
6-
retval=1
76

87
for var; do
98
if [[ $var != -* && $var == *.dme ]]; then
@@ -28,33 +27,16 @@ if [[ $? != 0 ]]; then
2827
fi
2928

3029
sed -i '1s/^/#define MAP_OVERRIDE\n/' $dmepath.m.dme
31-
sed -i 's!#include "maps\\_map_include.dm"!#include "maps\\example\\example.dm"!' $dmepath.m.dme
32-
33-
# find feature DMEs to include. they're located in mods/**/**/*.dme. for example: mods/content/fantasy/_fantasy.dme
34-
# it is guaranteed that each feature folder has only one DME file, so wildcard matching will work
35-
dme_features=$(find mods -mindepth 3 -type f -name '*.dme')
36-
# some features may be bare DM files, located at mods/**/*.dm. for example: mods/content/mundane.dm
37-
# it is guaranteed that all bare DM files directly in mods/content, mods/gamemodes, and similar folders are able to be included as features
38-
dm_features=$(find mods -mindepth 2 -maxdepth 2 -name '*.dm' ! -path 'mods/~*/*' ! -path 'mods/*/~.dm' )
39-
# do some sort of for loop to insert a feature at the end of the DME prior to #include "mods\~compatibility\~compatibility.dm"
40-
# run ~/dreamchecker -e $dmepath.m.dme 2>&1 | tee -a ${GITHUB_WORKSPACE}/output-annotations.txt
41-
# then remove the inserted feature after so the next step in the loop can test a new feature
30+
sed -i 's!#include "maps\\_map_include.dm"!#include "maps\\modpack_testing\\modpack_testing.dm"!' $dmepath.m.dme
4231
failed=0
43-
for feature in $dme_features $dm_features; do
44-
echo "Testing feature: $feature"
45-
# Include the feature
46-
sed -i "/#include \"mods\\\\_modpack.dm\"/a#include \"$feature\"" "$dmepath.m.dme"
47-
# Run the linter, only doing parsing to catch undefined vars and keywords
48-
~/dreamchecker -e "$dmepath.m.dme" --parse-only 2>&1 | tee -a "${GITHUB_WORKSPACE}/output-annotations.txt"
49-
# Check the return value
50-
if [[ $? -ne 0 ]]; then
51-
failed=1
52-
fi
53-
# Remove the feature include
54-
sed -i "\\:#include \"$feature\":d" "$dmepath.m.dme"
55-
done
32+
# Run the linter, doing a full linting rather than just parsing
33+
~/dreamchecker -e "$dmepath.m.dme" 2>&1 | tee -a "${GITHUB_WORKSPACE}/output-annotations.txt"
34+
# Check the return value
35+
if [[ $? -ne 0 ]]; then
36+
failed=1
37+
fi
5638
rm $dmepath.m.dme
5739
if [[ $failed -eq 1 ]]; then
58-
echo "One or more modpacks failed to pass solo validation."
40+
echo "Modpack testing map failed to pass validation."
5941
exit 1
6042
fi

test/lint-each-modpack.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
set -o pipefail
4+
5+
dmepath=""
6+
7+
for var; do
8+
if [[ $var != -* && $var == *.dme ]]; then
9+
dmepath=$(echo $var | sed -r 's/.{4}$//')
10+
break
11+
fi
12+
done
13+
14+
if [[ $dmepath == "" ]]; then
15+
echo "No .dme file specified, aborting."
16+
exit 1
17+
fi
18+
19+
if [[ -a $dmepath.m.dme ]]; then
20+
rm $dmepath.m.dme
21+
fi
22+
23+
cp $dmepath.dme $dmepath.m.dme
24+
if [[ $? != 0 ]]; then
25+
echo "Failed to make modified dme, aborting."
26+
exit 2
27+
fi
28+
29+
sed -i '1s/^/#define MAP_OVERRIDE\n/' $dmepath.m.dme
30+
sed -i 's!#include "maps\\_map_include.dm"!#include "maps\\example\\example.dm"!' $dmepath.m.dme
31+
32+
# find feature DMEs to include. they're located in mods/**/**/*.dme. for example: mods/content/fantasy/_fantasy.dme
33+
# it is guaranteed that each feature folder has only one DME file, so wildcard matching will work
34+
dme_features=$(find mods -mindepth 3 -type f -name '*.dme')
35+
# some features may be bare DM files, located at mods/**/*.dm. for example: mods/content/mundane.dm
36+
# it is guaranteed that all bare DM files directly in mods/content, mods/gamemodes, and similar folders are able to be included as features
37+
dm_features=$(find mods -mindepth 2 -maxdepth 2 -name '*.dm' ! -path 'mods/~*/*' ! -path 'mods/*/~.dm' )
38+
# do some sort of for loop to insert a feature at the end of the DME prior to #include "mods\~compatibility\~compatibility.dm"
39+
# run ~/dreamchecker -e $dmepath.m.dme 2>&1 | tee -a ${GITHUB_WORKSPACE}/output-annotations.txt
40+
# then remove the inserted feature after so the next step in the loop can test a new feature
41+
failed=0
42+
for feature in $dme_features $dm_features; do
43+
echo "Testing feature: $feature"
44+
# Include the feature
45+
sed -i "/#include \"mods\\\\_modpack.dm\"/a#include \"$feature\"" "$dmepath.m.dme"
46+
# Run the linter, only doing parsing to catch undefined vars and keywords
47+
~/dreamchecker -e "$dmepath.m.dme" --parse-only 2>&1 | tee -a "${GITHUB_WORKSPACE}/output-annotations.txt"
48+
# Check the return value
49+
if [[ $? -ne 0 ]]; then
50+
failed=1
51+
fi
52+
# Remove the feature include
53+
sed -i "\\:#include \"$feature\":d" "$dmepath.m.dme"
54+
done
55+
rm $dmepath.m.dme
56+
if [[ $failed -eq 1 ]]; then
57+
echo "One or more modpacks failed to pass solo validation."
58+
exit 1
59+
fi

0 commit comments

Comments
 (0)