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