fix: remove remaining DefinitionParser and definitions/ references
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (push) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (push) Blocked by required conditions
Generic: Repo Health / Release configuration (push) Blocked by required conditions
Generic: Repo Health / Scripts governance (push) Blocked by required conditions
Generic: Repo Health / Repository health (push) Blocked by required conditions
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Universal: Cascade Main → Dev / Cascade main → branches (push) Successful in 3s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 44s
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (push) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (push) Blocked by required conditions
Generic: Repo Health / Release configuration (push) Blocked by required conditions
Generic: Repo Health / Scripts governance (push) Blocked by required conditions
Generic: Repo Health / Repository health (push) Blocked by required conditions
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Universal: Cascade Main → Dev / Cascade main → branches (push) Successful in 3s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 44s
- Remove generateRepositoryDefinition() method from RepositorySynchronizer - Remove SYNC_DEFINITION_DIR constant - Remove .tf version check from check_version_consistency.php - Clean up stale comments referencing DefinitionParser Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,8 +32,6 @@ use RuntimeException;
|
||||
*/
|
||||
class RepositorySynchronizer
|
||||
{
|
||||
/** @deprecated Sync definitions removed — Template repos are now canonical */
|
||||
private const SYNC_DEFINITION_DIR = 'definitions/sync';
|
||||
/** Override file path — resolved at runtime via adapter's getMetadataDir(). */
|
||||
private const SYNC_OVERRIDE_FILE_SUFFIX = 'override.tf';
|
||||
private const STANDARDS_VERSION = '04.06.00';
|
||||
@@ -234,10 +232,6 @@ class RepositorySynchronizer
|
||||
if ($prNumber) {
|
||||
$this->logger->logInfo("Successfully created PR #{$prNumber} for {$repo}");
|
||||
|
||||
// Generate / update definitions/sync/{repo}.def.tf AFTER the sync so it
|
||||
// reflects exactly what was pushed in this run.
|
||||
$this->generateRepositoryDefinition($org, $repo, $platform, $repoInfo, $summary);
|
||||
|
||||
return (int) $prNumber;
|
||||
}
|
||||
|
||||
@@ -265,136 +259,6 @@ class RepositorySynchronizer
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate / update the repository tracking definition after a successful sync.
|
||||
*
|
||||
* Writes definitions/sync/{repo}.def.tf with:
|
||||
* - the base platform definition as a foundation
|
||||
* - a sync_record block recording what was actually pushed (files created/updated/skipped)
|
||||
* - full timestamps and platform metadata
|
||||
*
|
||||
* @param string $org
|
||||
* @param string $repo
|
||||
* @param string $platform Detected platform slug (e.g. 'dolibarr')
|
||||
* @param array $repoInfo Raw GitHub API repository object
|
||||
* @param array $summary Sync result from createSyncPR: {copied[], skipped[], total}
|
||||
* @return bool
|
||||
*/
|
||||
private function generateRepositoryDefinition(
|
||||
string $org,
|
||||
string $repo,
|
||||
string $platform,
|
||||
array $repoInfo,
|
||||
array $summary
|
||||
): bool {
|
||||
try {
|
||||
$this->logger->logInfo("Writing sync tracking definition for {$org}/{$repo}");
|
||||
|
||||
$timestamp = date('c');
|
||||
$description = addslashes($repoInfo['description'] ?? '');
|
||||
$defaultBranch = $repoInfo['default_branch'] ?? 'main';
|
||||
|
||||
// Resolve repo root relative to this file's location
|
||||
$repoRoot = dirname(dirname(__DIR__));
|
||||
$baseDefPath = "{$repoRoot}/definitions/default/{$platform}.tf";
|
||||
if (!file_exists($baseDefPath)) {
|
||||
$baseDefPath = "{$repoRoot}/definitions/default/generic.tf";
|
||||
}
|
||||
$baseDefinition = file_get_contents($baseDefPath) ?: '';
|
||||
|
||||
// Extract definition version from the source .tf metadata block
|
||||
$definitionVersion = 'unknown';
|
||||
if (preg_match('/\bversion\s*=\s*"([^"]+)"/', $baseDefinition, $vm)) {
|
||||
$definitionVersion = $vm[1];
|
||||
}
|
||||
|
||||
// Cache the nullable sub-arrays once to avoid repeated null-coalescing
|
||||
$copiedItems = $summary['copied'] ?? [];
|
||||
$skippedItems = $summary['skipped'] ?? [];
|
||||
$totalCount = (int) ($summary['total'] ?? 0);
|
||||
|
||||
// Build the synced_files list
|
||||
$syncedEntries = '';
|
||||
foreach ($copiedItems as $item) {
|
||||
$action = addslashes($item['action'] ?? 'synced');
|
||||
$file = addslashes($item['file'] ?? '');
|
||||
$syncedEntries .= " { path = \"{$file}\" action = \"{$action}\" },\n";
|
||||
}
|
||||
|
||||
$skippedEntries = '';
|
||||
foreach ($skippedItems as $item) {
|
||||
$file = addslashes($item['file'] ?? '');
|
||||
$reason = addslashes($item['reason'] ?? '');
|
||||
$skippedEntries .= " { path = \"{$file}\" reason = \"{$reason}\" },\n";
|
||||
}
|
||||
|
||||
$createdCount = count(array_filter($copiedItems, fn($i) => ($i['action'] ?? '') === 'created'));
|
||||
$updatedCount = count(array_filter($copiedItems, fn($i) => ($i['action'] ?? '') === 'updated'));
|
||||
$skippedCount = count($skippedItems);
|
||||
|
||||
// Assemble the definition file using PHP 7.3+ flexible heredoc:
|
||||
// the closing marker is indented, so PHP strips that many leading spaces automatically.
|
||||
$definition = <<<HCL
|
||||
/**
|
||||
* Repository Sync Tracking Definition: {$org}/{$repo}
|
||||
*
|
||||
* Auto-generated by MokoStandards bulk sync on {$timestamp}
|
||||
* Platform : {$platform}
|
||||
* Description: {$description}
|
||||
*
|
||||
* DO NOT EDIT MANUALLY — this file is regenerated on every successful sync.
|
||||
* To change what gets synced, edit definitions/default/{$platform}.tf
|
||||
* and re-run the bulk-repo-sync workflow.
|
||||
*/
|
||||
|
||||
locals {
|
||||
sync_record = {
|
||||
metadata = {
|
||||
repo = "{$org}/{$repo}"
|
||||
default_branch = "{$defaultBranch}"
|
||||
detected_platform = "{$platform}"
|
||||
description = "{$description}"
|
||||
sync_timestamp = "{$timestamp}"
|
||||
source_repo = "mokoconsulting-tech/MokoStandards"
|
||||
base_definition = "definitions/default/{$platform}.tf"
|
||||
}
|
||||
|
||||
sync_stats = {
|
||||
total_files = {$totalCount}
|
||||
created_files = {$createdCount}
|
||||
updated_files = {$updatedCount}
|
||||
skipped_files = {$skippedCount}
|
||||
}
|
||||
|
||||
synced_files = [
|
||||
{$syncedEntries} ]
|
||||
|
||||
skipped_files = [
|
||||
{$skippedEntries} ]
|
||||
}
|
||||
}
|
||||
|
||||
# ---- Base platform definition (reference copy) ----
|
||||
{$baseDefinition}
|
||||
HCL;
|
||||
|
||||
$defFilePath = "{$repoRoot}/" . self::SYNC_DEFINITION_DIR . "/{$repo}.def.tf";
|
||||
|
||||
if (!is_dir(dirname($defFilePath))) {
|
||||
mkdir(dirname($defFilePath), 0755, true);
|
||||
}
|
||||
|
||||
file_put_contents($defFilePath, $definition);
|
||||
$this->logger->logInfo("Wrote sync tracking definition: {$defFilePath}");
|
||||
$this->metrics->increment('definitions_generated');
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$this->logger->logError("Failed to write tracking definition for {$repo}: " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect platform from repository info
|
||||
*/
|
||||
@@ -515,7 +379,7 @@ HCL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a PR with sync updates driven by the flat entry list from DefinitionParser.
|
||||
* Create a PR with sync updates driven by the file entry list.
|
||||
*
|
||||
* @param string $org
|
||||
* @param string $repo
|
||||
|
||||
@@ -165,46 +165,8 @@ class CheckVersionConsistency extends CliFramework
|
||||
$this->progress($phpTotal, $phpTotal, '', true);
|
||||
|
||||
// ── Check Terraform definition files ─────────────────────────────────
|
||||
// Each .tf file has TWO version locations that must both match:
|
||||
// - Block-comment header: * Version: XX.XX.XX
|
||||
// - HCL metadata field: version = "XX.XX.XX"
|
||||
$this->section('Checking Terraform definition files');
|
||||
|
||||
$defFiles = glob($path . '/definitions/default/*.tf') ?: [];
|
||||
$defTotal = count($defFiles);
|
||||
|
||||
foreach ($defFiles as $i => $file) {
|
||||
$this->progress($i + 1, $defTotal, basename($file));
|
||||
$content = (string) file_get_contents($file);
|
||||
$filePassed = true;
|
||||
$rel = str_replace($path . '/', '', $file);
|
||||
|
||||
// Block-comment header version
|
||||
preg_match_all('/\*\s*Version:\s*(\d{2}\.\d{2}\.\d{2})/', $content, $headerMatches, PREG_OFFSET_CAPTURE);
|
||||
foreach ($headerMatches[1] as $match) {
|
||||
if ($match[0] !== $expected) {
|
||||
$this->progress($i + 1, $defTotal, '', true);
|
||||
$this->status(false, $rel, "header Version: found {$match[0]}, expected {$expected}");
|
||||
$issues[] = $rel;
|
||||
$filePassed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// HCL metadata version field
|
||||
preg_match_all('/^\s*version\s*=\s*"(\d{2}\.\d{2}\.\d{2})"/m', $content, $hclMatches, PREG_OFFSET_CAPTURE);
|
||||
foreach ($hclMatches[1] as $match) {
|
||||
if ($match[0] !== $expected) {
|
||||
$this->progress($i + 1, $defTotal, '', true);
|
||||
$this->status(false, $rel, "HCL version = found {$match[0]}, expected {$expected}");
|
||||
$issues[] = $rel;
|
||||
$filePassed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filePassed) {
|
||||
$this->status(true, $rel);
|
||||
}
|
||||
}
|
||||
// HCL definition files removed — Template repos are now canonical
|
||||
// Skipping .tf version check
|
||||
$this->progress($defTotal, $defTotal, '', true);
|
||||
|
||||
// ── Summary ───────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user