Skip to content

Stream Windows GitHub actions output#188

Merged
moroten merged 1 commit intomainfrom
stream-windows-github-actions-output
Apr 2, 2026
Merged

Stream Windows GitHub actions output#188
moroten merged 1 commit intomainfrom
stream-windows-github-actions-output

Conversation

@moroten
Copy link
Copy Markdown
Collaborator

@moroten moroten commented Mar 31, 2026

No description provided.

@moroten moroten force-pushed the stream-windows-github-actions-output branch 5 times, most recently from 78a1067 to ba3e927 Compare April 2, 2026 08:07
@moroten
Copy link
Copy Markdown
Collaborator Author

moroten commented Apr 2, 2026

The following was useful during debugging.

# Disable VT Processing in current session, to avoid those codes to be shown
# in GitHub actions output.
$MethodDefinitions = @'
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint lpMode);

public const int STD_OUTPUT_HANDLE = -11;

public const int ENABLE_PROCESSED_OUTPUT            = 0x0001;
public const int ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
'@

$WinAPI = Add-Type -MemberDefinition $MethodDefinitions -Name 'WinAPI' -Namespace 'Win32' -PassThru
$hConsoleHandle = $WinAPI::GetStdHandle($WinAPI::STD_OUTPUT_HANDLE)
$mode=$WinAPI::ENABLE_PROCESSED_OUTPUT
$WinAPI::GetConsoleMode($hConsoleHandle, [ref]$mode)
# Remove the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.
$mode = $mode -band -bnot $WinAPI::ENABLE_VIRTUAL_TERMINAL_PROCESSING
$WinAPI::SetConsoleMode($hConsoleHandle, $mode)

Manually verified that errors are forwarded correctly in GitHub
workflows.
@moroten moroten force-pushed the stream-windows-github-actions-output branch from ba3e927 to dc8b48b Compare April 2, 2026 08:21
@moroten moroten merged commit 2a7708e into main Apr 2, 2026
2 checks passed
@moroten moroten deleted the stream-windows-github-actions-output branch April 2, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant