forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_build.sh
More file actions
executable file
·139 lines (122 loc) · 4.22 KB
/
check_build.sh
File metadata and controls
executable file
·139 lines (122 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
echo "======================================"
echo "Local Build Check (GitHub Actions Simulation)"
echo "======================================"
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Track overall status
BUILD_SUCCESS=true
echo "1. Checking for unnecessary using directives (IDE0005)..."
echo "---------------------------------------------------"
if dotnet build -c Release src/SourceGit.csproj -warnaserror:IDE0005 > /tmp/build_ide0005.log 2>&1; then
echo -e "${GREEN}✅ No IDE0005 errors found${NC}"
else
echo -e "${RED}❌ IDE0005 errors detected:${NC}"
grep "error IDE0005" /tmp/build_ide0005.log
BUILD_SUCCESS=false
fi
echo ""
echo "2. Running full Release build..."
echo "--------------------------------"
if dotnet build -c Release src/SourceGit.csproj > /tmp/build_release.log 2>&1; then
echo -e "${GREEN}✅ Release build successful${NC}"
WARNINGS=$(grep -c "warning" /tmp/build_release.log 2>/dev/null || echo "0")
if [ "$WARNINGS" -gt "0" ]; then
echo -e "${YELLOW}⚠️ Build has $WARNINGS warnings${NC}"
fi
else
echo -e "${RED}❌ Release build failed${NC}"
grep -E "error" /tmp/build_release.log | head -10
BUILD_SUCCESS=false
fi
echo ""
echo "3. Checking code analysis rules..."
echo "-----------------------------------"
# Check with all code analysis rules that GitHub Actions uses
if dotnet build -c Release src/SourceGit.csproj \
-warnaserror:IDE0005 \
-warnaserror:CS8600 \
-warnaserror:CS8602 \
-warnaserror:CS8604 \
-warnaserror:CS8618 \
-warnaserror:CS8625 \
-p:TreatWarningsAsErrors=false \
> /tmp/build_analysis.log 2>&1; then
echo -e "${GREEN}✅ Code analysis passed${NC}"
else
echo -e "${RED}❌ Code analysis failed:${NC}"
grep -E "error" /tmp/build_analysis.log | head -10
BUILD_SUCCESS=false
fi
echo ""
echo "4. Checking for common issues..."
echo "---------------------------------"
# Check for tabs vs spaces issues
TAB_FILES=$(find src -name "*.cs" -exec grep -l $'\t' {} \; 2>/dev/null | wc -l)
if [ "$TAB_FILES" -eq 0 ]; then
echo -e "${GREEN}✅ No tab/space issues${NC}"
else
echo -e "${YELLOW}⚠️ $TAB_FILES files contain tabs${NC}"
fi
# Check for BOM issues
BOM_FILES=$(find src -name "*.cs" -exec file {} \; | grep -c "with BOM" || echo "0")
if [ "$BOM_FILES" -eq 0 ]; then
echo -e "${GREEN}✅ No BOM issues${NC}"
else
echo -e "${YELLOW}⚠️ $BOM_FILES files have BOM${NC}"
fi
# Check for line ending issues (CRLF vs LF)
CRLF_FILES=$(find src -name "*.cs" -exec file {} \; | grep -c "CRLF" || echo "0")
echo -e "${YELLOW}ℹ️ $CRLF_FILES files use CRLF line endings${NC}"
echo ""
echo "5. Test compilation for all platforms..."
echo "-----------------------------------------"
# Test Windows build
echo -n "Windows (win-x64): "
if dotnet publish src/SourceGit.csproj -c Release -r win-x64 --self-contained -o /tmp/test-win > /dev/null 2>&1; then
echo -e "${GREEN}✅${NC}"
else
echo -e "${RED}❌${NC}"
BUILD_SUCCESS=false
fi
# Test macOS build
echo -n "macOS (osx-arm64): "
if dotnet publish src/SourceGit.csproj -c Release -r osx-arm64 --self-contained -o /tmp/test-osx > /dev/null 2>&1; then
echo -e "${GREEN}✅${NC}"
else
echo -e "${RED}❌${NC}"
BUILD_SUCCESS=false
fi
# Test Linux build
echo -n "Linux (linux-x64): "
if dotnet publish src/SourceGit.csproj -c Release -r linux-x64 --self-contained -o /tmp/test-linux > /dev/null 2>&1; then
echo -e "${GREEN}✅${NC}"
else
echo -e "${RED}❌${NC}"
BUILD_SUCCESS=false
fi
# Cleanup temp directories
rm -rf /tmp/test-win /tmp/test-osx /tmp/test-linux 2>/dev/null
echo ""
echo "======================================"
if [ "$BUILD_SUCCESS" = true ]; then
echo -e "${GREEN}✅ ALL CHECKS PASSED!${NC}"
echo "Ready to commit and push to GitHub."
else
echo -e "${RED}❌ SOME CHECKS FAILED!${NC}"
echo "Please fix the issues before pushing to GitHub."
echo ""
echo "To see detailed errors, check:"
echo " /tmp/build_ide0005.log"
echo " /tmp/build_release.log"
echo " /tmp/build_analysis.log"
fi
echo "======================================"
# Exit with error if build failed
if [ "$BUILD_SUCCESS" = false ]; then
exit 1
fi