Skip to content

Commit

Permalink
jenkins: improve x64 node.exe caching for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanStojanovic committed Oct 9, 2023
1 parent c0a1bd0 commit 80eaa17
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions jenkins/scripts/windows/compile.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,32 @@ if "%nodes:~-6%" == "-arm64" (
:: thus failing the build after timing out (1-2% runs).
:: Downloading it from here and updating it weekly should
:: decrease, if not remove, these types of CI failures.
:: Download and cache x64 node.exe.
:: 1. Make the cache directory
mkdir C:\node_exe_cache
forfiles /p "C:\node_exe_cache" /m "node.exe" /d -7 /c "cmd /c del @path"
:: 2. Check if node.exe exists and if it's older then 7 days. If yes rename it to node.exe.bak
forfiles /p "C:\node_exe_cache" /m "node.exe" /d -7 /c "cmd /c ren @path node.exe.bak"
:: 3. If node.exe was older then 7 days, or it didn't exist download the new one and check it's validity
if not exist C:\node_exe_cache\node.exe (
:: 3.1. Download SHASUMS and find value for "win-x64/node.exe"
curl -L https://nodejs.org/dist/latest/SHASUMS256.txt -o C:\node_exe_cache\SHASUMS256.txt
for /f %%a in ('findstr win-x64/node.exe C:\node_exe_cache\SHASUMS256.txt') do set "VALID_SHASUM=%%a"
del C:\node_exe_cache\SHASUMS256.txt
:: 3.2. Download win-x64/node.exe and calculate its SHASUM
curl -L https://nodejs.org/dist/latest/win-x64/node.exe -o C:\node_exe_cache\node.exe
for /f %%a in ('certutil -hashfile C:\node_exe_cache\node.exe SHA256 ^| find /v ":"') do set "DOWNLOAD_SHASUM=%%a"
:: 3.3. Check if downloaded file is valid. If yes, delete backup. If not, delete it and revert backup.
if "%VALID_SHASUM%" == "%DOWNLOAD_SHASUM%" (
del C:\node_exe_cache\node.exe.bak
) else (
del C:\node_exe_cache\node.exe
ren C:\node_exe_cache\node.exe.bak node.exe
)
)
:: 4. Copy the latest valid node, if any, to where vcbuild expects it to be
if exist C:\node_exe_cache\node.exe (
mkdir temp-vcbuild
copy C:\node_exe_cache\node.exe temp-vcbuild\node-x64-cross-compiling.exe
)
:: Copy it to where vcbuild expects.
mkdir temp-vcbuild
copy C:\node_exe_cache\node.exe temp-vcbuild\node-x64-cross-compiling.exe
)
) else if "%nodes:~-4%" == "-x86" (
set "VCBUILD_EXTRA_ARGS=x86 %VCBUILD_EXTRA_ARGS%"
Expand Down

0 comments on commit 80eaa17

Please sign in to comment.