Skip to content

Implement comprehensive automated testing infrastructure and version management for all repository scripts#17

Merged
DutchmanNL merged 5 commits intomainfrom
copilot/fix-16
Sep 18, 2025
Merged

Implement comprehensive automated testing infrastructure and version management for all repository scripts#17
DutchmanNL merged 5 commits intomainfrom
copilot/fix-16

Conversation

Copy link
Contributor

Copilot AI commented Sep 18, 2025

  • Explore repository structure and understand current scripts
  • Test all existing scripts to verify they work correctly
  • Identify automation scripts that need testing:
    • scripts/manage-versions.sh - Master version management with show/check/sync/update commands
    • scripts/extract-version.sh - Extract version and date information from template
    • scripts/update-versions.sh - Update documentation with dynamic versions
    • scripts/check-template-version.sh - Check template version against remote
  • Create comprehensive test suite using bash/shell testing framework
    • tests/test-runner.sh - Main test execution framework (54 total tests)
    • tests/test-extract-version.sh - 9 tests for version extraction functionality
    • tests/test-manage-versions.sh - 13 tests for version management commands
    • tests/test-update-versions.sh - 11 tests for documentation updating
    • tests/test-check-template-version.sh - 11 tests for template version checking
    • tests/test-integration.sh - 10 integration tests for script interactions
  • Implement tests for all script functions and edge cases
    • Unit tests for individual functions and parameters
    • Integration tests for script interactions and workflows
    • Error handling tests for missing files, invalid parameters, network failures
    • Consistency validation tests for version synchronization
  • Create GitHub Actions workflow for automated testing on CI
    • .github/workflows/test-scripts.yml - Runs on push, PRs, manual trigger (removed daily schedule)
    • Tests scripts functionality and version consistency
    • Creates test reports as artifacts
    • Fixed CI issues: Added execute permissions for all test files and updated actions to v4
  • Add test documentation and guidelines for future script additions
    • TESTING.md - Comprehensive testing infrastructure documentation
    • Test framework usage guide and best practices
    • Guidelines for adding new tests and maintaining existing ones
  • Implement Copilot instructions for test case validation on new functionality
    • Updated .github/copilot-instructions.md with automated testing requirements
    • Added mandatory testing guidelines for new scripts and functionality changes
    • Integrated test validation requirements into development workflow
  • Update CHANGELOG.md and README.md per repository requirements
    • Added detailed changelog entry for automated testing infrastructure (Fixes automated testing #16)
    • Updated README.md with testing framework documentation and usage examples
    • Enhanced Contributing section with testing requirements
    • Improved PR guidelines to prevent missing changelog/readme updates
  • Version Management Updates
    • Updated version to 0.4.0 using automated version management scripts
    • Updated CHANGELOG.md title: "Automated Version handling & validation by GitHub actions"
    • Verified all version references are consistent across all files
    • Removed daily schedule from CI workflow as requested
  • CI/CD Fixes
    • Fixed GitHub Actions workflow by adding execute permissions for all test files
    • Updated upload-artifact action from v3 to v4
    • Verified all workflow steps execute correctly locally

All 54 tests pass successfully, providing comprehensive coverage of script functionality, error handling, and integration scenarios.

Fixes #16.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…sitory scripts

Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Copilot AI changed the title [WIP] automated testing Implement comprehensive automated testing infrastructure for all repository scripts Sep 18, 2025
Copilot AI requested a review from DutchmanNL September 18, 2025 20:18
@DutchmanNL
Copy link
Contributor

…re details, enhance PR guidelines

Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 18, 2025

@copilot you forgot (again) to update the change log and readme according to requirements:

You're absolutely right - I missed updating the CHANGELOG.md and README.md as required by the repository guidelines. I've now addressed this with commit ab49038 which:

CHANGELOG.md Updates:

  • Added detailed entry for the automated testing infrastructure under version 0.3.1
  • Included comprehensive details about all 54 tests, test framework, CI/CD workflow, and documentation
  • Referenced issue automated testing #16 as required

README.md Updates:

  • Added new "Automated Testing Infrastructure" section with usage examples and key features
  • Updated Contributing section with mandatory testing requirements for contributors
  • Enhanced development guidelines to include test suite validation

Enhanced PR Guidelines:

  • Updated .github/copilot-instructions.md with more explicit requirements for CHANGELOG.md and README.md updates
  • Added specific guidance about documenting new functionality and infrastructure changes
  • Included testing requirements to prevent similar oversights

This ensures future PRs will properly document changes in both files as required by the repository standards.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid-url-for-testing.invalid
    • Triggering command: curl -s http://invalid-url-for-testing.invalid (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Contributor

@DutchmanNL DutchmanNL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , implementing this PR will update the version to 0.4.0, handling accordingly and use the automation/scripting for this purpose and validate all reference are updated correctly

Title for this release: Automated Version handling & validation by GitHub actions

…le from CI workflow

Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 18, 2025

@copilot , implementing this PR will update the version to 0.4.0, handling accordingly and use the automation/scripting for this purpose and validate all reference are updated correctly

Title for thi...

Updated the version to 0.4.0 using the automated version management scripts (./scripts/manage-versions.sh update 0.4.0) and updated the CHANGELOG.md with the requested title "Automated Version handling & validation by GitHub actions". All version references across template.md, README.md, and .github/copilot-instructions.md are now consistently updated to 0.4.0 and verified with the consistency check. Completed in commit ef65fb0.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid-url-for-testing.invalid
    • Triggering command: curl -s http://invalid-url-for-testing.invalid (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Implement comprehensive automated testing infrastructure for all repository scripts Implement comprehensive automated testing infrastructure and version management for all repository scripts Sep 18, 2025
Copilot AI requested a review from DutchmanNL September 18, 2025 20:37
@DutchmanNL DutchmanNL dismissed their stale review September 18, 2025 20:40

improvements implemented

@DutchmanNL
Copy link
Contributor

@copilot testing is failing: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/actions/runs/17840762631/job/50729644734?pr=17#step:1:40

update framework accordingly and test your changes

…tions to v4

Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 18, 2025

@copilot testing is failing: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/actions/runs/17840762631/job/50729644734?pr=17#step:1:40

update framework accordingly and test your changes

Fixed the CI testing failures with commit b31c8e1. The issues were:

  1. Missing execute permissions - Test files lacked execute permissions in the repository
  2. Outdated action version - Updated upload-artifact from v3 to v4

The workflow now properly sets execute permissions for all test files (chmod +x tests/*.sh) and uses the latest action versions. All 54 tests pass successfully both locally and should now pass in CI.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid-url-for-testing.invalid
    • Triggering command: curl -s http://invalid-url-for-testing.invalid (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@DutchmanNL DutchmanNL marked this pull request as ready for review September 18, 2025 20:50
Copilot AI review requested due to automatic review settings September 18, 2025 20:50
@DutchmanNL DutchmanNL merged commit 1abed14 into main Sep 18, 2025
1 check passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive automated testing infrastructure for all repository scripts and introduces version management automation. The primary purpose is to ensure script reliability and prevent regressions through systematic testing of all automation tools used in the ioBroker Copilot Instructions repository.

Key changes:

  • Created complete test framework with 54 tests covering all scripts and integration scenarios
  • Added GitHub Actions CI/CD workflow for automated testing on repository changes
  • Updated repository version to 0.4.0 with comprehensive documentation updates

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/test-runner.sh Main test execution framework providing isolated environments and comprehensive reporting
tests/test-update-versions.sh 11 tests for documentation version synchronization script functionality
tests/test-manage-versions.sh 13 tests for master version management script commands and validation
tests/test-integration.sh 10 integration tests for cross-script workflows and end-to-end scenarios
tests/test-extract-version.sh 9 tests for version and date extraction utility functions
tests/test-check-template-version.sh 11 tests for template version comparison and remote checking features
TESTING.md Comprehensive documentation for the automated testing infrastructure and usage guidelines
.github/workflows/test-scripts.yml GitHub Actions workflow for continuous integration testing
template.md Version bump from 0.3.1 to 0.4.0
README.md Added testing framework documentation and updated version references
CHANGELOG.md Detailed changelog entry for automated testing infrastructure (Fixes #16)
.github/copilot-instructions.md Updated with mandatory testing requirements and guidelines


# Test actual version replacement in README
test_version_replacement() {
local original_version=$(grep "Latest Version:" "$TEST_DIR/README.md" | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' ')
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern for extracting version numbers is duplicated and complex. Consider creating a helper function to extract versions from README.md to improve maintainability and reduce the risk of inconsistent patterns.

Copilot uses AI. Check for mistakes.
"$TEST_DIR/scripts/update-versions.sh" >/dev/null 2>&1

# Check if README was updated
local updated_version=$(grep "Latest Version:" "$TEST_DIR/README.md" | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' ')
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern for extracting version numbers is duplicated and complex. Consider creating a helper function to extract versions from README.md to improve maintainability and reduce the risk of inconsistent patterns.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +21
# Test full version update workflow
test_version_update_workflow() {
cd "$TEST_DIR"

# Store original versions
local original_template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')

# Update to a test version
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1

# Check if all files were updated
local template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
local readme_version=$(grep "Latest Version:" README.md | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' ')
local copilot_version=$(grep "^**Version:**" .github/copilot-instructions.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple similar grep/sed patterns for version extraction are repeated throughout the test. Consider creating a shared helper function for version extraction to reduce code duplication and improve maintainability.

Suggested change
# Test full version update workflow
test_version_update_workflow() {
cd "$TEST_DIR"
# Store original versions
local original_template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
# Update to a test version
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1
# Check if all files were updated
local template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
local readme_version=$(grep "Latest Version:" README.md | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' ')
local copilot_version=$(grep "^**Version:**" .github/copilot-instructions.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
# Helper function to extract version from a file using a grep pattern
extract_version_from_file() {
local file="$1"
local pattern="$2"
grep "$pattern" "$file" | head -1 | sed 's/.*\*\* *v*\?//' | tr -d ' '
}
# Test full version update workflow
test_version_update_workflow() {
cd "$TEST_DIR"
# Store original versions
local original_template_version=$(extract_version_from_file "template.md" "^**Version:**")
# Update to a test version
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1
# Check if all files were updated
local template_version=$(extract_version_from_file "template.md" "^**Version:**")
local readme_version=$(extract_version_from_file "README.md" "Latest Version:")
local copilot_version=$(extract_version_from_file ".github/copilot-instructions.md" "^**Version:**")

Copilot uses AI. Check for mistakes.
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1

# Check if all files were updated
local template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple similar grep/sed patterns for version extraction are repeated throughout the test. Consider creating a shared helper function for version extraction to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +21
# Test full version update workflow
test_version_update_workflow() {
cd "$TEST_DIR"

# Store original versions
local original_template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')

# Update to a test version
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1

# Check if all files were updated
local template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
local readme_version=$(grep "Latest Version:" README.md | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' ')
local copilot_version=$(grep "^**Version:**" .github/copilot-instructions.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple similar grep/sed patterns for version extraction are repeated throughout the test. Consider creating a shared helper function for version extraction to reduce code duplication and improve maintainability.

Suggested change
# Test full version update workflow
test_version_update_workflow() {
cd "$TEST_DIR"
# Store original versions
local original_template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
# Update to a test version
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1
# Check if all files were updated
local template_version=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
local readme_version=$(grep "Latest Version:" README.md | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' ')
local copilot_version=$(grep "^**Version:**" .github/copilot-instructions.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ')
# Helper function to extract version from a file
# Usage: extract_version_from_file <file> <type>
# type: "template" | "readme" | "copilot"
extract_version_from_file() {
local file="$1"
local type="$2"
case "$type" in
template|copilot)
grep "^**Version:**" "$file" | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' '
;;
readme)
grep "Latest Version:" "$file" | head -1 | sed 's/.*Latest Version:\*\* v*//' | tr -d ' '
;;
*)
echo "Unknown type: $type" >&2
return 1
;;
esac
}
# Test full version update workflow
test_version_update_workflow() {
cd "$TEST_DIR"
# Store original versions
local original_template_version=$(extract_version_from_file template.md template)
# Update to a test version
./scripts/manage-versions.sh update 1.2.3 >/dev/null 2>&1
# Check if all files were updated
local template_version=$(extract_version_from_file template.md template)
local readme_version=$(extract_version_from_file README.md readme)
local copilot_version=$(extract_version_from_file .github/copilot-instructions.md copilot)

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +114
cp -r "$REPO_ROOT"/* "$TEST_DIR/" 2>/dev/null || true

# Ensure hidden directories are copied (like .github)
cp -r "$REPO_ROOT"/.* "$TEST_DIR/" 2>/dev/null || true
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy operations suppress all errors with || true, which could mask legitimate permission or disk space issues. Consider checking for specific expected errors (like 'cannot copy . and ..') while still reporting unexpected failures.

Suggested change
cp -r "$REPO_ROOT"/* "$TEST_DIR/" 2>/dev/null || true
# Ensure hidden directories are copied (like .github)
cp -r "$REPO_ROOT"/.* "$TEST_DIR/" 2>/dev/null || true
# Copy non-hidden files/directories
if ! cp_output=$(cp -r "$REPO_ROOT"/* "$TEST_DIR/" 2>&1); then
echo -e "${RED}Error copying files to test directory:${NC} $cp_output"
exit 1
fi
# Ensure hidden directories are copied (like .github)
if ! cp_hidden_output=$(cp -r "$REPO_ROOT"/.* "$TEST_DIR/" 2>&1); then
# Ignore expected errors about . and .., but fail on others
if ! echo "$cp_hidden_output" | grep -qE 'cannot copy .*: No such file or directory|cannot copy .:.*|cannot copy ..:.*'; then
echo -e "${RED}Error copying hidden files to test directory:${NC} $cp_hidden_output"
exit 1
fi
fi

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +114
cp -r "$REPO_ROOT"/* "$TEST_DIR/" 2>/dev/null || true

# Ensure hidden directories are copied (like .github)
cp -r "$REPO_ROOT"/.* "$TEST_DIR/" 2>/dev/null || true
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy operations suppress all errors with || true, which could mask legitimate permission or disk space issues. Consider checking for specific expected errors (like 'cannot copy . and ..') while still reporting unexpected failures.

Suggested change
cp -r "$REPO_ROOT"/* "$TEST_DIR/" 2>/dev/null || true
# Ensure hidden directories are copied (like .github)
cp -r "$REPO_ROOT"/.* "$TEST_DIR/" 2>/dev/null || true
# Copy non-hidden files/directories
if ! cp -r "$REPO_ROOT"/* "$TEST_DIR/" 2>err.log; then
if grep -vqE "No such file or directory|cannot stat" err.log; then
echo -e "${RED}Error copying files to test directory:${NC}"
cat err.log
rm -f err.log
exit 1
fi
rm -f err.log
fi
# Ensure hidden directories are copied (like .github)
if ! cp -r "$REPO_ROOT"/.* "$TEST_DIR/" 2>err.log; then
# Only suppress errors about . and .., which are expected
if grep -vqE "cannot copy .*: No such file or directory|cannot copy .:.*|cannot copy ..:.*" err.log; then
echo -e "${RED}Error copying hidden files to test directory:${NC}"
cat err.log
rm -f err.log
exit 1
fi
rm -f err.log
fi

Copilot uses AI. Check for mistakes.
@DutchmanNL DutchmanNL deleted the copilot/fix-16 branch September 18, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

automated testing

3 participants