diff --git a/templates/automated-template-update.md b/templates/automated-template-update.md index 423e60b..5913f65 100644 --- a/templates/automated-template-update.md +++ b/templates/automated-template-update.md @@ -91,6 +91,6 @@ Show me what changes will be made before applying them." - **Template Source**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions - **Latest Template**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md -- **Version Check Script**: Use our [version check command](../snippets/version-check-command.md) +- **Version Check Script**: Use our [version check command](https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/version-check-command.md) **GitHub Copilot**: Start by running the version check and analyzing my current template, then proceed with the merge using the provided prompt. \ No newline at end of file diff --git a/templates/initial-setup-automation.md b/templates/initial-setup-automation.md index 401adcb..24003df 100644 --- a/templates/initial-setup-automation.md +++ b/templates/initial-setup-automation.md @@ -290,7 +290,7 @@ Test that enhanced Copilot suggestions work: - **Template Repository**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions - **Latest Template**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md -- **Version Check**: See [version check command](../snippets/version-check-command.md) -- **GitHub Action Template**: [GitHub Action](../snippets/github-action-version-check.yml) +- **Version Check**: See [version check command](https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/version-check-command.md) +- **GitHub Action Template**: [GitHub Action](https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/github-action-version-check.yml) **GitHub Copilot**: Please start with the current state analysis and proceed step-by-step through the setup process. Provide detailed feedback on what you're doing at each step. \ No newline at end of file diff --git a/tests/test-http-links.sh b/tests/test-http-links.sh new file mode 100755 index 0000000..6d73852 --- /dev/null +++ b/tests/test-http-links.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Test HTTP Links in Templates +# +# This test ensures that templates use HTTP URLs instead of relative +# markdown links for snippet references, as required when templates +# are used in external repositories. + +set -e + +# Get the directory of this script and find the root of the repository +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(dirname "$SCRIPT_DIR")" +TEMPLATES_DIR="$REPO_ROOT/templates" + +# Colors +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +echo "Testing HTTP Links in Templates" + +EXIT_CODE=0 + +# Test framework helper +run_test_with_output() { + local TEST_NAME="$1" + local EXPECTED_PATTERN="$2" + local COMMAND="$3" + + echo -n " Testing $TEST_NAME... " + + if eval "$COMMAND" 2>/dev/null | grep -q "$EXPECTED_PATTERN"; then + echo -e "${GREEN}✅ PASS${NC}" + return 0 + else + echo -e "${RED}❌ FAIL${NC}" + EXIT_CODE=1 + return 1 + fi +} + +# Test framework helper for negative tests (commands that should fail) +run_negative_test() { + local TEST_NAME="$1" + local COMMAND="$2" + + echo -n " Testing $TEST_NAME... " + + if eval "$COMMAND" 2>/dev/null; then + echo -e "${RED}❌ FAIL${NC}" + EXIT_CODE=1 + return 1 + else + echo -e "${GREEN}✅ PASS${NC}" + return 0 + fi +} + +# Test that templates don't contain relative links to snippets +run_negative_test \ + "Templates don't contain relative snippet links" \ + "grep -r '\.\./snippets.*\\.md)' \"$TEMPLATES_DIR\" --include='*.md'" + +run_negative_test \ + "Templates don't contain relative yml snippet links" \ + "grep -r '\.\./snippets.*\\.yml)' \"$TEMPLATES_DIR\" --include='*.md'" + +# Test that templates contain the expected HTTP URLs for snippets +run_test_with_output \ + "Version check snippet uses HTTP URL" \ + "version-check-command.md" \ + "grep -r 'https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/version-check-command.md' \"$TEMPLATES_DIR\" --include='*.md'" + +run_test_with_output \ + "GitHub Action snippet uses HTTP URL" \ + "github-action-version-check.yml" \ + "grep -r 'https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/github-action-version-check.yml' \"$TEMPLATES_DIR\" --include='*.md'" + +# Test that the HTTP URLs are actually accessible (if network is available) +test_url_accessibility() { + local url="$1" + local description="$2" + + if curl -s --fail -I "$url" >/dev/null 2>&1; then + echo -e " Testing $description URL accessibility... ${GREEN}✅ PASS${NC}" + return 0 + else + echo -e " Testing $description URL accessibility... ${YELLOW}⚠️ SKIP${NC} (network unavailable or URL inaccessible)" + return 0 # Don't fail tests if network is unavailable + fi +} + +echo "" +echo -e "${YELLOW}🌐 Testing URL Accessibility (network dependent)${NC}" + +test_url_accessibility "https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/version-check-command.md" "version check command" +test_url_accessibility "https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/github-action-version-check.yml" "GitHub Action template" + +# Summary +echo "" +if [[ $EXIT_CODE -eq 0 ]]; then + echo -e "${GREEN}✅ All HTTP link tests passed!${NC}" +else + echo -e "${RED}❌ Some HTTP link tests failed. Please review the output above.${NC}" +fi + +exit $EXIT_CODE \ No newline at end of file