Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ It runs five steps in order:
4. **secrets**: pushes `AUR_SSH_KEY`, `AUR_GIT_NAME`, `AUR_GIT_EMAIL` and, with GPG, `GPG_SIGNING_KEY` to your GitHub repo. It checks the SSH key as the ssh step does, so a key that is missing or has a passphrase stops it before any secret is set.
5. **verify**: checks identity, SSH access to the AUR, GPG signing and the secrets

The script reads the GitHub repo from the `origin` remote and asks for `owner/repo` when that fails. It saves your answers to `.aurtomator.conf`, also when `verify` finds a problem.
The script reads the GitHub repo from the `origin` remote and asks for `owner/repo` when that fails. It saves your answers to `.aurtomator.conf` after each step, so a step that fails, and a `verify` that finds a problem, leave the answers given so far for the next run.

## Identity

Expand Down
20 changes: 5 additions & 15 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ save_config() {
printf 'GPG_KEY_ID=%s\n' "${GPG_KEY_ID@Q}"
printf 'AUR_SSH_KEY=%s\n' "${AUR_SSH_KEY@Q}"
} >"$CONFIG_FILE"
ok "Config saved to .aurtomator.conf"
}

# =============================================================================
Expand Down Expand Up @@ -567,13 +566,9 @@ fi

printf "%saurtomator setup%s\n" "$BOLD" "$RESET"

FULL_SETUP=false
if [[ ${#STEPS[@]} -eq 5 ]]; then
FULL_SETUP=true
fi

# A failed verify still saves the config, so the re-run it suggests has
# the values of this run
# Each step is saved as soon as it ends, so a step that fails keeps the
# answers given before it. A failed verify still saves the config, so the
# re-run it suggests has the values of this run.
EXIT_STATUS=0
for step in "${STEPS[@]}"; do
case "$step" in
Expand All @@ -583,12 +578,7 @@ for step in "${STEPS[@]}"; do
secrets) setup_secrets ;;
verify) verify_all || EXIT_STATUS=1 ;;
esac
if [[ "$FULL_SETUP" == "false" ]]; then
save_config
fi
done

if [[ "$FULL_SETUP" == "true" ]]; then
save_config
fi
done
ok "Config saved to .aurtomator.conf"
exit "$EXIT_STATUS"
17 changes: 16 additions & 1 deletion tests/setup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ EOF
# === Config persistence ===

@test "setup: saves config file" {
"$TEST_TMPDIR/scripts/setup.sh" gpg --gpg-key VALIDKEY123 --non-interactive 2>/dev/null
run "$TEST_TMPDIR/scripts/setup.sh" gpg --gpg-key VALIDKEY123 --non-interactive
[ "$status" -eq 0 ]
[[ "$output" == *"Config saved to .aurtomator.conf"* ]]
[ -f "$TEST_TMPDIR/.aurtomator.conf" ]
grep -q "VALIDKEY123" "$TEST_TMPDIR/.aurtomator.conf"
}
Expand Down Expand Up @@ -504,6 +506,19 @@ EOF
grep -qx "AUR_SSH_KEY='$TEST_TMPDIR/ssh/aur.pem'" "$TEST_TMPDIR/.aurtomator.conf"
}

# A full setup runs every step in one go, and a step that fails ends it
@test "setup: full setup keeps the identity when the ssh step fails" {
mkdir -p "$TEST_TMPDIR/ssh-pass"
ssh-keygen -t ed25519 -f "$TEST_TMPDIR/ssh-pass/key" -N "testpass" -q

run "$TEST_TMPDIR/scripts/setup.sh" \
--git-name "Jane Doe" --git-email "jane@example.com" \
--ssh-key "$TEST_TMPDIR/ssh-pass/key" --non-interactive
[ "$status" -eq 1 ]
[[ "$output" == *"SSH key has a passphrase"* ]]
grep -qx "GIT_AUTHOR_NAME='Jane Doe'" "$TEST_TMPDIR/.aurtomator.conf"
}

# === Secrets step ===

@test "setup secrets: sets all secrets via gh" {
Expand Down
Loading