workstation-v0: add Lampstand user-service subcommands #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: workstation-lampstand | ||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'profiles/linux-dev/workstation-v0/bin/install-lampstand.sh' | ||
| - 'profiles/linux-dev/workstation-v0/bin/sourceos-search.sh' | ||
| - 'profiles/linux-dev/workstation-v0/manifest.yaml' | ||
| - '.github/workflows/workstation-lampstand.yml' | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'profiles/linux-dev/workstation-v0/bin/install-lampstand.sh' | ||
| - 'profiles/linux-dev/workstation-v0/bin/sourceos-search.sh' | ||
| - 'profiles/linux-dev/workstation-v0/manifest.yaml' | ||
| - '.github/workflows/workstation-lampstand.yml' | ||
| jobs: | ||
| lampstand-installer-smoke: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Syntax check installer and helper | ||
| run: | | ||
| set -euo pipefail | ||
| bash -n profiles/linux-dev/workstation-v0/bin/install-lampstand.sh | ||
| bash -n profiles/linux-dev/workstation-v0/bin/sourceos-search.sh | ||
| - name: Smoke: installer writes user service with stub pipx | ||
| run: | | ||
| set -euo pipefail | ||
| tmp_home=$(mktemp -d) | ||
| tmp_bin=$(mktemp -d) | ||
| tmp_src=$(mktemp -d) | ||
| printf '[project]\nname = "lampstand"\n' > "$tmp_src/pyproject.toml" | ||
| cat > "$tmp_bin/pipx" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| test "${1:-}" = install | ||
| mkdir -p "$HOME/.local/bin" | ||
| cat > "$HOME/.local/bin/lampstandd" <<'EOS' | ||
| #!/usr/bin/env bash | ||
| exit 0 | ||
| EOS | ||
| chmod +x "$HOME/.local/bin/lampstandd" | ||
| EOF | ||
| chmod +x "$tmp_bin/pipx" | ||
| HOME="$tmp_home" \ | ||
| XDG_CONFIG_HOME="$tmp_home/.config" \ | ||
| SOURCEOS_LAMPSTAND_SRC="$tmp_src" \ | ||
| PATH="$tmp_bin:$PATH" \ | ||
| bash profiles/linux-dev/workstation-v0/bin/install-lampstand.sh | ||
| svc="$tmp_home/.config/systemd/user/sourceos-lampstand.service" | ||
| test -f "$svc" | ||
| grep -F 'lampstandd --root %h --rpc unixjson' "$svc" >/dev/null | ||
| - name: Smoke: sourceos-search runtime commands with stub lampstand | ||
| run: | | ||
| set -euo pipefail | ||
| helper='profiles/linux-dev/workstation-v0/bin/sourceos-search.sh' | ||
| stub_bin=$(mktemp -d) | ||
| cat > "$stub_bin/lampstand" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| case "${1:-}" in | ||
| query) | ||
| printf '/tmp/example.txt\t(score=1.000)\n' | ||
| printf ' snippet for %s\n' "$*" | ||
| ;; | ||
| health) | ||
| printf '{"ok": true, "service": "lampstand"}\n' | ||
| ;; | ||
| stats) | ||
| printf '{"documents": 1, "terms": 3}\n' | ||
| ;; | ||
| index) | ||
| printf '{"indexed": 1}\n' | ||
| ;; | ||
| *) | ||
| printf 'unexpected command: %s\n' "$*" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
| EOF | ||
| chmod +x "$stub_bin/lampstand" | ||
| tmp_dir=$(mktemp -d) | ||
| query_out="$tmp_dir/query.txt" | ||
| health_out="$tmp_dir/health.json" | ||
| stats_out="$tmp_dir/stats.json" | ||
| PATH="$stub_bin:$PATH" bash "$helper" --snippet --write "$query_out" report | ||
| grep -F '/tmp/example.txt' "$query_out" >/dev/null | ||
| PATH="$stub_bin:$PATH" bash "$helper" health --write "$health_out" | ||
| grep -F '"ok": true' "$health_out" >/dev/null | ||
| PATH="$stub_bin:$PATH" bash "$helper" stats --write "$stats_out" | ||
| grep -F '"documents": 1' "$stats_out" >/dev/null | ||
| PATH="$stub_bin:$PATH" bash "$helper" index --root "$tmp_dir" >/dev/null | ||