'Generic Commit'
Some checks failed
Build-Test-Publish / build (push) Failing after 19s

This commit is contained in:
Your Name 2025-06-22 09:16:28 +12:00
parent d557ab01f7
commit 84c9907edc
2 changed files with 21 additions and 12 deletions

View File

@ -276,6 +276,15 @@ int publish_tool(int argc, char* argv[]) {
// If no ARCH is provided (no colon in labeltag), append ":universal" for cross-platform tools // If no ARCH is provided (no colon in labeltag), append ":universal" for cross-platform tools
if (labeltag.find(':') == std::string::npos) { if (labeltag.find(':') == std::string::npos) {
labeltag += ":universal"; labeltag += ":universal";
} else {
// valid labels are tool_name:ARCH, where ARCH is x86_64 or aarch64 or universal
if (labeltag.find(':') != std::string::npos) {
std::string arch = labeltag.substr(labeltag.find(':') + 1);
if (arch != "x86_64" && arch != "aarch64" && arch != "universal") {
std::cerr << "Invalid architecture: " << arch << std::endl;
return 1;
}
}
} }
std::string home = get_home(); std::string home = get_home();
std::filesystem::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz"); std::filesystem::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz");

View File

@ -105,7 +105,7 @@ fi
# Test 2: Help command # Test 2: Help command
echo -e "\nTest 2: Help command" echo -e "\nTest 2: Help command"
HELP_OUTPUT=$(timeout 3 "$GETPKG" help 2>&1) || HELP_OUTPUT="" HELP_OUTPUT=$(timeout 3 "$GETPKG" help 2>&1) || HELP_OUTPUT=""
if [[ "$HELP_OUTPUT" =~ "Usage: getpkg" ]]; then if [[ "$HELP_OUTPUT" =~ Usage:\ getpkg ]]; then
print_test_result "Help command output" 0 print_test_result "Help command output" 0
else else
print_test_result "Help command output" 1 print_test_result "Help command output" 1
@ -114,7 +114,7 @@ fi
# Test 3: Autocomplete command # Test 3: Autocomplete command
echo -e "\nTest 3: Autocomplete command" echo -e "\nTest 3: Autocomplete command"
AUTOCOMPLETE_OUTPUT=$(timeout 3 "$GETPKG" autocomplete 2>&1) || AUTOCOMPLETE_OUTPUT="" AUTOCOMPLETE_OUTPUT=$(timeout 3 "$GETPKG" autocomplete 2>&1) || AUTOCOMPLETE_OUTPUT=""
if [[ "$AUTOCOMPLETE_OUTPUT" =~ "install" ]] && [[ "$AUTOCOMPLETE_OUTPUT" =~ "publish" ]]; then if [[ "$AUTOCOMPLETE_OUTPUT" =~ install ]] && [[ "$AUTOCOMPLETE_OUTPUT" =~ publish ]]; then
print_test_result "Autocomplete command output" 0 print_test_result "Autocomplete command output" 0
else else
print_test_result "Autocomplete command output" 1 print_test_result "Autocomplete command output" 1
@ -183,7 +183,7 @@ if [ -n "${SOS_WRITE_TOKEN:-}" ]; then
echo "Publish command failed with no output. Checking for missing dependencies..." echo "Publish command failed with no output. Checking for missing dependencies..."
ldd "$GETPKG" 2>&1 | grep "not found" || echo "All dependencies found" ldd "$GETPKG" 2>&1 | grep "not found" || echo "All dependencies found"
fi fi
if [[ "$PUBLISH_OUTPUT" =~ "Published!" ]] && [[ "$PUBLISH_OUTPUT" =~ "URL:" ]] && [[ "$PUBLISH_OUTPUT" =~ "Hash:" ]]; then if [[ "$PUBLISH_OUTPUT" =~ Published! ]] && [[ "$PUBLISH_OUTPUT" =~ URL: ]] && [[ "$PUBLISH_OUTPUT" =~ Hash: ]]; then
print_test_result "Publish tool with ARCH to getpkg.xyz" 0 print_test_result "Publish tool with ARCH to getpkg.xyz" 0
# Extract hash for later cleanup # Extract hash for later cleanup
@ -202,7 +202,7 @@ if [ -n "${SOS_WRITE_TOKEN:-}" ]; then
# Test 8: Install command # Test 8: Install command
echo -e "\nTest 8: Install command" echo -e "\nTest 8: Install command"
INSTALL_OUTPUT=$(timeout 3 "$GETPKG" install "$TEST_TOOL_NAME" 2>&1) || INSTALL_OUTPUT="" INSTALL_OUTPUT=$(timeout 3 "$GETPKG" install "$TEST_TOOL_NAME" 2>&1) || INSTALL_OUTPUT=""
if [[ "$INSTALL_OUTPUT" =~ "Installed ${TEST_TOOL_NAME} successfully" ]] || [[ "$INSTALL_OUTPUT" =~ "${TEST_TOOL_NAME} is already up to date" ]]; then if [[ "$INSTALL_OUTPUT" =~ Installed\ ${TEST_TOOL_NAME}\ successfully ]] || [[ "$INSTALL_OUTPUT" =~ ${TEST_TOOL_NAME}\ is\ already\ up\ to\ date ]]; then
print_test_result "Install tool from getpkg.xyz" 0 print_test_result "Install tool from getpkg.xyz" 0
# Test 9: Check installed files # Test 9: Check installed files
@ -228,7 +228,7 @@ if [ -n "${SOS_WRITE_TOKEN:-}" ]; then
rm -f ~/.config/getpkg/"${TEST_TOOL_NAME}.json" rm -f ~/.config/getpkg/"${TEST_TOOL_NAME}.json"
DIRECT_INSTALL_OUTPUT=$(timeout 3 "$GETPKG" "$TEST_TOOL_NAME" 2>&1) || DIRECT_INSTALL_OUTPUT="" DIRECT_INSTALL_OUTPUT=$(timeout 3 "$GETPKG" "$TEST_TOOL_NAME" 2>&1) || DIRECT_INSTALL_OUTPUT=""
if [[ "$DIRECT_INSTALL_OUTPUT" =~ "Installed ${TEST_TOOL_NAME} successfully" ]] || [[ "$DIRECT_INSTALL_OUTPUT" =~ "${TEST_TOOL_NAME} is already up to date" ]]; then if [[ "$DIRECT_INSTALL_OUTPUT" =~ Installed\ ${TEST_TOOL_NAME}\ successfully ]] || [[ "$DIRECT_INSTALL_OUTPUT" =~ ${TEST_TOOL_NAME}\ is\ already\ up\ to\ date ]]; then
print_test_result "Direct tool name install syntax" 0 print_test_result "Direct tool name install syntax" 0
else else
print_test_result "Direct tool name install syntax" 1 print_test_result "Direct tool name install syntax" 1
@ -237,7 +237,7 @@ if [ -n "${SOS_WRITE_TOKEN:-}" ]; then
# Test 12: Update already installed tool (should say up to date) # Test 12: Update already installed tool (should say up to date)
echo -e "\nTest 12: Update check for installed tool" echo -e "\nTest 12: Update check for installed tool"
UPDATE_OUTPUT=$(timeout 3 "$GETPKG" install "$TEST_TOOL_NAME" 2>&1) || UPDATE_OUTPUT="" UPDATE_OUTPUT=$(timeout 3 "$GETPKG" install "$TEST_TOOL_NAME" 2>&1) || UPDATE_OUTPUT=""
if [[ "$UPDATE_OUTPUT" =~ "${TEST_TOOL_NAME} is already up to date" ]]; then if [[ "$UPDATE_OUTPUT" =~ ${TEST_TOOL_NAME}\ is\ already\ up\ to\ date ]]; then
print_test_result "Update check recognizes up-to-date tool" 0 print_test_result "Update check recognizes up-to-date tool" 0
else else
print_test_result "Update check recognizes up-to-date tool" 1 print_test_result "Update check recognizes up-to-date tool" 1
@ -281,7 +281,7 @@ EOF
chmod +x "${TEST_DIR}/${TEST_TOOL_NOARCH}/${TEST_TOOL_NOARCH}" chmod +x "${TEST_DIR}/${TEST_TOOL_NOARCH}/${TEST_TOOL_NOARCH}"
PUBLISH_NOARCH_OUTPUT=$(timeout 3 "$GETPKG" publish "${TEST_TOOL_NOARCH}" "${TEST_DIR}/${TEST_TOOL_NOARCH}" 2>&1) || PUBLISH_NOARCH_OUTPUT="" PUBLISH_NOARCH_OUTPUT=$(timeout 3 "$GETPKG" publish "${TEST_TOOL_NOARCH}" "${TEST_DIR}/${TEST_TOOL_NOARCH}" 2>&1) || PUBLISH_NOARCH_OUTPUT=""
if [[ "$PUBLISH_NOARCH_OUTPUT" =~ "Published!" ]] && [[ "$PUBLISH_NOARCH_OUTPUT" =~ "URL:" ]] && [[ "$PUBLISH_NOARCH_OUTPUT" =~ "Hash:" ]]; then if [[ "$PUBLISH_NOARCH_OUTPUT" =~ Published! ]] && [[ "$PUBLISH_NOARCH_OUTPUT" =~ URL: ]] && [[ "$PUBLISH_NOARCH_OUTPUT" =~ Hash: ]]; then
print_test_result "Publish tool without ARCH" 0 print_test_result "Publish tool without ARCH" 0
# Clean up the noarch tool # Clean up the noarch tool
NOARCH_HASH=$(curl -s "https://getpkg.xyz/hash/${TEST_TOOL_NOARCH}" 2>/dev/null || echo "") NOARCH_HASH=$(curl -s "https://getpkg.xyz/hash/${TEST_TOOL_NOARCH}" 2>/dev/null || echo "")
@ -297,12 +297,12 @@ EOF
echo -e "\nTest 12c: Install universal tool (arch fallback)" echo -e "\nTest 12c: Install universal tool (arch fallback)"
rm -rf ~/.config/getpkg/"${TEST_TOOL_NOARCH}.json" ~/.local/bin/getpkg/"${TEST_TOOL_NOARCH}" 2>/dev/null || true rm -rf ~/.config/getpkg/"${TEST_TOOL_NOARCH}.json" ~/.local/bin/getpkg/"${TEST_TOOL_NOARCH}" 2>/dev/null || true
FALLBACK_INSTALL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || FALLBACK_INSTALL_OUTPUT="" FALLBACK_INSTALL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || FALLBACK_INSTALL_OUTPUT=""
if [[ "$FALLBACK_INSTALL_OUTPUT" =~ "Arch-specific version not found, trying universal version" ]] && [[ "$FALLBACK_INSTALL_OUTPUT" =~ "Installed ${TEST_TOOL_NOARCH} successfully" ]]; then if [[ "$FALLBACK_INSTALL_OUTPUT" =~ Arch-specific\ version\ not\ found,\ trying\ universal\ version ]] && [[ "$FALLBACK_INSTALL_OUTPUT" =~ Installed\ ${TEST_TOOL_NOARCH}\ successfully ]]; then
print_test_result "Install universal tool with arch fallback" 0 print_test_result "Install universal tool with arch fallback" 0
# Test update check for universal tool # Test update check for universal tool
UPDATE_UNIVERSAL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || UPDATE_UNIVERSAL_OUTPUT="" UPDATE_UNIVERSAL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || UPDATE_UNIVERSAL_OUTPUT=""
if [[ "$UPDATE_UNIVERSAL_OUTPUT" =~ "${TEST_TOOL_NOARCH} is already up to date" ]]; then if [[ "$UPDATE_UNIVERSAL_OUTPUT" =~ ${TEST_TOOL_NOARCH}\ is\ already\ up\ to\ date ]]; then
print_test_result "Update check for universal tool" 0 print_test_result "Update check for universal tool" 0
else else
print_test_result "Update check for universal tool" 1 print_test_result "Update check for universal tool" 1
@ -322,17 +322,17 @@ INVALID_OUTPUT=$(timeout 3 "$GETPKG" install "../evil-tool" 2>&1)
INVALID_EXIT_CODE=$? INVALID_EXIT_CODE=$?
echo "Invalid tool output: $INVALID_OUTPUT" echo "Invalid tool output: $INVALID_OUTPUT"
echo "Invalid tool exit code: $INVALID_EXIT_CODE" echo "Invalid tool exit code: $INVALID_EXIT_CODE"
if [[ "$INVALID_OUTPUT" =~ "Invalid tool name" ]]; then if [[ "$INVALID_OUTPUT" =~ Invalid\ tool\ name ]]; then
print_test_result "Invalid tool name rejection" 0 print_test_result "Invalid tool name rejection" 0
else else
print_test_result "Invalid tool name rejection" 1 print_test_result "Invalid tool name rejection" 1
fi fi
# Test 14: Update command (if we have tools installed) # Test 14: Update command (if we have tools installed)
if [ -d ~/.config/getpkg ] && [ "$(ls -A ~/.config/getpkg/*.json 2>/dev/null | wc -l)" -gt 0 ]; then if [ -d ~/.config/getpkg ] && [ "$(find ~/.config/getpkg -name "*.json" -type f 2>/dev/null | wc -l)" -gt 0 ]; then
echo -e "\nTest 14: Update command" echo -e "\nTest 14: Update command"
UPDATE_ALL_OUTPUT=$(timeout 3 "$GETPKG" update 2>&1) || UPDATE_ALL_OUTPUT="" UPDATE_ALL_OUTPUT=$(timeout 3 "$GETPKG" update 2>&1) || UPDATE_ALL_OUTPUT=""
if [[ "$UPDATE_ALL_OUTPUT" =~ "Update complete" ]]; then if [[ "$UPDATE_ALL_OUTPUT" =~ Update\ complete ]]; then
print_test_result "Update all tools command" 0 print_test_result "Update all tools command" 0
else else
print_test_result "Update all tools command" 1 print_test_result "Update all tools command" 1