mirror of
https://github.com/vercel-labs/portless.git
synced 2026-09-14 16:37:59 +08:00
326e8933e4
* fix(service): disable Windows task time limit * fix(service): write task XML as UTF-16 * test(ci): match Windows task duration format * test(ci): remove temporary cuse evidence
134 lines
3.7 KiB
YAML
134 lines
3.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: .node-version
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
|
|
- run: pnpm install --frozen-lockfile
|
|
|
|
- run: pnpm format:check
|
|
|
|
- run: pnpm lint
|
|
|
|
- run: pnpm type-check
|
|
|
|
- run: pnpm build
|
|
|
|
- run: pnpm test
|
|
|
|
- run: pnpm test:e2e
|
|
|
|
ci-windows:
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: .node-version
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
|
|
- run: pnpm install --frozen-lockfile
|
|
|
|
- run: pnpm type-check
|
|
|
|
- run: pnpm build
|
|
|
|
- run: pnpm test
|
|
|
|
- name: Install and verify the Windows service
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
$stateDir = "C:\portless-ci-state"
|
|
node packages/portless/dist/cli.js service install `
|
|
--no-tls `
|
|
--port 18080 `
|
|
--state-dir $stateDir
|
|
|
|
$task = Get-ScheduledTask -TaskName "Portless Proxy"
|
|
if ([string]$task.Settings.ExecutionTimeLimit -ne "PT0S") {
|
|
throw "Expected zero execution time limit, got $($task.Settings.ExecutionTimeLimit)"
|
|
}
|
|
if ($task.Principal.UserId -notin @("SYSTEM", "S-1-5-18")) {
|
|
throw "Expected SYSTEM principal, got $($task.Principal.UserId)"
|
|
}
|
|
if ($task.Principal.RunLevel -ne "Highest") {
|
|
throw "Expected highest run level, got $($task.Principal.RunLevel)"
|
|
}
|
|
if (-not ($task.Triggers | Where-Object {
|
|
$_.CimClass.CimClassName -eq "MSFT_TaskBootTrigger"
|
|
})) {
|
|
throw "Expected a boot trigger"
|
|
}
|
|
if ($task.Actions.Execute -notmatch "(?i)cmd(\.exe)?$") {
|
|
throw "Expected cmd.exe action, got $($task.Actions.Execute)"
|
|
}
|
|
|
|
Export-ScheduledTask -TaskName "Portless Proxy" | Set-Content portless-task.xml
|
|
if ((Get-Content portless-task.xml -Raw) -notmatch "<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>") {
|
|
throw "Exported task XML does not contain PT0S"
|
|
}
|
|
|
|
$listening = $false
|
|
for ($attempt = 0; $attempt -lt 20; $attempt++) {
|
|
if (Get-NetTCPConnection -LocalPort 18080 -State Listen -ErrorAction SilentlyContinue) {
|
|
$listening = $true
|
|
break
|
|
}
|
|
Start-Sleep -Milliseconds 500
|
|
}
|
|
if (-not $listening) {
|
|
schtasks /Query /TN "Portless Proxy" /FO LIST /V
|
|
throw "Portless service did not listen on port 18080"
|
|
}
|
|
|
|
node packages/portless/dist/cli.js service status | Tee-Object service-status.txt
|
|
|
|
- name: Upload Windows service evidence
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: windows-service-evidence
|
|
path: |
|
|
portless-task.xml
|
|
service-status.txt
|
|
|
|
- name: Uninstall Windows service
|
|
if: always()
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
node packages/portless/dist/cli.js service uninstall
|