Skip to content

Commit 212a1ad

Browse files
authored
Merge 1aa9bf3 into 4a711b2
2 parents 4a711b2 + 1aa9bf3 commit 212a1ad

File tree

6 files changed

+100
-48
lines changed

6 files changed

+100
-48
lines changed

.github/workflows/core_build.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77

88
jobs:
99
build:
10+
strategy:
11+
fail-fast: false
12+
1013
runs-on: ubuntu-latest
1114

1215
steps:
@@ -20,11 +23,27 @@ jobs:
2023
- name: Install Required Packages
2124
run: sudo apt-get install -y git make cmake clang libssl-dev libbz2-dev build-essential default-libmysqlclient-dev libace-dev libreadline-dev
2225

23-
- name: Update Compilers
24-
run: source ./apps/ci/ci-compiler-update.sh
26+
- name: Install OpenSSL 3.5.1 Package Manually
27+
run: |
28+
wget https://www.openssl.org/source/openssl-3.5.1.tar.gz
29+
tar -xvf openssl-3.5.1.tar.gz
30+
cd openssl-3.5.1
31+
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
32+
make -j$(nproc)
33+
sudo make install
34+
35+
- name: Set OpenSSL 3.5.1 Environment Variables
36+
run: |
37+
echo "OPENSSL_ROOT_DIR=/usr/local/openssl" >> $GITHUB_ENV
38+
echo "OPENSSL_INCLUDE_DIR=/usr/local/openssl/include" >> $GITHUB_ENV
39+
echo "OPENSSL_LIBRARIES=/usr/local/openssl/lib" >> $GITHUB_ENV
40+
echo "/usr/local/openssl/lib" | sudo tee /etc/ld.so.conf.d/openssl-3.5.conf
41+
sudo ldconfig
2542
2643
- name: Check for Submodule Updates
27-
run: source ./apps/ci/ci-submodule-update.sh
44+
run: |
45+
git submodule init
46+
git submodule update
2847
2948
- name: Build Mangos Project
3049
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

apps/ci/ci-codestyle.sh

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

3-
set -e
4-
3+
echo
4+
echo "Checking For MaNGOS Coding Standards:"
55
echo "Starting Codestyling Script:"
66
echo
77

88
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"
9+
# Exception patterns (ignore initializer-style brace lines)
10+
["^[[: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 (valid) #ignore"
11+
12+
# General whitespace/style rules
13+
["[[:blank:]]$"]="Remove whitespace at the end of the lines"
14+
["\t"]="Replace tabs with 4 spaces in the lines"
15+
16+
# Control statements and braces
17+
["^[[:blank:]]*(if|else if|else|for|while|switch)[[:blank:]]*\(.*\)[[:blank:]]*\{[[:blank:]]*\S"]="Opening brace must be on its own line after control statement"
18+
["^[[:blank:]]*[\w:<>\*&~]+[[:blank:]]+\w+::?\w*\(.*\)[[:blank:]]*(const)?[[:blank:]]*\{[[:blank:]]*\S"]="Function opening brace must be on its own line (no code after '{')"
19+
["^\s*\S.*\}[[:blank:]]*\S.*$"]="Closing brace must be on its own line (no code before or after '}' on the line)"
20+
21+
# Brace usage enforcement
22+
["^[[:blank:]]*if[[:blank:]]*\(.*\)[[:blank:]]*$"]="if statement must use braces"
23+
["^[[:blank:]]*else[[:blank:]]*$"]="else statement must use braces"
24+
25+
# Spacing rules
26+
["\\b(if|for|while|switch|else\\s+if)\\("]="Missing space between keyword and '('"
27+
["\\)(\\{)"]="Missing space before '{'"
28+
)
29+
30+
# Ignore directories
31+
grep_exclude_args=(
32+
--exclude-dir="Eluna"
33+
--exclude-dir="Extractor_Binaries"
34+
--exclude-dir="MangosStrings_LanguageHGenerator"
35+
--exclude-dir="restart-scripts"
36+
--exclude="CMakeLists.txt"
1137
)
1238

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
39+
# Accept multiple input paths
40+
input_paths=("$@")
41+
if [[ ${#input_paths[@]} -eq 0 ]]; then
42+
input_paths=("src") # fallback
43+
fi
44+
45+
hadError=0
46+
declare -a triggeredDescriptions
47+
48+
for check in "${!singleLineRegexChecks[@]}"; do
49+
ruleDesc="${singleLineRegexChecks[$check]}"
50+
51+
# If it's a fully ignorable rule, skip early
52+
if [[ "$ruleDesc" == *"#ignore"* ]]; then
53+
continue
2054
fi
21-
done
2255

23-
# declare -A multiLineRegexChecks=(
24-
# ["\n\n\n"]="Multiple blank lines detected, keep only one. Check the files above"
25-
# )
56+
matches=$(grep -P -r -I -n "${grep_exclude_args[@]}" "${input_paths[@]}" -e "$check" 2>/dev/null)
2657

27-
# for check in ${!multiLineRegexChecks[@]}; do
28-
# echo " Checking RegEx: '${check}'"
58+
if [[ -n "$matches" ]]; then
59+
# Efficiently filter initializer list matches
60+
filteredMatches=$(printf "%s\n" "$matches" | grep -Pv '^[[: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:]]*$')
2961

30-
# if grep -Pzo -r -I ${check} src; then
31-
# echo
32-
# echo
33-
# echo "${multiLineRegexChecks[$check]}"
34-
# exit 1
35-
# fi
36-
# done
62+
if [[ -n "$filteredMatches" ]]; then
63+
echo
64+
echo "== Rule triggered: ${ruleDesc%%#*} =="
65+
echo "$filteredMatches"
66+
triggeredDescriptions+=("${ruleDesc%%#*}")
67+
hadError=1
68+
fi
69+
fi
70+
done
3771

3872
echo
39-
echo "Awesome! No issues..."
73+
echo "------------------------------------------"
74+
echo "Summary of Triggered Rules:"
75+
echo "------------------------------------------"
76+
77+
if [[ ${#triggeredDescriptions[@]} -eq 0 ]]; then
78+
echo "No style violations found."
79+
else
80+
for rule in "${triggeredDescriptions[@]}"; do
81+
echo "$rule"
82+
done
83+
fi
84+
85+
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)