chore: Sync MokoStandards workflows and configurations #77
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@@ -61,7 +61,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Detect platform type
|
||||
id: platform
|
||||
@@ -138,7 +138,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
@@ -175,7 +175,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
@@ -213,10 +213,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
@@ -241,10 +241,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v6
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
cache: 'pip'
|
||||
@@ -280,7 +280,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
@@ -309,10 +309,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.21'
|
||||
cache: true
|
||||
@@ -331,7 +331,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
@@ -353,7 +353,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
|
||||
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@@ -54,7 +54,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -124,7 +124,7 @@ jobs:
|
||||
md5sum "${ZIP_NAME}" > "${ZIP_NAME}.md5"
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-package
|
||||
path: |
|
||||
@@ -139,10 +139,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v7.0.0
|
||||
uses: actions/download-artifact@v4.1.3
|
||||
with:
|
||||
name: release-package
|
||||
path: ./artifacts
|
||||
@@ -175,7 +175,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: v${{ steps.version.outputs.version }}
|
||||
name: Release ${{ steps.version.outputs.version }}
|
||||
|
||||
2
.github/workflows/reusable-deploy.yml
vendored
2
.github/workflows/reusable-deploy.yml
vendored
@@ -131,7 +131,7 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v7.0.0
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: deployment-package-${{ needs.detect.outputs.project-type }}
|
||||
path: ./dist
|
||||
|
||||
@@ -32,7 +32,6 @@ import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pickle
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
from dataclasses import dataclass, asdict
|
||||
@@ -82,6 +81,23 @@ class DetectionResult:
|
||||
"metadata": self.metadata
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: Dict[str, any]) -> 'DetectionResult':
|
||||
"""Reconstruct DetectionResult from dictionary (deserialized JSON).
|
||||
|
||||
Args:
|
||||
data: Dictionary with detection result data.
|
||||
|
||||
Returns:
|
||||
DetectionResult instance.
|
||||
"""
|
||||
return cls(
|
||||
platform_type=PlatformType(data["platform_type"]),
|
||||
confidence=data["confidence"],
|
||||
indicators=data["indicators"],
|
||||
metadata=data["metadata"]
|
||||
)
|
||||
|
||||
|
||||
class DetectionCache:
|
||||
"""Simple file-based cache for platform detection results.
|
||||
@@ -122,15 +138,16 @@ class DetectionCache:
|
||||
Returns:
|
||||
Cached DetectionResult if available, None otherwise.
|
||||
"""
|
||||
cache_file = self.cache_dir / f"{self._get_cache_key(repo_path)}.pkl"
|
||||
cache_file = self.cache_dir / f"{self._get_cache_key(repo_path)}.json"
|
||||
|
||||
if not cache_file.exists():
|
||||
return None
|
||||
|
||||
try:
|
||||
with open(cache_file, 'rb') as f:
|
||||
return pickle.load(f)
|
||||
except (pickle.PickleError, OSError, EOFError):
|
||||
with open(cache_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
return DetectionResult.from_dict(data)
|
||||
except (json.JSONDecodeError, KeyError, ValueError, OSError):
|
||||
return None
|
||||
|
||||
def set(self, repo_path: Path, result: DetectionResult) -> None:
|
||||
@@ -140,21 +157,25 @@ class DetectionCache:
|
||||
repo_path: Path to repository.
|
||||
result: Detection result to cache.
|
||||
"""
|
||||
cache_file = self.cache_dir / f"{self._get_cache_key(repo_path)}.pkl"
|
||||
cache_file = self.cache_dir / f"{self._get_cache_key(repo_path)}.json"
|
||||
|
||||
try:
|
||||
with open(cache_file, 'wb') as f:
|
||||
pickle.dump(result, f)
|
||||
except (pickle.PickleError, OSError):
|
||||
pass
|
||||
with open(cache_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(result.to_dict(), f, indent=2)
|
||||
except (OSError, TypeError) as e:
|
||||
# Cache write failure is not critical, log and continue
|
||||
import sys
|
||||
print(f"Warning: Failed to write cache file: {e}", file=sys.stderr)
|
||||
|
||||
def clear(self) -> None:
|
||||
"""Clear all cached detection results."""
|
||||
for cache_file in self.cache_dir.glob("*.pkl"):
|
||||
try:
|
||||
cache_file.unlink()
|
||||
except OSError:
|
||||
pass
|
||||
except OSError as e:
|
||||
# Log error but continue clearing other files
|
||||
import sys
|
||||
print(f"Warning: Failed to delete cache file {cache_file}: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
class PlatformDetector:
|
||||
@@ -228,7 +249,6 @@ class PlatformDetector:
|
||||
indicators: List[str] = []
|
||||
metadata: Dict[str, str] = {}
|
||||
|
||||
manifest_patterns = ["**/*.xml"]
|
||||
skip_dirs = {".git", "vendor", "node_modules", ".github"}
|
||||
|
||||
for xml_file in self.repo_path.glob("**/*.xml"):
|
||||
|
||||
@@ -112,8 +112,9 @@ class RepositoryStructureValidator:
|
||||
return "json"
|
||||
elif content.startswith('<?xml') or content.startswith('<'):
|
||||
return "xml"
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
# Log error and continue to raise ValueError below
|
||||
print(f"Warning: Failed to read schema file for format detection: {e}", file=sys.stderr)
|
||||
|
||||
# Unable to detect format
|
||||
raise ValueError(f"Unable to detect schema format for {self.schema_path}")
|
||||
|
||||
Reference in New Issue
Block a user