83 lines
3.4 KiB
Bash
Executable File
83 lines
3.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)
|
|
tmp=${TMPDIR:-/tmp}/ink-skills-smoke-$$
|
|
trap 'rm -rf "$tmp"' EXIT HUP INT TERM
|
|
mkdir -p "$tmp/home" "$tmp/project"
|
|
|
|
list=$($repo/bin/ink-skills list)
|
|
printf '%s\n' "$list" | grep '^SKILL' >/dev/null
|
|
printf '%s\n' "$list" | grep '^audit-ink-cli' >/dev/null
|
|
printf '%s\n' "$list" | grep '^configure-ink-agent' >/dev/null
|
|
|
|
HOME=$tmp/home $repo/bin/ink-skills install audit-ink-cli >"$tmp/install.tsv"
|
|
grep "audit-ink-cli.*linked" "$tmp/install.tsv" >/dev/null
|
|
[ -L "$tmp/home/.ink/skills/audit-ink-cli" ]
|
|
[ "$(readlink "$tmp/home/.ink/skills/audit-ink-cli")" = "$repo/skills/audit-ink-cli" ]
|
|
|
|
HOME=$tmp/home $repo/bin/ink-skills install audit-ink-cli >"$tmp/reinstall.tsv"
|
|
grep "audit-ink-cli.*unchanged" "$tmp/reinstall.tsv" >/dev/null
|
|
|
|
mkdir -p "$tmp/home/.ink/skills/configure-ink-agent"
|
|
if HOME=$tmp/home $repo/bin/ink-skills install configure-ink-agent >/dev/null 2>"$tmp/collision.err"; then
|
|
echo 'expected collision refusal' >&2
|
|
exit 1
|
|
fi
|
|
grep 'refusing existing path' "$tmp/collision.err" >/dev/null
|
|
|
|
HOME=$tmp/home $repo/bin/ink-skills install --project "$tmp/project" create-ink-tool >"$tmp/project.tsv"
|
|
[ -L "$tmp/project/.ink/skills/create-ink-tool" ]
|
|
grep "create-ink-tool.*linked" "$tmp/project.tsv" >/dev/null
|
|
|
|
remote=$tmp/remote
|
|
mkdir -p "$remote/skills/remote-review"
|
|
cat >"$remote/skills/remote-review/SKILL.md" <<'EOF'
|
|
---
|
|
name: remote-review
|
|
description: Review one remote fixture.
|
|
---
|
|
|
|
# Remote review
|
|
EOF
|
|
git -C "$remote" init -q
|
|
git -C "$remote" config user.email ink-skills@example.invalid
|
|
git -C "$remote" config user.name 'Ink Skills Test'
|
|
git -C "$remote" add skills/remote-review/SKILL.md
|
|
git -C "$remote" commit -qm fixture
|
|
commit=$(git -C "$remote" rev-parse HEAD)
|
|
|
|
mkdir -p "$tmp/remote-home"
|
|
HOME=$tmp/remote-home INK_SKILLS_STORE=$tmp/store $repo/bin/ink-skills add --ref HEAD "$remote" skills/remote-review >"$tmp/add.tsv"
|
|
remote_link=$tmp/remote-home/.ink/skills/remote-review
|
|
[ -L "$remote_link" ]
|
|
case $(readlink "$remote_link") in
|
|
"$tmp/store/artifacts/"*"/$commit/skills/remote-review") ;;
|
|
*) echo 'remote link is not pinned to resolved commit' >&2; exit 1 ;;
|
|
esac
|
|
grep "remote-review.*linked.*$commit" "$tmp/add.tsv" >/dev/null
|
|
manifest=$tmp/remote-home/.ink/skills/.ink-skills.tsv
|
|
[ "$(wc -l <"$manifest")" -eq 2 ]
|
|
awk -F '\t' -v commit="$commit" 'NR == 2 { exit !($1 == "remote-review" && $4 == commit && length($6) == 64) }' "$manifest"
|
|
|
|
HOME=$tmp/remote-home INK_SKILLS_STORE=$tmp/store $repo/bin/ink-skills add --ref HEAD "$remote" skills/remote-review >"$tmp/readd.tsv"
|
|
grep 'remote-review.*unchanged' "$tmp/readd.tsv" >/dev/null
|
|
[ "$(wc -l <"$manifest")" -eq 2 ]
|
|
|
|
printf '\nchanged\n' >>"$remote/skills/remote-review/SKILL.md"
|
|
git -C "$remote" add skills/remote-review/SKILL.md
|
|
git -C "$remote" commit -qm changed
|
|
if HOME=$tmp/remote-home INK_SKILLS_STORE=$tmp/store $repo/bin/ink-skills add --ref HEAD "$remote" skills/remote-review >/dev/null 2>"$tmp/pin.err"; then
|
|
echo 'expected provenance collision after ref moves' >&2
|
|
exit 1
|
|
fi
|
|
grep 'provenance collision' "$tmp/pin.err" >/dev/null
|
|
|
|
if HOME=$tmp/remote-home INK_SKILLS_STORE=$tmp/store $repo/bin/ink-skills add 'https://user:secret@example.invalid/skills.git' >/dev/null 2>"$tmp/credential.err"; then
|
|
echo 'expected credentialed URL refusal' >&2
|
|
exit 1
|
|
fi
|
|
grep 'credentialed HTTP URLs are refused' "$tmp/credential.err" >/dev/null
|
|
|
|
printf 'ok\n'
|