25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

54 satır
2.0KB

  1. namespace Campaign_Tracker.Server.LegacyData.Schema;
  2. /// <summary>
  3. /// Release-gate entry point (Story 1.7 AC #4).
  4. ///
  5. /// Invoked from <c>Program.cs</c> when the application is launched with the
  6. /// <c>--check-legacy-schema</c> argument. Builds the host, runs the
  7. /// compatibility check synchronously, prints a structured report, and returns
  8. /// an exit code: <c>0</c> when the schema matches the baseline, non-zero (1)
  9. /// when drift is detected. The CI/CD pipeline blocks releases on the non-zero
  10. /// exit code.
  11. /// </summary>
  12. public static class LegacySchemaReleaseGate
  13. {
  14. public const string CommandLineFlag = "--check-legacy-schema";
  15. public const int ExitCodePass = 0;
  16. public const int ExitCodeFail = 1;
  17. public static bool ShouldRun(string[] args) =>
  18. args.Any(a => string.Equals(a, CommandLineFlag, StringComparison.Ordinal));
  19. public static async Task<int> ExecuteAsync(
  20. ILegacySchemaCompatibilityCheck check,
  21. ILegacySchemaCheckHistory history,
  22. TextWriter output,
  23. CancellationToken cancellationToken = default)
  24. {
  25. var result = await check.RunAsync(cancellationToken).ConfigureAwait(false);
  26. history.Record(result);
  27. WriteReport(result, output);
  28. return result.Passed ? ExitCodePass : ExitCodeFail;
  29. }
  30. public static void WriteReport(LegacySchemaCheckResult result, TextWriter output)
  31. {
  32. if (result.Passed)
  33. {
  34. output.WriteLine(
  35. $"[legacy-schema-check] PASS — {result.TablesVerified} tables verified at {result.CheckedAt:O}, drift=0.");
  36. return;
  37. }
  38. output.WriteLine(
  39. $"[legacy-schema-check] FAIL — {result.TablesVerified} tables verified at {result.CheckedAt:O}, drift={result.DriftCount}.");
  40. foreach (var drift in result.Drifts)
  41. {
  42. var location = drift.ColumnName is null
  43. ? drift.TableName
  44. : $"{drift.TableName}.{drift.ColumnName}";
  45. output.WriteLine($" - [{drift.ChangeType}] {location}: {drift.Detail}");
  46. }
  47. }
  48. }

Powered by TurnKey Linux.