fix: promote gitops render-only changes
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -2253,7 +2253,8 @@ const fs = require("node:fs");
|
||||
const plan = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
||||
const buildServices = Array.isArray(plan.buildServices) ? plan.buildServices : [];
|
||||
const affectedServices = Array.isArray(plan.affectedServices) ? plan.affectedServices : [];
|
||||
process.exit(buildServices.length === 0 && affectedServices.length === 0 ? 0 : 1);
|
||||
const willRunGitopsPromote = plan.ciCdPlan && plan.ciCdPlan.willRunGitopsPromote === true;
|
||||
process.exit(!willRunGitopsPromote && buildServices.length === 0 && affectedServices.length === 0 ? 0 : 1);
|
||||
NODE
|
||||
then
|
||||
rm -f /workspace/source/dev-artifacts.json
|
||||
@@ -2333,7 +2334,8 @@ const fs = require("node:fs");
|
||||
const plan = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
||||
const buildServices = Array.isArray(plan.buildServices) ? plan.buildServices : [];
|
||||
const affectedServices = Array.isArray(plan.affectedServices) ? plan.affectedServices : [];
|
||||
process.exit(buildServices.length === 0 && affectedServices.length === 0 ? 0 : 1);
|
||||
const willRunGitopsPromote = plan.ciCdPlan && plan.ciCdPlan.willRunGitopsPromote === true;
|
||||
process.exit(!willRunGitopsPromote && buildServices.length === 0 && affectedServices.length === 0 ? 0 : 1);
|
||||
NODE
|
||||
then
|
||||
printf 'false' > /tekton/results/runtime-ready-required || true
|
||||
|
||||
@@ -54,6 +54,16 @@ export const DEFAULT_GITOPS_ONLY_PATHS = Object.freeze([
|
||||
"tsconfig.gitops.json"
|
||||
]);
|
||||
|
||||
export const DEFAULT_GITOPS_RENDER_PATHS = Object.freeze([
|
||||
"deploy/deploy.yaml",
|
||||
"deploy/deploy.schema.json",
|
||||
"deploy/gitops/",
|
||||
"deploy/frp/",
|
||||
"scripts/gitops-render.mjs",
|
||||
"scripts/src/runtime-lane.ts",
|
||||
"tsconfig.gitops.json"
|
||||
]);
|
||||
|
||||
export async function createCiPlan(options = {}) {
|
||||
const repoRoot = options.repoRoot ?? process.cwd();
|
||||
const deployConfigPath = options.deployConfigPath ?? "deploy/deploy.yaml";
|
||||
@@ -324,6 +334,7 @@ export async function createCiPlan(options = {}) {
|
||||
const affectedServices = services.filter((service) => service.affected).map((service) => service.serviceId);
|
||||
const buildServices = services.filter((service) => service.buildRequired).map((service) => service.serviceId);
|
||||
const reusedServices = services.filter((service) => !service.buildRequired).map((service) => service.serviceId);
|
||||
const gitopsRenderChanged = hasGitOpsRenderChange(normalizedChangedPaths);
|
||||
return {
|
||||
planVersion: CI_PLAN_VERSION,
|
||||
sourceCommitId,
|
||||
@@ -369,9 +380,9 @@ export async function createCiPlan(options = {}) {
|
||||
willRollout: affectedServices,
|
||||
willReuse: reusedServices,
|
||||
envArtifactGroups: envArtifactGroupPlans,
|
||||
willRunGitopsPromote: globalChange.gitopsOnly || affectedServices.length > 0,
|
||||
willRunGitopsPromote: globalChange.gitopsOnly || affectedServices.length > 0 || gitopsRenderChanged,
|
||||
noImageBuildReason: buildServices.length === 0
|
||||
? (affectedServices.length > 0 ? "env-reuse-code-only-rollout" : globalChange.summary)
|
||||
? (affectedServices.length > 0 ? "env-reuse-code-only-rollout" : gitopsRenderChanged ? "gitops-render-only-change" : globalChange.summary)
|
||||
: null
|
||||
}
|
||||
};
|
||||
@@ -884,6 +895,15 @@ export function isGitOpsOnlyPath(filePath) {
|
||||
return DEFAULT_GITOPS_ONLY_PATHS.some((pattern) => pathMatches(pattern, normalized));
|
||||
}
|
||||
|
||||
export function isGitOpsRenderPath(filePath) {
|
||||
const normalized = normalizeRepoPath(filePath);
|
||||
return DEFAULT_GITOPS_RENDER_PATHS.some((pattern) => pathMatches(pattern, normalized));
|
||||
}
|
||||
|
||||
export function hasGitOpsRenderChange(changedPaths) {
|
||||
return changedPaths.some((item) => isGitOpsRenderPath(item));
|
||||
}
|
||||
|
||||
export async function changedPathsBetween(repoRoot, baseRef, targetRef) {
|
||||
const diff = await gitValue(repoRoot, ["diff", "--name-only", baseRef, targetRef]);
|
||||
return diff.split("\n").map((line) => line.trim()).filter(Boolean);
|
||||
|
||||
Reference in New Issue
Block a user