diff --git a/.github/workflows/nano-server.yml b/.github/workflows/nano-server.yml new file mode 100644 index 00000000000..597fc213de0 --- /dev/null +++ b/.github/workflows/nano-server.yml @@ -0,0 +1,35 @@ +name: Windows Nano Server tests + +on: [workflow_dispatch, push] + +jobs: + test-nano-server: + if: github.event.repository.fork == false || github.event_name == 'workflow_dispatch' + runs-on: windows-2022 + env: + REF: ${{github.ref}} + WINDBG_DIR: "C:/Program Files (x86)/Windows Kits/10/Debuggers/x64" + IMAGE: mcr.microsoft.com/powershell:nanoserver-ltsc2022 + + steps: + - name: partial clone + shell: bash + run: | + # cannot use `git clone` directly, to allow for PR's refs to be fetched + git clone --no-checkout --single-branch -b ${REF#refs/heads/} --filter=blob:none --depth=1 \ + https://github.com/${{github.repository}} . && + git sparse-checkout set .github/workflows mingw64/bin && + git checkout HEAD + - name: pull nanoserver image + shell: bash + run: docker pull $IMAGE + - name: run nano-server test + shell: bash + run: | + docker pull $IMAGE + docker run \ + --user "ContainerAdministrator" \ + -v "$WINDBG_DIR:C:/dbg" \ + -v "$(cygpath -aw mingw64/bin):C:/test" \ + -v "$(cygpath -aw .github/workflows/nano-server):C:/script" \ + $IMAGE pwsh.exe C:/script/run-tests.ps1 diff --git a/.github/workflows/nano-server/run-tests.ps1 b/.github/workflows/nano-server/run-tests.ps1 new file mode 100644 index 00000000000..da91b26c564 --- /dev/null +++ b/.github/workflows/nano-server/run-tests.ps1 @@ -0,0 +1,34 @@ +# Each exectuable to test is run with the `version` subcommand; It is +# expected to return with exit code 0. + +$executables_to_test = @( + 'C:\test\git.exe', + 'C:\test\scalar.exe' +) + +foreach ($executable in $executables_to_test) +{ + Write-Output "Now testing $($executable)" + &$executable 'version' + if ($LASTEXITCODE -ne 0) { + # If the command failed, run the debugger to find out what function or + # DLL could not be found and then exit the script with failure. The + # missing DLL or EXE will be referenced near the end of the output + + # Set flag to ask the debugger to + # - show loader stub dianostics, + # - enable system critical breaks, + # - stop on exception, and + # - stop on unhandled user-mode exception + # + # For further details, see + # https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags-flag-table + C:\dbg\gflags -i $executable +SLS +SCB +SOE +SUE + + C:\dbg\cdb.exe -c "g" -c "q" $executable 'version' + + exit 1 + } +} + +exit 0