-
Notifications
You must be signed in to change notification settings - Fork 2
Implement centralized metadata system and eliminate content duplication #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6cea84b
Initial plan
Copilot 195c0f6
Implement centralized metadata system and clean up duplication
Copilot 391f0e2
Update tests/test-centralized-metadata.sh
DutchmanNL b51c7b4
Update scripts/manage-versions.sh
DutchmanNL 9a667c5
Address feedback: Move manual commands to advanced section and improv…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| name: Validate Repository Consistency | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| validate-consistency: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Validate metadata and version consistency | ||
| run: | | ||
| echo "🔍 Validating repository consistency..." | ||
|
|
||
| # Check if metadata file exists and is valid JSON | ||
| if [[ ! -f "config/metadata.json" ]]; then | ||
| echo "❌ Metadata file not found: config/metadata.json" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! jq empty config/metadata.json 2>/dev/null; then | ||
| echo "❌ Invalid JSON in metadata file" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ Metadata file is valid JSON" | ||
|
|
||
| # Extract versions from different sources | ||
| METADATA_VERSION=$(jq -r '.version' config/metadata.json) | ||
| TEMPLATE_VERSION=$(grep "^**Version:**" template.md | head -1 | sed 's/.*Version:\*\* *//' | tr -d ' ' || echo "unknown") | ||
| PACKAGE_VERSION=$(grep '"version":' package.json | head -1 | sed 's/.*"version": *"//;s/".*//' || echo "unknown") | ||
|
|
||
| echo "📋 Version Comparison:" | ||
| echo " Metadata: $METADATA_VERSION" | ||
| echo " Template: $TEMPLATE_VERSION" | ||
| echo " Package: $PACKAGE_VERSION" | ||
|
|
||
| # Check version consistency | ||
| INCONSISTENT=false | ||
|
|
||
| if [[ "$METADATA_VERSION" != "$TEMPLATE_VERSION" && "$TEMPLATE_VERSION" != "unknown" ]]; then | ||
| echo "❌ Metadata version ($METADATA_VERSION) doesn't match template version ($TEMPLATE_VERSION)" | ||
| INCONSISTENT=true | ||
| fi | ||
|
|
||
| if [[ "$METADATA_VERSION" != "$PACKAGE_VERSION" && "$PACKAGE_VERSION" != "unknown" ]]; then | ||
| echo "❌ Metadata version ($METADATA_VERSION) doesn't match package.json version ($PACKAGE_VERSION)" | ||
| INCONSISTENT=true | ||
| fi | ||
|
|
||
| if [[ "$INCONSISTENT" == "true" ]]; then | ||
| echo "" | ||
| echo "💡 Run './scripts/manage-versions.sh sync' or './scripts/manage-versions.sh update <version>' to fix inconsistencies" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ All versions are consistent!" | ||
|
|
||
| - name: Validate snippet files exist | ||
| run: | | ||
| echo "📄 Validating snippet files..." | ||
|
|
||
| required_snippets=( | ||
| "snippets/version-check-command.md" | ||
| "snippets/github-action-version-check.yml" | ||
| "snippets/version-management-commands.md" | ||
| ) | ||
|
|
||
| for snippet in "${required_snippets[@]}"; do | ||
| if [[ -f "$snippet" ]]; then | ||
| echo "✅ $snippet exists" | ||
| else | ||
| echo "❌ Missing required snippet: $snippet" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| - name: Validate documentation references snippets | ||
| run: | | ||
| echo "🔗 Validating documentation uses centralized snippets..." | ||
|
|
||
| # Check that docs reference snippets instead of duplicating content | ||
| duplicated_content_count=0 | ||
|
|
||
| # Count GitHub Action YAML duplications (should be minimal now) | ||
| yaml_duplications=$(grep -r -l "name:.*Check.*Template.*Version" docs/ templates/ 2>/dev/null | wc -l) | ||
| echo "GitHub Action YAML references in docs/templates: $yaml_duplications" | ||
|
|
||
| if [[ $yaml_duplications -gt 1 ]]; then | ||
| echo "⚠️ Consider further consolidation of GitHub Action YAML content" | ||
| fi | ||
|
|
||
| # Check that curl commands are referenced via snippets | ||
| snippet_references=$(grep -r "snippets/" docs/ templates/ 2>/dev/null | wc -l) | ||
| echo "Snippet references found: $snippet_references" | ||
|
|
||
| if [[ $snippet_references -lt 3 ]]; then | ||
| echo "❌ Documentation should reference more centralized snippets" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ Documentation properly references centralized snippets" | ||
|
|
||
| - name: Run centralized metadata tests | ||
| run: | | ||
| echo "🧪 Running centralized metadata tests..." | ||
| if [[ -f "tests/test-centralized-metadata.sh" ]]; then | ||
| chmod +x tests/test-centralized-metadata.sh | ||
| ./tests/test-centralized-metadata.sh | ||
| else | ||
| echo "⚠️ Centralized metadata tests not found" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # Centralized Configuration and Snippets | ||
|
|
||
| This directory contains the centralized configuration and reusable content snippets for the ioBroker Copilot Instructions repository. | ||
|
|
||
| ## Directory Structure | ||
|
|
||
| ``` | ||
| config/ | ||
| ├── metadata.json # Centralized repository metadata and configuration | ||
| └── README.md # This file | ||
|
|
||
| snippets/ | ||
| ├── version-check-command.md # Reusable version check command | ||
| ├── github-action-version-check.yml # GitHub Action template for version monitoring | ||
| └── version-management-commands.md # Version management script commands | ||
| ``` | ||
|
|
||
| ## Metadata Configuration (metadata.json) | ||
|
|
||
| The `metadata.json` file serves as the single source of truth for: | ||
|
|
||
| - **Version Information**: Current template version | ||
| - **Repository URLs**: GitHub repository and raw content URLs | ||
| - **Script Paths**: Locations of management scripts | ||
| - **Automation Config**: GitHub Action settings and schedules | ||
|
|
||
| ### Schema | ||
|
|
||
| ```json | ||
| { | ||
| "version": "X.Y.Z", // Current template version | ||
| "repository": { | ||
| "url": "https://github.com/...", // Repository homepage URL | ||
| "raw_base": "https://raw.github..." // Raw content base URL | ||
| }, | ||
| "template": { | ||
| "file": "template.md", // Template filename | ||
| "target_path": ".github/..." // Target installation path | ||
| }, | ||
| "scripts": { | ||
| "check_template_version": "scripts/...", // Version check script path | ||
| "manage_versions": "scripts/..." // Version management script path | ||
| }, | ||
| "automation": { | ||
| "workflow_file": ".github/workflows/...", // GitHub Action filename | ||
| "cron_schedule": "0 0 * * 0", // Weekly schedule | ||
| "labels": ["template-update", ...] // Issue labels | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Reusable Snippets | ||
|
|
||
| ### Version Check Command (`version-check-command.md`) | ||
|
|
||
| Contains the standardized curl command for checking template versions. Referenced throughout documentation instead of duplicating the command. | ||
|
|
||
| **Usage in Documentation**: | ||
| ```markdown | ||
| <!-- Include version check instructions --> | ||
| ``` | ||
|
|
||
| ### GitHub Action Template (`github-action-version-check.yml`) | ||
|
|
||
| Complete GitHub Action workflow for automated template version monitoring. Used by templates and documentation instead of duplicating the YAML. | ||
|
|
||
| **Features**: | ||
| - Weekly automated checks | ||
| - Automatic issue creation | ||
| - Custom content preservation | ||
| - Both setup and update scenarios | ||
|
|
||
| ### Version Management Commands (`version-management-commands.md`) | ||
|
|
||
| Standard documentation for the version management script commands and their functions. | ||
|
|
||
| ## Integration with Scripts | ||
|
|
||
| The centralized metadata is used by: | ||
|
|
||
| - **`scripts/shared-utils.sh`**: Utility functions for accessing metadata | ||
| - **`scripts/extract-version.sh`**: Enhanced with metadata fallback | ||
| - **`scripts/manage-versions.sh`**: Updates metadata when versions change | ||
| - **`scripts/check-template-version.sh`**: Uses metadata for URL generation | ||
|
|
||
| ## Benefits of Centralization | ||
|
|
||
| ### Before (Duplicated Content) | ||
| - Version check curl command duplicated in 6+ files | ||
| - GitHub Action YAML duplicated in 3+ files | ||
| - Version management instructions repeated across docs | ||
| - Manual updates required in multiple locations | ||
|
|
||
| ### After (Centralized System) | ||
| - **Single Source of Truth**: All metadata in one place | ||
| - **Automatic Consistency**: Scripts sync versions across files | ||
| - **Reusable Snippets**: Documentation references shared content | ||
| - **Easier Maintenance**: Update once, apply everywhere | ||
| - **Version Validation**: Automated consistency checking | ||
|
|
||
| ## Validation and Testing | ||
|
|
||
| The centralized system includes: | ||
|
|
||
| - **JSON Schema Validation**: Metadata file structure validation | ||
| - **Consistency Checks**: Version synchronization across files | ||
| - **Integration Tests**: Script and documentation integration | ||
| - **GitHub Action**: Automated validation in CI/CD | ||
| - **Comprehensive Test Suite**: `tests/test-centralized-metadata.sh` | ||
|
|
||
| ## Usage for Documentation | ||
|
|
||
| When writing documentation, reference snippets instead of duplicating content: | ||
|
|
||
| ```markdown | ||
| ### Version Check | ||
|
|
||
| Use our [version check command](../snippets/version-check-command.md). | ||
|
|
||
| ### GitHub Action Setup | ||
|
|
||
| For automated monitoring, see our [GitHub Action template](../snippets/github-action-version-check.yml). | ||
| ``` | ||
|
|
||
| ## Updating the System | ||
|
|
||
| ### Adding New Metadata | ||
| 1. Update `config/metadata.json` with new fields | ||
| 2. Update `scripts/shared-utils.sh` accessor functions | ||
| 3. Add validation to `tests/test-centralized-metadata.sh` | ||
| 4. Update this README with schema documentation | ||
|
|
||
| ### Creating New Snippets | ||
| 1. Create snippet file in `snippets/` directory | ||
| 2. Update documentation to reference the snippet | ||
| 3. Remove duplicated content from existing files | ||
| 4. Add tests for snippet usage and content | ||
|
|
||
| ### Version Updates | ||
| Use the centralized version management: | ||
| ```bash | ||
| ./scripts/manage-versions.sh update X.Y.Z | ||
| ``` | ||
|
|
||
| This automatically updates: | ||
| - `config/metadata.json` | ||
| - `template.md` | ||
| - `package.json` | ||
| - All derived documentation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "version": "0.4.0", | ||
| "repository": { | ||
| "url": "https://github.com/DrozmotiX/ioBroker-Copilot-Instructions", | ||
| "raw_base": "https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main" | ||
| }, | ||
| "template": { | ||
| "file": "template.md", | ||
| "target_path": ".github/copilot-instructions.md" | ||
| }, | ||
| "scripts": { | ||
| "check_template_version": "scripts/check-template-version.sh", | ||
| "manage_versions": "scripts/manage-versions.sh" | ||
| }, | ||
| "automation": { | ||
| "workflow_file": ".github/workflows/check-copilot-template.yml", | ||
| "cron_schedule": "0 0 * * 0", | ||
| "labels": ["template-update", "automation"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the script is for advanced users, move to that section. regular and best practise should stick to the automation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the manual version check script to the new "Advanced Usage" section in the README. Regular users are now guided to use the automated processes first, with manual commands available for advanced users who need more control. Commit: 9a667c5