mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-01 01:52:30 +01:00
Early grep closure can reject valid GNU tools with SIGPIPE under pipefail. Drain each full version stream while preserving non-GNU and producer-failure rejection. Keep the existing native tool choices and step-local paths. Exercise streaming version output and matched producers that fail through the real fixture and timeout workflow consumers. Contract-Neutral: CI probe stream consumption changes no agent lifecycle, installer authority, native tool selection or runtime contract.
391 lines
16 KiB
YAML
391 lines
16 KiB
YAML
name: Unified Agent Native Verification
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- '.github/workflows/unified-agent-native.yml'
|
|
- 'cmd/pulse-agent/**'
|
|
- 'cmd/pulse-agent-helper/**'
|
|
- 'internal/agenthelper/**'
|
|
- 'internal/agenttls/**'
|
|
- 'internal/agentupdate/**'
|
|
- 'internal/dockeragent/**'
|
|
- 'internal/filesystemprobe/**'
|
|
- 'internal/hostagent/**'
|
|
- 'internal/kubernetesagent/**'
|
|
- 'internal/remoteconfig/**'
|
|
- 'internal/updatesignature/**'
|
|
- 'pkg/agents/**'
|
|
# Every native platform installs/builds this graph, and Windows uses its
|
|
# Vitest runtime for the generated PowerShell 5.1 install command.
|
|
- 'frontend-modern/package.json'
|
|
- 'frontend-modern/package-lock.json'
|
|
- 'frontend-modern/src/utils/agentInstallCommand.ts'
|
|
- 'frontend-modern/src/utils/__tests__/agentInstallCommand.windows.test.ts'
|
|
- 'scripts/install.sh'
|
|
- 'scripts/install.ps1'
|
|
# The Unix installer inventory also executes server/update fixtures.
|
|
# Keep direct source and Python fixture edits in native admission.
|
|
- 'install.sh'
|
|
- 'scripts/pulse-auto-update.sh'
|
|
- 'scripts/tests/test_auto_update_service_state.py'
|
|
- 'scripts/tests/test_auto_update_systemd.py'
|
|
- 'scripts/tests/test_agent_removal_systemd.py'
|
|
- 'scripts/tests/test_server_service_discovery.py'
|
|
- 'scripts/installtests/**'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- '.github/workflows/unified-agent-native.yml'
|
|
- 'cmd/pulse-agent/**'
|
|
- 'cmd/pulse-agent-helper/**'
|
|
- 'internal/agenthelper/**'
|
|
- 'internal/agenttls/**'
|
|
- 'internal/agentupdate/**'
|
|
- 'internal/dockeragent/**'
|
|
- 'internal/filesystemprobe/**'
|
|
- 'internal/hostagent/**'
|
|
- 'internal/kubernetesagent/**'
|
|
- 'internal/remoteconfig/**'
|
|
- 'internal/updatesignature/**'
|
|
- 'pkg/agents/**'
|
|
- 'frontend-modern/package.json'
|
|
- 'frontend-modern/package-lock.json'
|
|
- 'frontend-modern/src/utils/agentInstallCommand.ts'
|
|
- 'frontend-modern/src/utils/__tests__/agentInstallCommand.windows.test.ts'
|
|
- 'scripts/install.sh'
|
|
- 'scripts/install.ps1'
|
|
- 'install.sh'
|
|
- 'scripts/pulse-auto-update.sh'
|
|
- 'scripts/tests/test_auto_update_service_state.py'
|
|
- 'scripts/tests/test_auto_update_systemd.py'
|
|
- 'scripts/tests/test_agent_removal_systemd.py'
|
|
- 'scripts/tests/test_server_service_discovery.py'
|
|
- 'scripts/installtests/**'
|
|
- 'go.mod'
|
|
- 'go.sum'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
native-agent:
|
|
name: ${{ matrix.name }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: Linux x64
|
|
runner: ubuntu-24.04
|
|
unix: true
|
|
- name: Linux ARM64
|
|
runner: ubuntu-24.04-arm
|
|
unix: true
|
|
- name: macOS ARM64
|
|
runner: macos-15
|
|
unix: true
|
|
- name: macOS Intel
|
|
runner: macos-15-intel
|
|
unix: true
|
|
- name: Windows x64
|
|
runner: windows-2025
|
|
unix: false
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
# These are real manager/deletion checks, not the installer doubles. Run
|
|
# before compiler/frontend acquisition so unrelated preparation cannot
|
|
# hide Linux removal safety. Only the new public hosted runner is mutated.
|
|
- name: Check agent removal on native systemd
|
|
if: runner.os == 'Linux'
|
|
timeout-minutes: 5
|
|
env:
|
|
EXPECTED_SOURCE_SHA: ${{ github.sha }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
test "$(git rev-parse HEAD)" = "$EXPECTED_SOURCE_SHA"
|
|
git diff --exit-code HEAD
|
|
python3 -m unittest discover -s scripts/tests -p test_agent_removal_systemd.py -v
|
|
sudo env -i PATH=/usr/sbin:/usr/bin:/sbin:/bin LC_ALL=C \
|
|
GITHUB_ACTIONS=true RUNNER_ENVIRONMENT=github-hosted GITHUB_REPOSITORY=rcourtman/Pulse \
|
|
EXPECTED_SOURCE_SHA="$EXPECTED_SOURCE_SHA" RUNNER_TEMP="$RUNNER_TEMP" \
|
|
python3 scripts/installtests/agent_removal_systemd.py \
|
|
--receipt "$RUNNER_TEMP/pulse-agent-removal.json"
|
|
|
|
- name: Retain bounded native agent removal receipt
|
|
if: always() && runner.os == 'Linux'
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: native-agent-removal-${{ matrix.runner }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
path: ${{ runner.temp }}/pulse-agent-removal.json
|
|
if-no-files-found: warn
|
|
retention-days: 7
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
# These source-only checks need neither Node nor generated assets. Reject
|
|
# a broken pin before frontend acquisition/build and native runtime work;
|
|
# the complete installer inventory still runs below on passing source.
|
|
- name: Check immutable integration images before frontend preparation
|
|
if: matrix.unix
|
|
run: go test -count=1 -timeout 3m -run '^TestIntegrationContainer' ./scripts/installtests
|
|
|
|
# The complete Go installer inventory also executes Python workflow
|
|
# contracts. The runner's unversioned Python is not a wheel compatibility
|
|
# contract (ARM64 could not obtain the pinned parser). Select supported
|
|
# CPython before creating the isolated venv; never build a parser from
|
|
# source, skip the registered proof or modify the managed interpreter.
|
|
# Intel images already supply a versioned framework Python. Reuse that
|
|
# verified runtime without asking Homebrew to replace its global links;
|
|
# only acquire a formula when the versioned command is absent.
|
|
- name: Supply YAML parser for native Unix contract checks
|
|
if: runner.os == 'macOS'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if ! contract_runtime="$(command -v python3.13)"; then
|
|
brew install python@3.13
|
|
contract_runtime="$(brew --prefix python@3.13)/bin/python3.13"
|
|
fi
|
|
test -x "$contract_runtime"
|
|
"$contract_runtime" -c 'import sys; assert sys.version_info[:2] == (3, 13); print(sys.version)'
|
|
contract_python="$(mktemp -d "$RUNNER_TEMP/pulse-contract-python.XXXXXX")"
|
|
"$contract_runtime" -m venv "$contract_python"
|
|
"$contract_python/bin/python3" -m pip install \
|
|
--disable-pip-version-check --no-input --only-binary=:all: 'PyYAML==6.0.3'
|
|
"$contract_python/bin/python3" -c 'import yaml; assert yaml.__version__ == "6.0.3"'
|
|
printf '%s\n' "$contract_python/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Supply GNU timeout for macOS guidance checks
|
|
if: runner.os == 'macOS'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
brew install coreutils
|
|
# Drain version output so pipefail cannot turn early grep closure into SIGPIPE.
|
|
gnu_timeout="$(brew --prefix coreutils)/bin/gtimeout"
|
|
test -x "$gnu_timeout"
|
|
"$gnu_timeout" --version | grep -F 'GNU coreutils' > /dev/null
|
|
timeout_bin="$(mktemp -d "$RUNNER_TEMP/pulse-guidance-tools.XXXXXX")"
|
|
ln -s "$gnu_timeout" "$timeout_bin/timeout"
|
|
printf '%s\n' "$timeout_bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Verify native Unix timeout prerequisite
|
|
if: matrix.unix
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
timeout --version | grep -F 'GNU coreutils' > /dev/null
|
|
|
|
# Server/LXC fixtures execute Linux-only scripts, not a macOS installer.
|
|
# Keep their Bash/GNU metadata, archive, checksum and rename semantics local to that step;
|
|
# native macOS agent/runtime tests still use the runner's own utilities.
|
|
- name: Supply Linux server installer fixture tools on macOS
|
|
if: runner.os == 'macOS'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
brew install bash gnu-tar gawk
|
|
linux_bash="$(brew --prefix bash)/bin/bash"
|
|
test -x "$linux_bash"
|
|
"$linux_bash" -c '(( BASH_VERSINFO[0] >= 5 ))'
|
|
coreutils_bin="$(brew --prefix coreutils)/bin"
|
|
fixture_bin="$(mktemp -d "$RUNNER_TEMP/pulse-installer-fixture-tools.XXXXXX")"
|
|
ln -s "$linux_bash" "$fixture_bin/bash"
|
|
for tool in stat chmod chown cp mv ln readlink sha256sum; do
|
|
executable="$coreutils_bin/g$tool"
|
|
test -x "$executable"
|
|
"$executable" --version | grep -F 'GNU coreutils' > /dev/null
|
|
ln -s "$executable" "$fixture_bin/$tool"
|
|
done
|
|
gnu_tar="$(brew --prefix gnu-tar)/bin/gtar"
|
|
test -x "$gnu_tar"
|
|
"$gnu_tar" --version | grep -F 'GNU tar' > /dev/null
|
|
ln -s "$gnu_tar" "$fixture_bin/tar"
|
|
# The NAS boot filter rejects embedded NUL/control bytes with octal
|
|
# ranges. Use the same binary-aware awk semantics as its Linux jobs,
|
|
# not the native macOS parser, only within these server fixtures.
|
|
gnu_awk="$(brew --prefix gawk)/bin/gawk"
|
|
test -x "$gnu_awk"
|
|
"$gnu_awk" --version | grep -F 'GNU Awk' > /dev/null
|
|
ln -s "$gnu_awk" "$fixture_bin/awk"
|
|
printf 'PULSE_INSTALLER_FIXTURE_BIN=%s\n' "$fixture_bin" >> "$GITHUB_ENV"
|
|
|
|
# Observe the existing generated NAS watchdog/collector control before
|
|
# Node acquisition and the large installer inventory. The runner's two
|
|
# phases partition the same discovered checks; no check runs twice or is
|
|
# dropped, and the production process/cleanup deadlines stay unchanged.
|
|
- name: Test NAS removal contracts before frontend preparation
|
|
if: matrix.unix
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ -n "${PULSE_INSTALLER_FIXTURE_BIN:-}" ]]; then
|
|
export PATH="$PULSE_INSTALLER_FIXTURE_BIN:$PATH"
|
|
fi
|
|
python3 scripts/installtests/run_unix_contracts.py --phase preflight
|
|
|
|
- name: Set up Node.js for native runtime test assets
|
|
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
with:
|
|
node-version: '24'
|
|
cache: 'npm'
|
|
cache-dependency-path: 'frontend-modern/package-lock.json'
|
|
|
|
- name: Install frontend test dependencies
|
|
working-directory: frontend-modern
|
|
run: npm ci
|
|
|
|
- name: Build real frontend assets for API-linked native tests
|
|
working-directory: frontend-modern
|
|
run: npm run build
|
|
|
|
- name: Test native agent runtime
|
|
run: >-
|
|
go test
|
|
./cmd/pulse-agent
|
|
./internal/agenttls
|
|
./internal/agentupdate
|
|
./internal/dockeragent
|
|
./internal/hostagent
|
|
./internal/kubernetesagent
|
|
./internal/remoteconfig
|
|
|
|
# The privileged helper is Linux-only. Keep its protocol, executable
|
|
# identity and shared filesystem fences in both native Linux jobs, even
|
|
# when a change leaves the unprivileged agent's source untouched. These
|
|
# tests run as the ordinary runner user; no helper service is installed.
|
|
- name: Test native Linux helper boundaries
|
|
if: runner.os == 'Linux'
|
|
run: >-
|
|
go test -race -count=1 -timeout 5m
|
|
./cmd/pulse-agent-helper
|
|
./internal/agenthelper
|
|
./internal/filesystemprobe
|
|
./internal/updatesignature
|
|
./pkg/agents/host
|
|
|
|
- name: Build native Linux helper
|
|
if: runner.os == 'Linux'
|
|
run: go build -o pulse-agent-helper-native ./cmd/pulse-agent-helper
|
|
|
|
- name: Test native Unix installer contracts
|
|
if: matrix.unix
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ -n "${PULSE_INSTALLER_FIXTURE_BIN:-}" ]]; then
|
|
export PATH="$PULSE_INSTALLER_FIXTURE_BIN:$PATH"
|
|
fi
|
|
python3 scripts/installtests/run_unix_contracts.py --phase remaining
|
|
|
|
- name: Test native Windows installer contracts
|
|
if: ${{ !matrix.unix }}
|
|
run: go test ./scripts/installtests ./scripts/installtests/windowslifecycleserver -run '^Test(InstallPS1|WindowsAgentLifecycle|UninstallProof)'
|
|
|
|
- name: Execute generated command with Windows PowerShell 5.1
|
|
if: ${{ !matrix.unix }}
|
|
working-directory: frontend-modern
|
|
run: npm test -- --run src/utils/__tests__/agentInstallCommand.windows.test.ts
|
|
|
|
- name: Build and execute native Unix agent
|
|
if: matrix.unix
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
go build -o pulse-agent-native ./cmd/pulse-agent
|
|
./pulse-agent-native --version
|
|
./pulse-agent-native --self-test
|
|
|
|
- name: Build and execute native Windows agent
|
|
if: ${{ !matrix.unix }}
|
|
shell: pwsh
|
|
run: |
|
|
# PowerShell does not stop on native nonzero exits. Check each one
|
|
# before a later success can replace LASTEXITCODE.
|
|
go build -o pulse-agent-native.exe ./cmd/pulse-agent
|
|
if ($LASTEXITCODE -ne 0) { throw "Native Windows agent build failed (exit $LASTEXITCODE)." }
|
|
.\pulse-agent-native.exe --version
|
|
if ($LASTEXITCODE -ne 0) { throw "Native Windows agent version check failed (exit $LASTEXITCODE)." }
|
|
$selfTestStateDir = Join-Path $env:RUNNER_TEMP 'pulse-agent-self-test'
|
|
$selfTestLogFile = Join-Path $selfTestStateDir 'pulse-agent.log'
|
|
New-Item -ItemType Directory -Path $selfTestStateDir -Force | Out-Null
|
|
.\pulse-agent-native.exe --self-test --state-dir $selfTestStateDir --log-file $selfTestLogFile
|
|
if ($LASTEXITCODE -ne 0) { throw "Native Windows agent self-test failed (exit $LASTEXITCODE)." }
|
|
$errors = $null
|
|
[System.Management.Automation.Language.Parser]::ParseFile(
|
|
(Resolve-Path 'scripts/install.ps1'),
|
|
[ref]$null,
|
|
[ref]$errors
|
|
) > $null
|
|
if ($errors.Count) {
|
|
$errors | ForEach-Object { Write-Error $_.ToString() }
|
|
exit 1
|
|
}
|
|
|
|
- name: Exercise native Windows service lifecycle
|
|
if: ${{ !matrix.unix }}
|
|
shell: powershell
|
|
timeout-minutes: 10
|
|
run: |
|
|
go build -buildvcs=false -trimpath -ldflags="-s -w -X main.Version=6.0.5-ci.1" -o pulse-agent-windows-ci-1.exe ./cmd/pulse-agent
|
|
if ($LASTEXITCODE -ne 0) { throw "Windows lifecycle v1 build failed (exit $LASTEXITCODE)." }
|
|
go build -buildvcs=false -trimpath -ldflags="-s -w -X main.Version=6.0.5-ci.2" -o pulse-agent-windows-ci-2.exe ./cmd/pulse-agent
|
|
if ($LASTEXITCODE -ne 0) { throw "Windows lifecycle v2 build failed (exit $LASTEXITCODE)." }
|
|
go build -buildvcs=false -trimpath -o windows-lifecycle-server.exe ./scripts/installtests/windowslifecycleserver
|
|
if ($LASTEXITCODE -ne 0) { throw "Windows lifecycle server build failed (exit $LASTEXITCODE)." }
|
|
& ./scripts/installtests/windows_agent_lifecycle.ps1 `
|
|
-Phase Full `
|
|
-ServerBinary ./windows-lifecycle-server.exe `
|
|
-AgentV1 ./pulse-agent-windows-ci-1.exe `
|
|
-AgentV2 ./pulse-agent-windows-ci-2.exe `
|
|
-InstallerPath ./scripts/install.ps1 `
|
|
-ConfirmLifecycleMutation
|
|
if ($LASTEXITCODE -ne 0) { throw "Windows service lifecycle proof failed (exit $LASTEXITCODE)." }
|
|
|
|
freebsd-build-contract:
|
|
name: FreeBSD cross-build contract
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Compile and validate FreeBSD binaries
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
for arch in amd64 arm64; do
|
|
GOOS=freebsd GOARCH="$arch" CGO_ENABLED=0 \
|
|
go build -o "pulse-agent-freebsd-${arch}" ./cmd/pulse-agent
|
|
magic="$(od -An -tx1 -N4 "pulse-agent-freebsd-${arch}" | tr -d ' \n')"
|
|
test "$magic" = "7f454c46"
|
|
done
|
|
GOOS=freebsd GOARCH=amd64 go test -c -o agentupdate-freebsd.test ./internal/agentupdate
|