-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·145 lines (130 loc) · 3.31 KB
/
run.sh
File metadata and controls
executable file
·145 lines (130 loc) · 3.31 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
140
141
142
143
144
145
#!/bin/bash
function print {
GREEN="\033[0;32m"
RESET="\033[0m"
echo -e "${GREEN}$1${RESET}"
}
BUILD=0
CI=0
INSTALL_VENV=0
SPELL=0
ACT=''
ALL=0
SOURCES=''
ARGS=''
SPELL_ARGS=''
while [ $# -gt 0 ] ; do
case $1 in
-b)
BUILD=1
;;
--ci)
CI=1
;;
--install-venv)
INSTALL_VENV=1
;;
--spell)
BUILD=1
SPELL=1
ARGS="$ARGS --clean"
;;
--source | -S)
SOURCES="$SOURCES -S $2"
shift
;;
--all)
ALL=1
;;
--act)
ACT=$2
if [ -z "$ACT" ]; then
print "Missing workflow name."
exit 1
fi
shift
;;
*)
ARGS="$ARGS $1"
;;
esac
shift
done
if [ -n "$ACT" ]; then
if ! which act 2>/dev/null; then
print "act not found."
exit 1
fi
if [ ! -f ".github/workflows/$ACT" ]; then
print "Workflow $ACT not found."
exit 1
fi
act -W .github/workflows/$ACT
exit
fi
if [ ! -d "venv" ]; then
INSTALL_VENV=1
print "Virtual environment not found."
fi
if [ $INSTALL_VENV -eq 1 ]; then
if [ -d "venv" ]; then
print "Removing existing virtual environment..."
rm -rf venv
fi
print "Installing virtual environment..."
python3 -m venv venv
print "Installing dependencies"
./venv/bin/pip install -r requirements.txt
fi
source venv/bin/activate
COMMAND="serve"
if [ $BUILD -eq 1 ]; then
COMMAND="build"
fi
if [ $CI -eq 0 ]; then
mkdocs $COMMAND $ARGS
else
CI=true mkdocs $COMMAND $ARGS
fi
if [ $? -ne 0 ]; then
print "Error building site."
exit 1
fi
if [ $SPELL -eq 1 ]; then
export DICPATH=.hunspell/
print "Checking spelling..."
mkdir -p .hunspell
if ! python -c 'import pyspelling' 2>/dev/null; then
print "Installing pyspelling..."
pip install pyspelling
fi
if [ ! -f .hunspell/ca_ES_valencia.dic ]; then
print "Downloading ca_ES_valencia dictionary..."
curl -L https://raw.githubusercontent.com/Softcatala/catalan-dict-tools/refs/heads/master/resultats/hunspell/catalan-valencia.dic -o .hunspell/ca_ES_valencia.dic
fi
if [ ! -f .hunspell/ca_ES_valencia.aff ]; then
print "Downloading ca_ES_valencia affix file..."
curl -L https://raw.githubusercontent.com/Softcatala/catalan-dict-tools/refs/heads/master/resultats/hunspell/catalan-valencia.aff -o .hunspell/ca_ES_valencia.aff
fi
if [ $ALL -eq 0 ]; then
if [ -z "$SOURCES" ]; then
CHANGED_FILES=$(git diff --name-only main HEAD | grep '\.md$' | sed 's/docs/site/' | sed 's/.md$/\/index.html/')
if [ -z "$CHANGED_FILES" ]; then
print "No changes found."
exit
fi
for FILE in $CHANGED_FILES; do
if [ -f $FILE ]; then
SOURCES="$SOURCES -S $FILE"
fi
done
fi
SPELL_ARGS="$SPELL_ARGS --name mkdocs $SOURCES"
fi
print "Running pyspelling..."
echo "pyspelling $SPELL_ARGS"
pyspelling $SPELL_ARGS | tee pyspelling.log
if [ ${PIPESTATUS[0]} -ne 0 ]; then
less pyspelling.log
fi
fi