Skip to content

Commit 37a2116

Browse files
Merge branch 'worktree-20260325-181052'
2 parents a70760f + cb06659 commit 37a2116

File tree

12 files changed

+1544
-56
lines changed

12 files changed

+1544
-56
lines changed

.test-index

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ plugins/dso/scripts/check-script-writes.py:tests/scripts/test-check-script-write
4848
plugins/dso/scripts/ci-generator.sh:tests/scripts/test-ci-generator.sh,tests/scripts/test-ci-generator-integration.sh
4949
plugins/dso/scripts/classify-task.py:tests/scripts/test-classify-task.sh
5050
plugins/dso/scripts/collect-discoveries.sh:tests/scripts/test-collect-discoveries-plugin-root.sh
51+
plugins/dso/scripts/gh-identity-resolver.sh: tests/scripts/test-gh-identity-resolver.sh
5152
plugins/dso/scripts/ensure-pre-commit.sh:tests/scripts/test-ensure-precommit-config-paths.sh
5253
plugins/dso/scripts/check-acceptance-criteria.sh:tests/scripts/test_issue_quality_check_file_impact.py
5354
plugins/dso/scripts/enrich-file-impact.sh:tests/scripts/test_issue_quality_check_file_impact.py,tests/scripts/test-enrich-file-impact-v2-removal.sh
@@ -151,3 +152,6 @@ tests/scripts/test-flat-config-e2e.sh: tests/scripts/test-v2-clean-guard.sh
151152
plugins/dso/agents/complexity-evaluator.md: tests/skills/test_complexity_evaluator_agent.py
152153
plugins/dso/skills/implementation-plan/SKILL.md: tests/skills/test-skill-nesting-depth.sh
153154
plugins/dso/skills/design-wireframe/SKILL.md: tests/skills/test-skill-nesting-depth.sh
155+
plugins/dso/scripts/jira-credential-helper.sh: tests/scripts/test-jira-credential-helper.sh
156+
plugins/dso/scripts/acli-version-resolver.sh: tests/scripts/test-acli-version-resolver.sh
157+
plugins/dso/scripts/gh-availability-check.sh: tests/scripts/test-gh-availability-check.sh
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/usr/bin/env bash
2+
# plugins/dso/scripts/acli-version-resolver.sh
3+
#
4+
# Spike PoC: resolves the current ACLI (Atlassian CLI) version and computes
5+
# its SHA-256 checksum for use in reproducible installs (e.g. Homebrew formulae).
6+
#
7+
# ── Version string format ─────────────────────────────────────────────────────
8+
# ACLI reports its version via: acli --version
9+
# Output format: acli version <semver>[-tag]
10+
# Example: acli version 1.3.5-stable
11+
# The version token is everything after "acli version " (space-trimmed).
12+
# The -stable suffix (or similar channel suffix) is preserved verbatim.
13+
#
14+
# ── Download URL patterns ─────────────────────────────────────────────────────
15+
# Latest binary (platform-detect bootstrap):
16+
# https://acli.atlassian.com/{platform}/latest/acli_{platform}_{arch}
17+
# Example: https://acli.atlassian.com/darwin/latest/acli_darwin_arm64
18+
#
19+
# Versioned tarball (used for SHA-256 pinning):
20+
# https://acli.atlassian.com/{platform}/{version}/acli_{version}_{platform}_{arch}.tar.gz
21+
# Example: https://acli.atlassian.com/darwin/1.3.5-stable/acli_1.3.5-stable_darwin_arm64.tar.gz
22+
#
23+
# ── Supported platform / arch values ─────────────────────────────────────────
24+
# Platform: darwin, linux (auto-detected from `uname -s`)
25+
# Arch: amd64, arm64 (auto-detected from `uname -m`; x86_64 → amd64, arm64/aarch64 → arm64)
26+
#
27+
# ── Output format ─────────────────────────────────────────────────────────────
28+
# On success two lines are printed to stdout:
29+
# ACLI_VERSION=<version>
30+
# ACLI_SHA256=<hex-hash>
31+
#
32+
# ── Manually validated versions ───────────────────────────────────────────────
33+
# Validated: v1.3.4-stable SHA256=<run manually to obtain>
34+
# Validated: v1.3.5-stable SHA256=<run manually to obtain>
35+
#
36+
# ── Usage ─────────────────────────────────────────────────────────────────────
37+
# acli-version-resolver.sh [--platform darwin|linux] [--arch amd64|arm64]
38+
#
39+
# Exit 0 on success; non-zero with a descriptive error message on stderr on failure.
40+
41+
set -uo pipefail
42+
43+
# ── Argument parsing ──────────────────────────────────────────────────────────
44+
PLATFORM=""
45+
ARCH=""
46+
47+
while [[ $# -gt 0 ]]; do
48+
case "$1" in
49+
--platform)
50+
PLATFORM="$2"
51+
shift 2
52+
;;
53+
--arch)
54+
ARCH="$2"
55+
shift 2
56+
;;
57+
*)
58+
echo "ERROR: unknown argument: $1" >&2
59+
exit 1
60+
;;
61+
esac
62+
done
63+
64+
# ── Platform / arch detection ─────────────────────────────────────────────────
65+
if [[ -z "$PLATFORM" ]]; then
66+
raw_os="$(uname -s 2>/dev/null || true)"
67+
case "${raw_os,,}" in
68+
darwin) PLATFORM="darwin" ;;
69+
linux) PLATFORM="linux" ;;
70+
*)
71+
echo "ERROR: unsupported OS '${raw_os}'; pass --platform darwin|linux" >&2
72+
exit 1
73+
;;
74+
esac
75+
fi
76+
77+
if [[ -z "$ARCH" ]]; then
78+
raw_arch="$(uname -m 2>/dev/null || true)"
79+
case "$raw_arch" in
80+
x86_64) ARCH="amd64" ;;
81+
arm64|aarch64) ARCH="arm64" ;;
82+
*)
83+
echo "ERROR: unsupported arch '${raw_arch}'; pass --arch amd64|arm64" >&2
84+
exit 1
85+
;;
86+
esac
87+
fi
88+
89+
# ── Locate acli (use PATH if available, otherwise download latest bootstrap) ──
90+
TMPDIR_WORK="$(mktemp -d)"
91+
trap 'rm -rf "$TMPDIR_WORK"' EXIT
92+
93+
if command -v acli &>/dev/null; then
94+
ACLI_BIN="$(command -v acli)"
95+
else
96+
# Download the latest acli binary for bootstrap
97+
LATEST_URL="https://acli.atlassian.com/${PLATFORM}/latest/acli_${PLATFORM}_${ARCH}"
98+
ACLI_BIN="$TMPDIR_WORK/acli"
99+
if ! curl -fsSL -o "$ACLI_BIN" "$LATEST_URL"; then
100+
echo "ERROR: failed to download acli from ${LATEST_URL}" >&2
101+
exit 1
102+
fi
103+
chmod +x "$ACLI_BIN"
104+
fi
105+
106+
# ── Run acli --version and parse the version string ──────────────────────────
107+
version_output="$("$ACLI_BIN" --version 2>&1 || true)"
108+
109+
# Expected format: "acli version <version>"
110+
# Extract the version token (third word)
111+
version_token=""
112+
if [[ "$version_output" =~ ^acli[[:space:]]+version[[:space:]]+([^[:space:]]+) ]]; then
113+
version_token="${BASH_REMATCH[1]}"
114+
fi
115+
116+
if [[ -z "$version_token" ]]; then
117+
echo "ERROR: could not parse version from acli output: ${version_output}" >&2
118+
exit 1
119+
fi
120+
121+
# ── Construct the versioned tarball URL ───────────────────────────────────────
122+
TARBALL_URL="https://acli.atlassian.com/${PLATFORM}/${version_token}/acli_${version_token}_${PLATFORM}_${ARCH}.tar.gz"
123+
124+
# ── Download the versioned tarball ───────────────────────────────────────────
125+
TARBALL_PATH="$TMPDIR_WORK/acli_${version_token}_${PLATFORM}_${ARCH}.tar.gz"
126+
if ! curl -fsSL -o "$TARBALL_PATH" "$TARBALL_URL"; then
127+
echo "ERROR: failed to download versioned tarball from ${TARBALL_URL}" >&2
128+
exit 1
129+
fi
130+
131+
# ── Compute SHA-256 ───────────────────────────────────────────────────────────
132+
sha256=""
133+
if command -v sha256sum &>/dev/null; then
134+
sha256="$(sha256sum "$TARBALL_PATH" | awk '{print $1}')"
135+
elif command -v shasum &>/dev/null; then
136+
sha256="$(shasum -a 256 "$TARBALL_PATH" | awk '{print $1}')"
137+
else
138+
echo "ERROR: no sha256sum or shasum found in PATH" >&2
139+
exit 1
140+
fi
141+
142+
# ── Output ────────────────────────────────────────────────────────────────────
143+
echo "ACLI_VERSION=${version_token}"
144+
echo "ACLI_URL=${TARBALL_URL}"
145+
echo "ACLI_SHA256=${sha256}"
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
# plugins/dso/scripts/gh-availability-check.sh
3+
#
4+
# Check GitHub CLI (gh) availability and authentication status.
5+
#
6+
# Output variables (printed to stdout):
7+
# GH_STATUS=authenticated — gh is installed and authenticated
8+
# GH_STATUS=not_authenticated — gh is installed but not authenticated
9+
# GH_STATUS=not_installed — gh is not installed
10+
# FALLBACK=commands — (with not_authenticated) gh CLI commands to set vars/secrets manually
11+
# FALLBACK=ui_steps — (with not_installed) GitHub UI navigation steps
12+
#
13+
# Usage:
14+
# bash gh-availability-check.sh [--vars=VAR1,VAR2] [--secrets=SECRET1,SECRET2]
15+
#
16+
# Flags:
17+
# --vars=VAR1,VAR2 Comma-separated list of variable names to include in fallback commands
18+
# --secrets=SEC1,SEC2 Comma-separated list of secret names to include in fallback commands
19+
20+
set -uo pipefail
21+
22+
# ---------------------------------------------------------------------------
23+
# Parse arguments
24+
# ---------------------------------------------------------------------------
25+
VARS_LIST=""
26+
SECRETS_LIST=""
27+
28+
for arg in "$@"; do
29+
case "$arg" in
30+
--vars=*)
31+
VARS_LIST="${arg#--vars=}"
32+
;;
33+
--secrets=*)
34+
SECRETS_LIST="${arg#--secrets=}"
35+
;;
36+
esac
37+
done
38+
39+
# ---------------------------------------------------------------------------
40+
# Check if gh is installed
41+
# ---------------------------------------------------------------------------
42+
if ! command -v gh &>/dev/null; then
43+
echo "GH_STATUS=not_installed"
44+
echo "FALLBACK=ui_steps"
45+
echo ""
46+
echo "GitHub CLI (gh) is not installed. To set repository variables and secrets manually:"
47+
echo " 1. Navigate to github.com/<owner>/<repo>"
48+
echo " 2. Go to Settings > Secrets and variables > Actions"
49+
echo " 3. Under 'Variables', click 'New repository variable' and add each variable"
50+
echo " 4. Under 'Secrets', click 'New repository secret' and add each secret"
51+
exit 0
52+
fi
53+
54+
# ---------------------------------------------------------------------------
55+
# Check if gh is authenticated
56+
# ---------------------------------------------------------------------------
57+
if ! gh auth status &>/dev/null; then
58+
echo "GH_STATUS=not_authenticated"
59+
echo "FALLBACK=commands"
60+
echo ""
61+
echo "GitHub CLI is installed but not authenticated. Run the following commands to"
62+
echo "set your repository variables and secrets manually after authenticating:"
63+
echo ""
64+
echo " gh auth login"
65+
echo ""
66+
67+
# Print gh variable set commands for each var
68+
if [[ -n "$VARS_LIST" ]]; then
69+
IFS=',' read -ra VARS_ARR <<< "$VARS_LIST"
70+
for var in "${VARS_ARR[@]}"; do
71+
var="$(echo "$var" | tr -d '[:space:]')"
72+
[[ -z "$var" ]] && continue
73+
echo " gh variable set $var --body \"<value>\""
74+
done
75+
else
76+
echo " gh variable set <VARIABLE_NAME> --body \"<value>\""
77+
fi
78+
79+
echo ""
80+
81+
# Print gh secret set commands for each secret
82+
if [[ -n "$SECRETS_LIST" ]]; then
83+
IFS=',' read -ra SECRETS_ARR <<< "$SECRETS_LIST"
84+
for secret in "${SECRETS_ARR[@]}"; do
85+
secret="$(echo "$secret" | tr -d '[:space:]')"
86+
[[ -z "$secret" ]] && continue
87+
echo " gh secret set $secret"
88+
done
89+
else
90+
echo " gh secret set <SECRET_NAME>"
91+
fi
92+
93+
exit 0
94+
fi
95+
96+
# ---------------------------------------------------------------------------
97+
# gh is installed and authenticated
98+
# ---------------------------------------------------------------------------
99+
echo "GH_STATUS=authenticated"
100+
exit 0

0 commit comments

Comments
 (0)