Skip to content

Commit

Permalink
update.sh: make this much more verbose
Browse files Browse the repository at this point in the history
also create a separate log file for the current build
  • Loading branch information
peterbarker committed Jan 29, 2025
1 parent a3d5bf1 commit e7de502
Showing 1 changed file with 51 additions and 26 deletions.
77 changes: 51 additions & 26 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,49 @@ lock_file build.lck || {
exit 1
}

progress() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] update.sh: $*"
}

LOGFILE="logs/update-latest.log"
progress "update.sh starting (see $LOGFILE)"

test -n "$FORCEBUILD" || {
(cd ardupilot_wiki && git fetch > /dev/null 2>&1)
(cd sphinx_rtd_theme && git fetch > /dev/null 2>&1)
progress "Fetching ardupilot_wiki"
(cd ardupilot_wiki && git fetch)
progress "Fetching sphinx_rtd_theme"
(cd sphinx_rtd_theme && git fetch)

changed=0
progress "Getting oldhash for ardupilot_wiki"
oldhash=$(cd ardupilot_wiki && git rev-parse origin/master)
progress "Getting newhash for ardupilot_wiki"
newhash=$(cd ardupilot_wiki && git rev-parse HEAD)
[ "$oldhash" = "$newhash" ] || {
echo "ardupilot_wiki has changed $newhash $oldhash"
progress "ardupilot_wiki has changed $newhash $oldhash"
changed=1
}

progress "Getting oldhash for sphinx_rtd_theme"
oldhash=$(cd sphinx_rtd_theme && git rev-parse origin/master)
progress "Getting newhash for sphinx_rtd_theme"
newhash=$(cd sphinx_rtd_theme && git rev-parse HEAD)
[ "$oldhash" = "$newhash" ] || {
echo "sphinx_rtd_theme has changed $newhash $oldhash"
progress "sphinx_rtd_theme has changed $newhash $oldhash"
changed=1
}

progress "Fetching parameters"
PARAMSITES="ArduPlane ArduCopter AntennaTracker Rover AP_Periph Blimp"
mkdir -p old_params new_params
for site in $PARAMSITES; do
wget "https://autotest.ardupilot.org/Parameters/$site/Parameters.rst" -O new_params/$site.rst 2> /dev/null
wget "https://autotest.ardupilot.org/Parameters/$site/Parameters.rst" -O new_params/$site.rst
done

progress "Comparing parameters"
for site in $PARAMSITES; do
if ! cmp new_params/$site.rst old_params/$site.rst; then
echo "$site.rst has changed"
progress "$site.rst has changed"
cp new_params/$site.rst old_params/$site.rst
changed=1
fi
Expand All @@ -71,30 +86,29 @@ test -n "$FORCEBUILD" || {
LOGMESSAGESITES="Plane Copter Tracker Rover Blimp"
mkdir -p old_logmessages new_logmessages
for site in $LOGMESSAGESITES; do
wget "https://autotest.ardupilot.org/LogMessages/$site/LogMessages.rst" -O new_logmessages/$site.rst 2> /dev/null
wget "https://autotest.ardupilot.org/LogMessages/$site/LogMessages.rst" -O new_logmessages/$site.rst
done

for site in $LOGMESSAGESITES; do
if ! cmp new_logmessages/$site.rst old_logmessages/$site.rst; then
echo "$site.rst has changed"
progress "$site.rst has changed"
cp new_logmessages/$site.rst old_logmessages/$site.rst
changed=1
fi
done

[ $changed = 1 ] || exit 0
[ $changed = 1 ] || {
progress "Nothing changed; no rebuild required, exiting"
exit 0
}
}

progress "update.sh starting build"

(
date

report() {
cat <<EOF | mail -s 'wiki build failed' [email protected]
A wiki build failed
EOF
}

echo "[Buildlog] Updating ardupilot_wiki at $(date '+%Y-%m-%d-%H-%M-%S')"
progress "Updating ardupilot_wiki"
pushd ardupilot_wiki
git checkout -f master
git fetch origin
Expand All @@ -103,7 +117,7 @@ git reset --hard origin/master
git clean -f -f -x -d -d
popd

echo "[Buildlog] Updating sphinx_rtd_theme at $(date '+%Y-%m-%d-%H-%M-%S')"
progress "Updating sphinx_rtd_theme"
pushd sphinx_rtd_theme
git checkout -f master
git fetch origin
Expand All @@ -120,26 +134,37 @@ END_UPDATES=$(date +%s)

DO_PARAM_VERSIONING=true
if $DO_PARAM_VERSIONING; then
echo "[Buildlog] Starting to build multiple parameters pages at $(date '+%Y-%m-%d-%H-%M-%S')"
python3 build_parameters.py
progress "Starting to build multiple parameters pages"
python3 build_parameters.py || {
progress "build_parameters.py failed"
exit 1
}
END_BUILD_MPARAMS=$(date +%s)
MPARAMS_TIME=$(echo "($END_BUILD_MPARAMS - $END_UPDATES)" | bc)
echo "[Buildlog] Time to run build_parameters.py: $MPARAMS_TIME seconds"
progress "Time to run build_parameters.py: $MPARAMS_TIME seconds"
else
# we use this hwne calculating times, below
END_BUILD_MPARAMS=$END_UPDATES
fi

echo "[Buildlog] Starting to build the wiki at $(date '+%Y-%m-%d-%H-%M-%S')"
progress "Starting to build the wiki"
# python3 update.py --clean --parallel 4 # Build without versioning for parameters. It is better for editing wiki.
python3 update.py --destdir /var/sites/wiki/web --clean --paramversioning --parallel 4 --enablebackups --verbose # Enables parameters versioning and backups, should be used only on the wiki server

python3 update.py --destdir /var/sites/wiki/web --clean --paramversioning --parallel 1 --enablebackups --verbose || {
progress "update.py failed"
exit 1
}

END_BUILD_WIKI=$(date +%s)
WIKI_TIME=$(echo "($END_BUILD_WIKI - $END_BUILD_MPARAMS)/60" | bc)
echo "[Buildlog] Time to build the wiki itself: $WIKI_TIME minutes"
progress "Time to build the wiki itself: $WIKI_TIME minutes"
SCRIPT_TIME=$(echo "($END_BUILD_WIKI - $START)/60" | bc)
echo "[Buildlog] Time to run the full script: $SCRIPT_TIME minutes"
progress "Time to run the full script: $SCRIPT_TIME minutes"


) >$LOGFILE 2>&1 || {
progress "update.sh failed; see $LOGFILE"
}

cat $LOGFILE >> logs/update.log

) >> update.log 2>&1
progress "update.sh finished"

0 comments on commit e7de502

Please sign in to comment.