feat: publish verifiable proxyctl v1
This commit is contained in:
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
repo=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT HUP INT TERM
|
||||
home="$work/home"
|
||||
config="$work/config"
|
||||
state="$work/state"
|
||||
bin="$work/bin"
|
||||
mkdir -p "$home" "$config" "$state" "$bin"
|
||||
|
||||
snapshot_host() {
|
||||
for path in \
|
||||
"$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.docker/config.json" \
|
||||
/etc/apt/apt.conf.d/99proxyctl /etc/docker/daemon.json \
|
||||
/var/lib/proxyctl/docker-daemon.json
|
||||
do
|
||||
if [ -r "$path" ]; then
|
||||
sha256sum "$path"
|
||||
elif [ -e "$path" ]; then
|
||||
ls -ld "$path"
|
||||
else
|
||||
printf 'absent %s\n' "$path"
|
||||
fi
|
||||
done
|
||||
if command -v gsettings >/dev/null 2>&1; then
|
||||
gsettings get org.gnome.system.proxy mode 2>&1 || true
|
||||
else
|
||||
printf 'gsettings absent\n'
|
||||
fi
|
||||
}
|
||||
|
||||
snapshot_host >"$work/host-before"
|
||||
|
||||
(
|
||||
cd "$repo"
|
||||
GOFLAGS='-mod=readonly' GOBIN="$bin" go install ./cmd/proxyctl
|
||||
)
|
||||
test "$("$bin/proxyctl" version --short)" != ""
|
||||
mv "$bin/proxyctl" "$bin/proxyctl-production"
|
||||
(
|
||||
cd "$repo"
|
||||
GOFLAGS='-mod=readonly -tags=proxyctl_process_test' GOBIN="$bin" go install ./cmd/proxyctl
|
||||
go test ./internal/app -run 'TestUserCanCreateAndActivatePersistentSingleProxyProfile|TestApplicationCoordinatesMultipleRealAndFakeHermeticAdaptersThroughPartialFailure' -count=1
|
||||
)
|
||||
|
||||
env_run() {
|
||||
env -i \
|
||||
PATH="$PATH" HOME="$home" XDG_CONFIG_HOME="$config" XDG_STATE_HOME="$state" \
|
||||
SHELL=/bin/bash PROXYCTL_PROCESS_TEST_HOME="$home" \
|
||||
"$bin/proxyctl" "$@"
|
||||
}
|
||||
|
||||
test "$(env_run version --short)" != ""
|
||||
doctor_output=$(env_run doctor 2>&1 || true)
|
||||
printf '%s\n' "$doctor_output" | grep -q 'Profile validity'
|
||||
printf 'no\n' | env_run reset | grep -q 'Reset cancelled'
|
||||
printf 'yes\n' | env_run reset | grep -q 'shell: skipped (Disabled)'
|
||||
env_run shell install | grep -q 'installed'
|
||||
grep -q 'proxyctl shell integration' "$home/.bashrc"
|
||||
env_run shell uninstall | grep -q 'uninstalled'
|
||||
if grep -q 'proxyctl shell integration' "$home/.bashrc"; then
|
||||
echo 'Shell integration remained after uninstall' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm "$bin/proxyctl" "$bin/proxyctl-production"
|
||||
test ! -e "$bin/proxyctl"
|
||||
test ! -e "$bin/proxyctl-production"
|
||||
snapshot_host >"$work/host-after"
|
||||
cmp "$work/host-before" "$work/host-after"
|
||||
|
||||
printf 'clean-machine verification passed: go install, Profile workflow, hermetic Target workflow, doctor, reset cancellation/confirmation, Shell install/uninstall, binary removal, and unchanged host state\n'
|
||||
Reference in New Issue
Block a user