Skip to content

Commit 69926c4

Browse files
authored
Merge a179d27 into 5a46eab
2 parents 5a46eab + a179d27 commit 69926c4

File tree

10 files changed

+293
-55
lines changed

10 files changed

+293
-55
lines changed

.github/workflows/core_build.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
name: Linux Build
22
on:
33
push:
4-
branches: [ master ]
4+
paths-ignore:
5+
- 'README.md'
6+
- 'apps/**'
7+
branches: [ master ]
58
pull_request:
6-
branches: [ master ]
9+
paths-ignore:
10+
- 'README.md'
11+
- 'apps/**'
12+
branches: [ master ]
713

814
jobs:
915
build:
16+
strategy:
17+
fail-fast: false
18+
1019
runs-on: ubuntu-latest
1120

1221
steps:
@@ -20,11 +29,27 @@ jobs:
2029
- name: Install Required Packages
2130
run: sudo apt-get install -y git make cmake clang libssl-dev libbz2-dev build-essential default-libmysqlclient-dev libace-dev libreadline-dev
2231

23-
- name: Update Compilers
24-
run: source ./apps/ci/ci-compiler-update.sh
32+
- name: Install OpenSSL 3.5.1 Package Manually
33+
run: |
34+
wget https://www.openssl.org/source/openssl-3.5.1.tar.gz
35+
tar -xvf openssl-3.5.1.tar.gz
36+
cd openssl-3.5.1
37+
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
38+
make -j$(nproc)
39+
sudo make install
40+
41+
- name: Set OpenSSL 3.5.1 Environment Variables
42+
run: |
43+
echo "OPENSSL_ROOT_DIR=/usr/local/openssl" >> $GITHUB_ENV
44+
echo "OPENSSL_INCLUDE_DIR=/usr/local/openssl/include" >> $GITHUB_ENV
45+
echo "OPENSSL_LIBRARIES=/usr/local/openssl/lib" >> $GITHUB_ENV
46+
echo "/usr/local/openssl/lib" | sudo tee /etc/ld.so.conf.d/openssl-3.5.conf
47+
sudo ldconfig
2548
2649
- name: Check for Submodule Updates
27-
run: source ./apps/ci/ci-submodule-update.sh
50+
run: |
51+
git submodule init
52+
git submodule update
2853
2954
- name: Build Mangos Project
3055
run: source ./apps/ci/ci-compile.sh

.github/workflows/core_codestyle.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ jobs:
1111
fail-fast: false
1212

1313
runs-on: ubuntu-latest
14+
1415
name: Check Codestyling
1516
steps:
1617
- uses: actions/checkout@v2
1718

1819
- name: Check Codestyling
19-
run: source ./apps/ci/ci-codestyle.sh
20+
run: bash ./apps/ci/ci-codestyle.sh

.github/workflows/core_windows_build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name: Windows Build
22
on:
33
push:
4-
branches: [ master ]
4+
paths-ignore:
5+
- 'README.md'
6+
- 'apps/**'
7+
branches: [ master ]
58
pull_request:
6-
branches: [ master ]
9+
paths-ignore:
10+
- 'README.md'
11+
- 'apps/**'
12+
branches: [ master ]
713

814
jobs:
915
build:

.github/workflows/docker_build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name: Docker Build
22
on:
33
push:
4-
branches: [ master ]
4+
paths-ignore:
5+
- 'README.md'
6+
- 'apps/**'
7+
branches: [ master ]
58
pull_request:
6-
branches: [ master ]
9+
paths-ignore:
10+
- 'README.md'
11+
- 'apps/**'
12+
branches: [ master ]
713

814
jobs:
915
build:

apps/ci/ci-codestyle.sh

Lines changed: 183 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,198 @@
11
#!/bin/bash
22

3-
set -e
3+
#
4+
# Advanced Code Styling Check for getMaNGOS
5+
# Script written by Meltie2013 (https://github.com/Meltie2013)
6+
#
7+
# Copyright: 2025
8+
# Website: https://getmangos.eu/
9+
#
10+
# Script Type: Bash
11+
#
12+
# Co-authors Area:
13+
#
14+
# Note from the author: Anyone is free to use this script but is asked to keep the original author name and GitHub url in the header.
15+
# You can add co-authors to the header when the script is updated or changed for your project needs. Removing the original author
16+
# from the header, will result in a DMCA (take-down).
17+
#
18+
# This script is viewed under the GPL-2.0 license and shall not be changed unless authorized by the original author.
19+
#
20+
21+
LOG_IGNORED_RULES=false # Set to true to print exception rule matches
422

5-
echo "Starting Codestyling Script:"
623
echo
24+
echo "Checking For MaNGOS Coding Standards:"
25+
echo "Starting Codestyling Script:"
726

827
declare -A singleLineRegexChecks=(
9-
["[[:blank:]]$"]="Remove whitespace at the end of the lines above"
10-
["\t"]="Replace tabs with 4 spaces in the lines above"
28+
# General whitespace/style rules
29+
["[[:blank:]]$"]="Remove whitespace at the end of the lines"
30+
["\t"]="Replace tabs with 4 spaces in the lines"
31+
32+
# Exception patterns (ignored, but still shown in summary)
33+
["^[[:blank:]]*\\{\\s*\".*?\"\\s*,\\s*\\w+\\s*,\\s*(true|false)\\s*,\\s*&[a-zA-Z_][\\w:]*::[a-zA-Z_]\\w*\\s*,\\s*\".*?\"\\s*,\\s*(NULL|nullptr)\\s*\\},?[[:blank:]]*$"]="Well-formed initializer list line (styling is valid) #ignore"
34+
["^[[:blank:]]*\\{[[:blank:]]*\"(SOAP-ENV|SOAP-ENC|xsi|xsd|ns1)\"[[:blank:]]*,[[:blank:]]*\"(http://[^\"]+|urn:[^\"]+)\"(?:[[:blank:]]*,[[:blank:]]*\"(http://[^\"]+|urn:[^\"]+)\")?[[:blank:]]*\\}[[:blank:]]*,?[[:blank:]]*(//.*)?$"]="Namespace initializer list line (styling is valid) #ignore"
35+
["^[[:blank:]]*[^[:blank:]]+[[:blank:]]*<<(.*\"[^\"]*[{}][^\"]*\".*)+[[:blank:]]*;?[[:blank:]]*$"]="Streamed brace output (styling is valid) #ignore"
36+
37+
# Control TODO/FIXME rules
38+
["//[[:blank:]]*(TODO|FIXME)[[:blank:]]*(?!:)"]="TODO/FIXME must include description"
39+
40+
# Virtual destructor enforcement
41+
["\\b(?:virtual[[:space:]]+)?~[[:alnum:]_]+[[:space:]]*\\([[:space:]]*\\)[[:space:]]*\\{[[:space:]]*\\}[[:space:]]*;?"]="Prefer '= default' for destructors instead of empty braces"
42+
43+
# Control statements and braces
44+
["^[[:blank:]]*(if|else if|else|do|for|while|switch|try|catch|class|struct|namespace|case)[[:blank:]]*(\(.*\))?[[:blank:]]*\{[[:blank:]]*\S"]="Opening brace must be on its own line after statement"
45+
["^[[:blank:]]*[\w:<>\*&~]+[[:blank:]]+\w+::?\w*\(.*\)[[:blank:]]*(const)?[[:blank:]]*\{[[:blank:]]*\S"]="Function opening brace must be on its own line (no code after '{')"
46+
["^\s*\S.*\}[[:blank:]]*\S.*$"]="Closing brace must be on its own line (no code before or after '}' on the line)"
47+
48+
# Brace usage enforcement
49+
["^[[:blank:]]*enum[[:blank:]]+(\\w+[[:blank:]]*)?\\{[[:blank:]]*[^}]*\\}[[:blank:]]*;"]="Enum opening brace must be on its own line and enum body properly formatted"
50+
51+
# Spacing rules
52+
["\\b(if|for|while|switch|else\\s+if)\\("]="Missing space between keyword and '('"
53+
54+
# Bad coding practice enforcement
55+
["^[[:blank:]]*using[[:blank:]]+namespace[[:blank:]]+std[[:blank:]]*;"]="Avoid using namespace std (prefer explicit qualifiers)"
56+
["^[[:blank:]]*namespace[[:blank:]]*\\{"]="Anonymous namespace brace must be on its own line"
57+
)
58+
59+
# Directories and files to exclude
60+
grep_exclude_args=(
61+
# Exclude Folders
62+
--exclude-dir="Eluna"
63+
--exclude-dir="Extractor_Binaries"
64+
--exclude-dir="MangosStrings_LanguageHGenerator"
65+
--exclude-dir="restart-scripts"
66+
67+
# Exclude Files
68+
--exclude="CMakeLists.txt"
69+
--exclude="realmd.conf.dist.in"
70+
--exclude="mangosd.conf.dist.in"
71+
--exclude=".dockerignore"
72+
--exclude=".gitattributes"
73+
--exclude=".gitignore"
74+
--exclude=".gitmodules"
1175
)
1276

13-
for check in ${!singleLineRegexChecks[@]}; do
14-
echo " Checking RegEx: '${check}'"
15-
16-
if grep -P -r -I -n ${check} src; then
17-
echo
18-
echo "${singleLineRegexChecks[$check]}"
19-
exit 1
77+
input_paths=("$@")
78+
if [[ ${#input_paths[@]} -eq 0 ]]; then
79+
input_paths=("src")
80+
fi
81+
82+
hadError=0
83+
declare -a triggeredDescriptions
84+
declare -a ignoredLines=() # To store all lines matched by #ignore rules
85+
86+
# First pass: collect ignored lines (to exclude later from other rules)
87+
for check in "${!singleLineRegexChecks[@]}"; do
88+
ruleDesc="${singleLineRegexChecks[$check]}"
89+
if [[ "$ruleDesc" == *"#ignore"* ]]; then
90+
# Keep original description with #ignore intact
91+
origRuleDesc="$ruleDesc"
92+
# Create print-friendly description without #ignore
93+
printRuleDesc="${ruleDesc%%#*}"
94+
95+
matches=$(grep -P -r -I -n "${grep_exclude_args[@]}" "${input_paths[@]}" -e "$check" 2>/dev/null)
96+
if [[ -n "$matches" ]]; then
97+
ignoredLines+=("$matches")
98+
triggeredDescriptions+=("$origRuleDesc") # Store original with #ignore for summary categorization
99+
100+
if $LOG_IGNORED_RULES; then
101+
echo
102+
echo "== Exception Rule matched: $printRuleDesc =="
103+
echo "$matches"
104+
fi
105+
fi
20106
fi
21107
done
22108

23-
# declare -A multiLineRegexChecks=(
24-
# ["\n\n\n"]="Multiple blank lines detected, keep only one. Check the files above"
25-
# )
109+
# Flatten ignoredLines to a single pattern (line numbers + paths) for exclusion
110+
ignoredPattern=$(printf "%s\n" "${ignoredLines[@]}" | cut -d: -f1,2 | sort -u | tr '\n' '|' | sed 's/|$//')
26111

27-
# for check in ${!multiLineRegexChecks[@]}; do
28-
# echo " Checking RegEx: '${check}'"
112+
# Second pass: check non-ignored rules, excluding ignored lines from output
113+
for check in "${!singleLineRegexChecks[@]}"; do
114+
ruleDesc="${singleLineRegexChecks[$check]}"
115+
if [[ "$ruleDesc" == *"#ignore"* ]]; then
116+
# Already handled in first pass, skip here
117+
continue
118+
fi
119+
120+
matches=$(grep -P -r -I -n "${grep_exclude_args[@]}" "${input_paths[@]}" -e "$check" 2>/dev/null)
121+
122+
# Filter out any ignored lines from matches
123+
if [[ -n "$matches" ]]; then
124+
# Remove lines already caught by ignored rules
125+
filteredMatches=$(printf "%s\n" "$matches" | grep -v -E "^($ignoredPattern):")
126+
127+
if [[ -n "$filteredMatches" ]]; then
128+
# Skip lines with streamed or quoted braces
129+
filteredMatches=$(printf "%s\n" "$filteredMatches" | while IFS= read -r line; do
130+
# Extract just the code part from line (after filename:linenumber:)
131+
codePart=$(echo "$line" | cut -d: -f3-)
29132
30-
# if grep -Pzo -r -I ${check} src; then
31-
# echo
32-
# echo
33-
# echo "${multiLineRegexChecks[$check]}"
34-
# exit 1
35-
# fi
36-
# done
133+
echo "$line"
134+
done)
135+
136+
if [[ -n "$filteredMatches" ]]; then
137+
echo
138+
echo "== Rule triggered: $ruleDesc =="
139+
echo "$filteredMatches"
140+
triggeredDescriptions+=("$ruleDesc")
141+
hadError=1
142+
fi
143+
fi
144+
fi
145+
done
37146
38147
echo
39-
echo "Awesome! No issues..."
148+
echo "------------------------------------------"
149+
echo "Summary of Triggered Rules:"
150+
echo "------------------------------------------"
151+
152+
if [[ ${#triggeredDescriptions[@]} -eq 0 ]]; then
153+
echo "No style violations found."
154+
else
155+
declare -A seen=()
156+
exceptions=()
157+
violations=()
158+
159+
for desc in "${triggeredDescriptions[@]}"; do
160+
# Remove leading/trailing whitespace and outer quotes if present
161+
clean_desc="$(echo "$desc" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g' | sed -E 's/^"(.*)"$/\1/')"
162+
163+
# Deduplicate
164+
[[ -n "${seen[$clean_desc]}" ]] && continue
165+
seen["$clean_desc"]=1
166+
167+
# Check if the line ends with #ignore (with or without trailing space)
168+
if [[ "$desc" =~ [[:space:]]*#ignore$ ]]; then
169+
# Remove #ignore for printing
170+
exceptions+=("$(echo "$clean_desc" | sed -E 's/[[:space:]]*#ignore$//')")
171+
else
172+
violations+=("$clean_desc")
173+
fi
174+
done
175+
176+
echo "Exception Rules (Informational Only):"
177+
echo "----"
178+
if [[ ${#exceptions[@]} -eq 0 ]]; then
179+
echo "(none)"
180+
else
181+
for e in "${exceptions[@]}"; do
182+
echo "$e"
183+
done
184+
fi
185+
186+
echo "------------------------------------------"
187+
echo "Violations:"
188+
echo "----"
189+
if [[ ${#violations[@]} -eq 0 ]]; then
190+
echo "(none)"
191+
else
192+
for v in "${violations[@]}"; do
193+
echo "$v"
194+
done
195+
fi
196+
fi
197+
198+
exit $hadError

apps/ci/ci-compile.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
set -e
44

55
# Check for & make directories
6-
time test -d _build || mkdir _build
7-
time test -d _install || mkdir _install
6+
test -d _build || mkdir _build
7+
test -d _install || mkdir _install
88

99
# Move to build folder
10-
time cd _build
10+
cd _build
1111

1212
# Run CMake Configurations
13-
time cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DBUILD_TOOLS:BOOL=1 -DBUILD_MANGOSD:BOOL=1 -DBUILD_REALMD:BOOL=1 -DSOAP:BOOL=1 -DSCRIPT_LIB_ELUNA:BOOL=1 -DSCRIPT_LIB_SD3:BOOL=1 -DPLAYERBOTS:BOOL=1 -DUSE_STORMLIB:BOOL=1
13+
cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DBUILD_TOOLS:BOOL=1 -DBUILD_MANGOSD:BOOL=1 -DBUILD_REALMD:BOOL=1 -DSOAP:BOOL=1 -DSCRIPT_LIB_ELUNA:BOOL=1 -DSCRIPT_LIB_SD3:BOOL=1 -DPLAYERBOTS:BOOL=1 -DUSE_STORMLIB:BOOL=1
1414

1515
# Compile the Project
16-
time make -j 6
16+
make -j$(nproc)

apps/ci/ci-compiler-update.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/ci/ci-submodule-update.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)