#!/usr/bin/bash # crude-ci - build new Emacs binaries for windows after commits6 # # Copyright 2026 Corwin Brust # # This program is distributed under the terms of the GNU Public # License version 3 or (at your option) any later version. # test -n "$DEBUG" && set -x # most likely things to edit SLEEP_TIME=${SLEEP_TIME-17} # if truthy, try to rebuild tree-sitter grammers also # NO_TS=${NO_TS-1} # number of loops between tree sitter project checks TS_WAIT=$((17 * 60)) LK_WAIT=$((17 * 60)) EC=${EC:-"$( echo "$MSYSTEM" | grep UCRT64 )"} EU=${EU:-"$(test -n "$EC" && printf '%s' "-ucrt")"} # the name the current master branch will have when it becomes the release branch MASTER=emacs$EU-32 # webpage with the head-revision of a given branch BASE_URI=$( printf '%s://%s/%s?project=%s&property=%s&' \ 'https' \ 'test.comic.chat' \ 'last-rev.pl' \ 'emacs' \ 'revision' ) # counter runs_since_last_ts=$TS_WAIT LOCKFILE=/g/.crude-ci.lock if test -r $LOCKFILE ; then echo "ERROR: cannot start while lockfile exists, try:\n\trm $LOCKFILE"; exit 1; fi # the .private file exports SSH_KEY and SSH_USER, needed for rsync if [[ -r /g/.private ]] ; then . /g/.private else echo "Private settings missing"; exit 1; fi sleep 10; while true ; do if test -r $LOCKFILE ; then echo -e "\e[1;6m$( date +'%Y-%m-%d %H:%M' ) Build in process. Trying again in $LK_WAIT seconds..\e[0m" sleep $LK_WAIT continue fi # maybe rebuild tree-sitter grammers # NOTE: only build TS grammers under MSYS54 for now if test -z "$NO_TS" && test -z "$EC" ; then runs_since_last_ts=$((1+ runs_since_last_ts)) if [[ $runs_since_last_ts > $TS_WAIT ]] ; then touch $LOCKFILE echo -e "\e[1;2m$( date +'%Y-%m-%d %H:%M' ) Checking treesitter projects...\e[0m" runs_since_last_ts=$((0)); /g/emacs-local-ci/build-tree-sitter.sh rm $LOCKFILE fi fi for VER in 32 31 ; do branch_folder_name=emacs$EU-$VER cd /g/git/$branch_folder_name # special case name of the master branch branch_name=emacs-$VER #$branch_folder_name if [[ $MASTER -eq $branch_folder_name ]] ; then branch_name=master branch_color=35 else branch_color=36 fi # echo "checking Emacs branche $branch_name for changes..." local_rev=$( git rev-parse HEAD ) echo "Fetching... ${BASE_URI}&branch=${branch_name}" remote_rev=$( wget -qO - $BASE_URI'&'branch=$branch_name ); if [[ "$local_rev" != "$remote_rev" ]] ; then local_color=33 else local_color=32 fi echo -e "\e[1;2m$( date +'%Y-%m-%d %H:%M' )\e[0m " \ "\e[1;${branch_color}m$branch_folder_name\e[0m " \ "\e[1;2mhave:\e[0m\e[1;32m${local_rev:0:6}\e[0m " \ "\e[1;2mwant:\e[0m\e[1;${local_color}m${remote_rev:0:6}\e[0m" if [[ -n $FORCE ]] || [[ "$local_rev" != "$remote_rev" ]] ; then touch $LOCKFILE # wait, in case of slow trickle of related commits if [[ -z $FORCE ]] ; then echo "pausing for $SLEEP_TIME seconds.."; sleep $SLEEP_TIME; fi echo "GIT: pull --rebase .." git pull --rebase; new_rev=$( git rev-parse HEAD ); new_rev_short=${new_rev:0:6}; (set -x; MV=$VER /g/emacs-local-ci/build-dist.sh; )2>&1 | tee -a /g/log/${branch_folder_name}-$new_rev_short-`date +%Y-%m-%d-%H%M`.log problems=`(/g/emacs-local-ci/check-feature.pl ${branch_folder_name}-$new_rev_short; /g/emacs-local-ci/check-log.sh ${branch_folder_name}) | grep NOT | cut -d ' ' -f 1,4 | perl -e 'END{ print join q(, ), @a }' -ne 's/\s+/ /msg; push @a, $_ if length'`; if [[ -n $problems ]] ; then health="dubious: $problems"; else health="OK" fi if [[ -n $CC_SSH_KEY ]] && [[ -n $CC_SSH_USER ]] && [[ -n $CC_SSH_HOST ]] ; then #last_up="$( basename $( ls -1td /h/upload/$branch_folder_name* | head -1 ) )" BUILD_URI="https://corwin.bru.st/$branch_folder_name/$branch_folder_name-$new_rev_short" ssh -i "$CC_SSH_KEY" "$CC_SSH_USER@$CC_SSH_HOST" \ "echo '#emacs-dev [$branch_name@$new_rev_short] `uname -o` build $health $BUILD_URI (`hostname`)' >>/petroglyph/udp2irc/gliphy.fifo" fi rm $LOCKFILE fi done FORCE= powershell /g/emacs-local-ci/fix-shortcut.ps1 sleep ${SLEEP_TIME} done