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
53 changes: 48 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Repository Purpose:** This repository maintains the template and best practices for GitHub Copilot instructions used in ioBroker adapter development.

**Version:** 0.3.1
**Version:** 0.4.0

This file contains instructions specific to maintaining and improving this template repository, not for ioBroker adapter development (that's in `template.md`).

Expand All @@ -20,10 +20,14 @@ You are working on the ioBroker Copilot Instructions template repository. This r
- `template.md` - The main template file that developers copy to their repositories as `.github/copilot-instructions.md`
- `README.md` - Repository documentation explaining how to use the template
- `CHANGELOG.md` - Version history and detailed change documentation
- `TESTING.md` - Automated testing infrastructure documentation
- `scripts/check-template-version.sh` - Version checking utility for users
- `scripts/manage-versions.sh` - Master version management script (show/check/sync/update commands)
- `scripts/extract-version.sh` - Dynamic version extraction from template and current dates
- `scripts/update-versions.sh` - Automated documentation synchronization script
- `tests/test-runner.sh` - Main test execution framework for all scripts
- `tests/test-*.sh` - Comprehensive test suites for each script and integration scenarios
- `.github/workflows/test-scripts.yml` - GitHub Actions workflow for continuous testing
- `.github/copilot-instructions.md` - THIS file - repository-specific instructions

## Template Development Guidelines
Expand Down Expand Up @@ -54,6 +58,42 @@ You are working on the ioBroker Copilot Instructions template repository. This r
- Validate all code examples for syntax and functionality
- Ensure version management scripts work correctly (`manage-versions.sh`, `extract-version.sh`, `update-versions.sh`)
- Verify download URLs and curl commands in documentation
- **Run automated test suite before any changes**: `./tests/test-runner.sh`
- **All scripts must have corresponding tests** in the `tests/` directory
- **New functionality requires new test cases** to prevent regressions

### Automated Testing Requirements
When adding new scripts or modifying existing ones, you **MUST**:

1. **Create/Update Tests**: Add comprehensive test cases in the appropriate `test-<script-name>.sh` file
2. **Test All Functions**: Cover success scenarios, error conditions, and edge cases
3. **Validate Dependencies**: Ensure tests check for required files and dependencies
4. **Test Integration**: Add integration tests if scripts interact with other components
5. **Run Full Suite**: Execute `./tests/test-runner.sh` to verify all tests pass
6. **Update Documentation**: Modify `TESTING.md` if adding new testing patterns

#### Test Categories Required:
- **Unit Tests**: Individual function and command-line option testing
- **Integration Tests**: Script interaction and workflow testing
- **Error Handling Tests**: Missing files, invalid parameters, network failures
- **Consistency Tests**: Version synchronization and file state validation

#### Test Framework Usage:
```bash
# Run all tests
./tests/test-runner.sh

# Run specific test file
./tests/test-runner.sh tests/test-extract-version.sh

# Add new test to existing file
run_test_with_output \
"Test description" \
"command to test" \
"expected output pattern"
```

GitHub Copilot will automatically validate if new test cases should be created or existing ones removed when new functionality is added.

## Contributing to the Template

Expand Down Expand Up @@ -93,13 +133,16 @@ You are working on the ioBroker Copilot Instructions template repository. This r
- Close duplicate or outdated issues promptly

### Pull Request Guidelines
- **ALWAYS update CHANGELOG.md** - Every PR that introduces new functionality, fixes issues, or makes changes must include a detailed changelog entry with issue references (e.g., "Fixes #11")
- PRs must update version numbers appropriately
- Include detailed CHANGELOG.md entries for user-facing changes
- **ALWAYS update CHANGELOG.md** - Every PR that introduces new functionality, fixes issues, or makes changes must include a detailed changelog entry with issue references (e.g., "Fixes #16")
- **ALWAYS update README.md** - When adding new functionality, infrastructure, or changing how users interact with the repository, update the relevant sections of README.md
- PRs must update version numbers appropriately using the dynamic version management system
- Include detailed CHANGELOG.md entries for user-facing changes with specific details about what was added/changed/fixed
- Test changes against multiple ioBroker adapter projects when possible
- Update README.md if usage instructions change
- Update README.md if usage instructions, new features, or repository structure changes
- Verify dynamic version management system continues to work (`./scripts/manage-versions.sh check`)
- **Run the complete test suite** (`./tests/test-runner.sh`) to ensure all tests pass
- Reference the specific issue number in both commit messages and changelog entries
- **Document new testing requirements** in TESTING.md when adding new scripts or functionality

### Release Process
- Use dynamic version management: `./scripts/manage-versions.sh update X.Y.Z`
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/test-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Automated Script Testing

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
# Allow manual trigger

jobs:
test-scripts:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Make test runner executable
run: chmod +x tests/test-runner.sh

- name: Make all scripts executable
run: |
chmod +x scripts/*.sh
chmod +x tests/*.sh

- name: Run script tests
run: ./tests/test-runner.sh

- name: Verify script functionality
run: |
echo "🔍 Verifying script functionality..."
./scripts/manage-versions.sh show
./scripts/extract-version.sh template
./scripts/check-template-version.sh

- name: Test version consistency
run: |
echo "🔍 Testing version consistency..."
if ! ./scripts/manage-versions.sh check; then
echo "❌ Version inconsistency detected!"
exit 1
else
echo "✅ All versions are consistent"
fi

# Optional: Create artifact with test results
- name: Create test report
if: always()
run: |
echo "# Test Report - $(date)" > test-report.md
echo "" >> test-report.md
echo "## Script Status" >> test-report.md
echo "" >> test-report.md
./scripts/manage-versions.sh show >> test-report.md 2>&1 || true
echo "" >> test-report.md
echo "## Version Check" >> test-report.md
echo "" >> test-report.md
./scripts/manage-versions.sh check >> test-report.md 2>&1 || true

- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: script-test-report
path: test-report.md
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ All notable changes to the ioBroker Copilot Instructions template will be docume
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2025-01-XX
## [0.4.0] - 2025-09-XX - Automated Version handling & validation by GitHub actions

### Added
- **Dynamic Version Management System** - Comprehensive scripts for automated version handling across all documentation
- **Version Extraction Script** (`scripts/extract-version.sh`) - Dynamically extracts version from template and current dates
- **Documentation Update Script** (`scripts/update-versions.sh`) - Automatically updates version references in README.md
- **Master Version Management** (`scripts/manage-versions.sh`) - Unified interface for version show/check/sync/update operations
- **Comprehensive Automated Testing Infrastructure** - Complete test framework for all repository scripts with 54 tests (Fixes #16)
- **Test Runner** (`tests/test-runner.sh`) - Main test execution framework with isolated environments and detailed reporting
- **Script-Specific Test Suites** - Dedicated test files for each script covering unit, integration, and error scenarios
- **GitHub Actions Workflow** (`.github/workflows/test-scripts.yml`) - Automated CI/CD testing on push, PRs, and scheduled runs
- **Testing Documentation** (`TESTING.md`) - Comprehensive guide for test framework usage and maintenance
- **Test Coverage** - 9 tests for extract-version.sh, 13 for manage-versions.sh, 11 for update-versions.sh, 11 for check-template-version.sh, 10 integration tests

### Changed
- **Separated Repository Instructions** - `.github/copilot-instructions.md` now contains repository-specific instructions for maintaining the template repository
Expand All @@ -29,6 +35,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Eliminated Static Version References** - All version numbers and dates are now dynamically generated from template source
- **Cross-Documentation Consistency** - Automated validation ensures all files reference the same version
- **Date Management** - Automatic current date insertion eliminates stale date references (e.g., "January 2025" → current month/year)
- **Automated Testing Requirements** - Updated Copilot instructions with mandatory testing guidelines for new functionality
- **Quality Assurance Through Testing** - Comprehensive test coverage prevents regressions and ensures script reliability
- **CI/CD Integration** - Automated testing on all repository changes maintains code quality
- Version checking script continues to work with new structure
- Clear separation between template maintenance (this repository) and adapter development (template usage)
- Better documentation workflow for template contributors vs adapter developers
Expand Down
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cd your-iobroker-adapter
# Use the following prompt in your editor:
# "Merge my existing .github/copilot-instructions.md with the ioBroker template
# from https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/template.md
# Keep project-specific content and add version: 0.3.1"
# Keep project-specific content and add version: 0.4.0"
# NOTE: Exclude the HTML comment block at the top of the template"
```

Expand Down Expand Up @@ -74,7 +74,7 @@ git push
To ensure you're using the latest best practices and that your local copy stays synchronized with improvements:

### Current Version
- **Latest Version:** v0.3.1
- **Latest Version:** v0.4.0
- **Template Location:** [`template.md`](template.md)
- **Last Updated:** September 2025

Expand All @@ -83,7 +83,7 @@ To ensure you're using the latest best practices and that your local copy stays
You can validate your local template version by checking the version header in your `.github/copilot-instructions.md` file:

```markdown
**Version:** 0.3.1
**Version:** 0.4.0
**Template Source:** https://github.com/DrozmotiX/ioBroker-Copilot-Instructions
```

Expand Down Expand Up @@ -132,6 +132,34 @@ These scripts ensure that:
- All cross-references remain consistent
- Manual version updates are no longer needed

### Automated Testing Infrastructure

This repository includes a comprehensive automated testing framework that ensures all scripts and automations work correctly:

```bash
# Run all tests (54 total tests)
./tests/test-runner.sh

# Run specific test file
./tests/test-runner.sh tests/test-extract-version.sh

# Tests are automatically run in CI/CD via GitHub Actions
```

**Test Coverage:**
- **Unit Tests**: Individual script functions and parameter validation
- **Integration Tests**: Cross-script workflows and end-to-end scenarios
- **Error Handling Tests**: Missing files, invalid parameters, network failures
- **Consistency Tests**: Version synchronization and file state validation

**Key Features:**
- **Isolated Test Environments**: Each test run uses temporary directories to prevent interference
- **Comprehensive Reporting**: Color-coded output with detailed error messages and debugging information
- **CI/CD Integration**: Automated testing on all repository changes via `.github/workflows/test-scripts.yml`
- **Developer Friendly**: Simple commands with clear documentation in `TESTING.md`

All repository scripts are thoroughly tested to prevent regressions and ensure reliability for the ioBroker community.

#### GitHub Action for Continuous Monitoring

You can set up a GitHub Action to periodically check if your template is up-to-date:
Expand Down Expand Up @@ -216,8 +244,17 @@ We welcome contributions to improve these instructions! Please:
1. Fork this repository
2. Create a feature branch
3. Make your improvements
4. Test with real ioBroker adapter development
5. Submit a pull request with a clear description of changes
4. **Run the test suite**: `./tests/test-runner.sh` to ensure all tests pass
5. **Update documentation**: Add changelog entries and update README if needed
6. Test with real ioBroker adapter development
7. Submit a pull request with a clear description of changes

### Development Guidelines

- All new scripts must have corresponding tests in the `tests/` directory
- Changes to existing scripts require updating relevant test cases
- Follow the testing patterns documented in `TESTING.md`
- Ensure all 54 tests pass before submitting PRs

## 🙏 Acknowledgments

Expand Down
Loading