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
27 changes: 20 additions & 7 deletions actions/setup-cli/install.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions actions/setup-cli/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ test_checksum_validation() {
fi
}

# Test 7: Verify version mismatch detection after gh extension install
test_version_mismatch_detection() {
echo ""
echo "Test 7: Verify version mismatch detection after gh extension install"

# Check if script detects when installed version differs from requested version
if grep -q 'INSTALLED_VERSION.*!=.*VERSION' "$SCRIPT_PATH" && \
grep -q 'Version mismatch' "$SCRIPT_PATH"; then
print_result "Script detects version mismatch after gh extension install" "PASS"
else
print_result "Script missing version mismatch detection (gh extension install may install wrong version)" "FAIL"
fi
}

# Run all tests
echo "========================================="
echo "Testing setup-cli action install.sh"
Expand All @@ -120,6 +134,7 @@ test_input_version
test_gh_install
test_version_pinning
test_checksum_validation
test_version_mismatch_detection

# Summary
echo ""
Expand Down
27 changes: 20 additions & 7 deletions install-gh-aw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,28 @@ if [ "$TRY_GH_INSTALL" = true ] && command -v gh &> /dev/null; then
# Verify the installation succeeded
if gh aw version &> /dev/null; then
INSTALLED_VERSION=$(gh aw version 2>&1 | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
print_success "Successfully installed gh-aw using gh extension install"
print_info "Installed version: $INSTALLED_VERSION"

# Set output for GitHub Actions
if [ -n "${GITHUB_OUTPUT}" ]; then
echo "installed_version=${INSTALLED_VERSION}" >> "${GITHUB_OUTPUT}"
# Ensure we could parse an installed version; empty means verification failed
if [ -z "$INSTALLED_VERSION" ]; then
print_warning "gh extension install completed but the installed gh-aw version could not be determined"
print_info "Falling back to manual installation..."
else
# Verify the installed version matches the requested version (if specific version was requested)
if [ "$VERSION" != "latest" ] && [ "$INSTALLED_VERSION" != "$VERSION" ]; then
print_warning "Version mismatch: requested $VERSION but gh extension install installed $INSTALLED_VERSION"
print_info "Falling back to manual installation to install the correct version..."
else
print_success "Successfully installed gh-aw using gh extension install"
print_info "Installed version: $INSTALLED_VERSION"

# Set output for GitHub Actions
if [ -n "${GITHUB_OUTPUT}" ]; then
echo "installed_version=${INSTALLED_VERSION}" >> "${GITHUB_OUTPUT}"
fi

exit 0
fi
fi

exit 0
else
print_warning "gh extension install completed but verification failed"
print_info "Falling back to manual installation..."
Expand Down
Loading