Skip to content
Merged
49 changes: 49 additions & 0 deletions .github/scripts/appveyor/02-install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
REM Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
REM with MSYS2/MinGW x64. Called by AppVeyor with the build folder as current
REM directory. AppVeyor checks each line of inline yml scripts, but only the
REM exit code of a called .bat file, so we check each command here.
REM
REM Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

REM Do not give pacman cause for complaints:
C:\msys64\usr\bin\bash -lc "date -u; mkdir -p /var/cache/pacman/pkg; ls -la /"
if errorlevel 1 exit /b %ERRORLEVEL%

REM FIXME: Since Jan 2025, normal update below fails with the message:
REM installing mingw-w64-i686-gdb (16.1-1) breaks dependency
REM 'mingw-w64-i686-gdb=15.2' required by mingw-w64-i686-gdb-multiarch
REM Currently we sweep it away by removing the conflicting package:
REM C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -R mingw-w64-i686-gdb-multiarch || true"

REM FIXME: Make this update or not of the ecosystem conditional?
REM Store a copy of C:\msys64 elsewhere as a tarball?
REM As of Aug 2025, the first update is quick (15sec, 18Mb DL, 91MB installed),
REM the second is costlier (6.5min, 378MB DL, 2.5GB installed)
REM Core update (in case any core packages are outdated):
REM C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -Syuu"
REM Normal update (same command again):
REM C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -Syuu"

REM As of Aug 2025, with updates commented away above still in place
REM so many packages skipped, this step did cost additional 58MB DL,
REM 392MB installed (new data), 1min of work.
REM Without the ecosystem update above, the overhead of this step remained
REM similar. It did however use a smaller population (via deps) and older
REM versions of packages.
REM Prerequisites for NUT per https://github.com/networkupstools/nut/blob/master/docs/config-prereqs.txt :
C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain autoconf-wrapper automake-wrapper libtool mingw-w64-x86_64-libltdl gcc ccache mingw-w64-x86_64-ccache git aspell aspell-en python mingw-w64-x86_64-python-pygments mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libusb mingw-w64-x86_64-libusb-compat-git mingw-w64-x86_64-neon libneon-devel mingw-w64-x86_64-libgd mingw-w64-x86_64-cppunit mingw-w64-x86_64-nss mingw-w64-x86_64-openssl"
if errorlevel 1 exit /b %ERRORLEVEL%
REM SKIP mingw-w64-x86_64-libmodbus-git : we custom-build one with USB support
REM SKIP for now NUT-Monitor prereqs (runtime Python would require somilar modules; need to fix localization builds like "fr.po"): gettext mingw-w64-x86_64-python-pyqt6

REM FIXME: Make these stats conditional for just troubleshooting sessions?
REM It seems the first "du" call costs us about 1-2 minutes (different runs):
REM Assorted stats after package processing:
REM C:\msys64\usr\bin\bash -lc "date -u; ls -la / ; du -ksx / ; date -u; du -ks /var/cache/pacman/pkg; date -u"

REM Preserve the current working directory:
set CHERE_INVOKING=yes
REM Start a 64 bit Mingw environment:
set MSYSTEM=MINGW64
C:\msys64\usr\bin\bash -lc 'PATH="/mingw64/bin:$PATH" ; export PATH ; pwd ; ccache -sv || echo "SKIP: Could not query ccache stats" ; ccache -o sloppiness=file_macro || true ; ccache -o compression=true || true ; ccache -o max_size=750M || true '
if errorlevel 1 exit /b %ERRORLEVEL%
23 changes: 23 additions & 0 deletions .github/scripts/appveyor/03-before_build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
REM Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
REM with MSYS2/MinGW x64. Called by AppVeyor with the build folder as current
REM directory. AppVeyor checks each line of inline yml scripts, but only the
REM exit code of a called .bat file, so we check each command here.
REM
REM Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

REM NOTE: The script aims to configure for minimal build results, e.g.
REM no tools and docs, and to ensure parallel builds via MAKEFLAGS...
REM As of Aug 2025, in cases these artifacts (and ~/.ccache) were not cached
REM and the step did run, it cost us 22min (before disabling tools and docs).

REM Ensure we have a net-snmp to build against
REM Adapted from scripts/Windows/README.adoc document.
REM Here we hope to build it once, then use the
REM stashed version across Appveyor rebuilds.
REM Time limit: see CI_DEADLINE_EPOCH in appveyor.yml
REM Preserve the current working directory:
set CHERE_INVOKING=yes
REM Start a 64 bit Mingw environment:
set MSYSTEM=MINGW64
C:\msys64\usr\bin\bash -lc 'date -u; R=$(( ${CI_DEADLINE_EPOCH:-EPOCHSECONDS+3600} - EPOCHSECONDS )) ; echo "CI deadline: $R seconds left" ; if [ "$R" -le 0 ] ; then exit 124 ; fi ; export MSYS2_PATH ; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" timeout -k 30 "$R" bash ./scripts/Windows/build-mingw-prereqs.sh'
if errorlevel 1 exit /b %ERRORLEVEL%
25 changes: 25 additions & 0 deletions .github/scripts/appveyor/04-build_script.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
REM Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
REM with MSYS2/MinGW x64. Called by AppVeyor with the build folder as current
REM directory. AppVeyor checks each line of inline yml scripts, but only the
REM exit code of a called .bat file, so we check each command here.
REM
REM Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

REM Preserve the current working directory:
set CHERE_INVOKING=yes
REM Start a 64 bit Mingw environment:
set MSYSTEM=MINGW64
REM Note: currently we save job time and do not install asciidoc/a2x
REM # --with-docs="man=auto html-single=auto html-chunked=no pdf=no"
REM The resulting configuration defaults to --prefix=/mingw{32,64}
REM as appropriate for the platform, which ends up as a subdirectory
REM under DESTDIR when we `make install` later, and in our 7z archive.
REM The builds are relocatable however, so end-users can extract to
REM e.g. "C:\Program Files\NUT" and forfeit "mingwXX" part, probably,
REM but this can complicate automatic relative directory resolution
REM to find "nearby" program or configuration files (see common.c
REM for current implementation). Hard-coded fallback strings may
REM end up getting used in those cases.
REM Time limit: see CI_DEADLINE_EPOCH in appveyor.yml
C:\msys64\usr\bin\bash -lc 'date -u; R=$(( ${CI_DEADLINE_EPOCH:-EPOCHSECONDS+3600} - EPOCHSECONDS )) ; echo "CI deadline: $R seconds left" ; if [ "$R" -le 0 ] ; then exit 124 ; fi ; PATH="/mingw64/bin:$PATH" CI_SKIP_CHECK=true CANBUILD_WITH_LIBMODBUS_USB=yes WITH_LIBNUTPRIVATE=true NUT_SSL_VARIANTS=nss timeout -k 30 "$R" ./ci_build.sh --with-docs=no'
if errorlevel 1 exit /b %ERRORLEVEL%
13 changes: 13 additions & 0 deletions .github/scripts/appveyor/05-after_build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
REM Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
REM with MSYS2/MinGW x64. Called by AppVeyor with the build folder as current
REM directory. AppVeyor checks each line of inline yml scripts, but only the
REM exit code of a called .bat file, so we check each command here.
REM
REM Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

REM Preserve the current working directory:
set CHERE_INVOKING=yes
REM Start a 64 bit Mingw environment:
set MSYSTEM=MINGW64
C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" ; export PATH ; ccache -sv || ccache -s || echo "SKIP: Could not query ccache stats"'
if errorlevel 1 exit /b %ERRORLEVEL%
18 changes: 18 additions & 0 deletions .github/scripts/appveyor/07-test_script.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
REM Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
REM with MSYS2/MinGW x64. Called by AppVeyor with the build folder as current
REM directory. AppVeyor checks each line of inline yml scripts, but only the
REM exit code of a called .bat file, so we check each command here.
REM
REM Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

REM Preserve the current working directory:
set CHERE_INVOKING=yes
REM Start a 64 bit Mingw environment:
set MSYSTEM=MINGW64
REM Time limits: see CI_DEADLINE_EPOCH in appveyor.yml
REM Start Mingw-based integration and unit checks:
C:\msys64\usr\bin\bash -lc 'date -u; R=$(( ${CI_DEADLINE_EPOCH:-EPOCHSECONDS+3600} - EPOCHSECONDS )) ; echo "CI deadline: $R seconds left" ; if [ "$R" -le 0 ] ; then exit 124 ; fi ; NUT_STATEPATH="C:\\Users\\appveyor\\AppData\\Local\\Temp\\nut-test"; mkdir -p "${NUT_STATEPATH}"; export NUT_STATEPATH; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" timeout -k 30 "$R" make -s check || bash -lc "for F in tests/*.log tests/*.trs ; do echo \"===---=== $F :\"; cat \"$F\"; done; exit 1;" '
if errorlevel 1 exit /b %ERRORLEVEL%
REM Start a Mingw-based documentation spellcheck (note that "make check" above could cover some documents in path of artifact delivery, but maybe not all that we have):
C:\msys64\usr\bin\bash -lc 'date -u; R=$(( ${CI_DEADLINE_EPOCH:-EPOCHSECONDS+3600} - EPOCHSECONDS )) ; echo "CI deadline: $R seconds left" ; if [ "$R" -le 0 ] ; then exit 124 ; fi ; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" timeout -k 30 "$R" make -s -j 8 spellcheck'
if errorlevel 1 exit /b %ERRORLEVEL%
32 changes: 32 additions & 0 deletions .github/scripts/appveyor/08-after_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
REM Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
REM with MSYS2/MinGW x64. Called by AppVeyor with the build folder as current
REM directory. AppVeyor checks each line of inline yml scripts, but only the
REM exit code of a called .bat file, so we check each command here.
REM
REM Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

REM Preserve the current working directory:
set CHERE_INVOKING=yes
REM Start a 64 bit Mingw environment:
set MSYSTEM=MINGW64
REM Oh the joys of shell scripting with strings passed through CMD:
REM Note: currently Python installation path with MSYS is buggy [#1584]
REM Time limit: see CI_DEADLINE_EPOCH in appveyor.yml
C:\msys64\usr\bin\bash -lc 'date -u; R=$(( ${CI_DEADLINE_EPOCH:-EPOCHSECONDS+3600} - EPOCHSECONDS )) ; echo "CI deadline: $R seconds left" ; if [ "$R" -le 0 ] ; then exit 124 ; fi ; set -e ; if ! rm -rf ".inst" ; then echo "WARNING: Failed to clean away .inst" ; fi ; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" timeout -k 30 "$R" make -s -j 8 install-win-bundle DESTDIR="`pwd`/.inst/NUT-for-Windows-x86_64-SNAPSHOT-%APPVEYOR_BUILD_VERSION%"'
if errorlevel 1 exit /b %ERRORLEVEL%
C:\msys64\usr\bin\bash -lc 'date -u; set -e ; rm -rf ./.inst/NUT-for-Windows-x86_64-SNAPSHOT || true ; ln -fs "NUT-for-Windows-x86_64-SNAPSHOT-%APPVEYOR_BUILD_VERSION%" ./.inst/NUT-for-Windows-x86_64-SNAPSHOT ; ( cd .inst/NUT-for-Windows-x86_64-SNAPSHOT ; find . -ls ; )'
if errorlevel 1 exit /b %ERRORLEVEL%
C:\msys64\usr\bin\bash -lc 'date -u'
pushd .inst
if errorlevel 1 exit /b %ERRORLEVEL%
REM 7z -snh: hoping for a version that can save hardlinks as such, and in 7z format to boot:
7z a -snh ../NUT-for-Windows-x86_64-SNAPSHOT-%APPVEYOR_BUILD_VERSION%.7z NUT*
if errorlevel 1 exit /b %ERRORLEVEL%
popd

REM Report ccache stats (here rather than in a separate yml step after the
REM artifact message in 08-after_test.ps1, the order does not matter):
C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" ; export PATH ; ccache -sv || ccache -s || echo "SKIP: Could not query ccache stats"'
if errorlevel 1 exit /b %ERRORLEVEL%
C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" ; export PATH ; ccache -x || echo "SKIP: Could not query ccache compression stats"'
if errorlevel 1 exit /b %ERRORLEVEL%
11 changes: 11 additions & 0 deletions .github/scripts/appveyor/08-after_test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Network UPS Tools: AppVeyor CI recipe step (see appveyor.yml), NUT for Windows
# with MSYS2/MinGW x64: report a link to the built archive in the job messages.
#
# Copyright (C) 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>

# Consider APPVEYOR_PULL_REQUEST_HEAD_COMMIT (PR) vs APPVEYOR_REPO_COMMIT (target branch, or ephemeral)
$nut7z = "NUT-for-Windows-x86_64-SNAPSHOT-$($env:APPVEYOR_BUILD_VERSION).7z"
$msg = "A 7-zip archive with built NUT for Windows debug binaries is temporarily available: [$($nut7z)]($($env:APPVEYOR_URL)/api/buildjobs/$($env:APPVEYOR_JOB_ID)/artifacts/$($nut7z))"
echo $msg
echo "build-id:$($env:APPVEYOR_BUILD_ID) job-id:$($env:APPVEYOR_JOB_ID) prj-id:$($env:APPVEYOR_PROJECT_ID)"
Add-AppveyorMessage $msg
Loading
Loading