Merge pull request #2226 from pikasTech/fix/agentrun-multibranch-repository
支持 AgentRun 共享 PaC Repository 的多分支 consumer
This commit is contained in:
@@ -149,10 +149,6 @@ repositories:
|
||||
variables:
|
||||
NODE: NC01
|
||||
LANE: v02
|
||||
- extends: templates.repositories.agentrunRelease
|
||||
variables:
|
||||
NODE: NC01
|
||||
LANE: release
|
||||
- extends: templates.repositories.sentinelV03
|
||||
variables:
|
||||
NODE: JD01
|
||||
@@ -320,6 +316,7 @@ consumers:
|
||||
variables:
|
||||
NODE: NC01
|
||||
LANE: release
|
||||
repositoryRef: agentrun-nc01-v02
|
||||
deliveryProvenance:
|
||||
required: true
|
||||
markerValue: admission-pac-v2:agentrun-nc01-release
|
||||
@@ -677,30 +674,6 @@ templates:
|
||||
pipeline_run_prefix: "agentrun-${nodeLower}-v02-ci"
|
||||
service_account: "agentrun-${nodeLower}-v02-tekton-runner"
|
||||
workspace_pvc_size: 2Gi
|
||||
agentrunRelease:
|
||||
id: "agentrun-${nodeLower}-release"
|
||||
name: "agentrun-${nodeLower}-release"
|
||||
namespace: agentrun-ci
|
||||
providerType: gitea
|
||||
url: https://gitea.pikapython.com/mirrors/pikasTech-agentrun
|
||||
cloneUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikasTech-agentrun.git
|
||||
owner: mirrors
|
||||
repo: pikasTech-agentrun
|
||||
secretName: "pac-gitea-agentrun-${nodeLower}-release"
|
||||
tokenKey: token
|
||||
webhookSecretKey: webhook.secret
|
||||
concurrencyLimit: 1
|
||||
params:
|
||||
git_read_url: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikasTech-agentrun.git
|
||||
git_write_url: http://git-mirror-write.devops-infra.svc.cluster.local:8080/pikasTech/agentrun.git
|
||||
source_branch: release
|
||||
node: "${NODE}"
|
||||
gitops_branch: "${nodeLower}-release-gitops"
|
||||
source_snapshot_prefix: refs/unidesk/snapshots/gitea-actions/agentrun-release
|
||||
pipeline_name: "agentrun-${nodeLower}-release-ci-image-publish"
|
||||
pipeline_run_prefix: "agentrun-${nodeLower}-release-ci"
|
||||
service_account: "agentrun-${nodeLower}-release-tekton-runner"
|
||||
workspace_pvc_size: 2Gi
|
||||
sentinelV03:
|
||||
id: "sentinel-${nodeLower}-v03"
|
||||
name: "sentinel-${nodeLower}-v03"
|
||||
@@ -783,6 +756,17 @@ templates:
|
||||
argoNamespace: argocd
|
||||
argoApplication: "agentrun-${nodeLower}-release"
|
||||
closeoutGitOpsMirrorFlush: true
|
||||
params:
|
||||
git_read_url: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikasTech-agentrun.git
|
||||
git_write_url: http://git-mirror-write.devops-infra.svc.cluster.local:8080/pikasTech/agentrun.git
|
||||
source_branch: release
|
||||
node: "${NODE}"
|
||||
gitops_branch: "${nodeLower}-release-gitops"
|
||||
source_snapshot_prefix: refs/unidesk/snapshots/gitea-actions/agentrun-release
|
||||
pipeline_name: "agentrun-${nodeLower}-release-ci-image-publish"
|
||||
pipeline_run_prefix: "agentrun-${nodeLower}-release-ci"
|
||||
service_account: "agentrun-${nodeLower}-release-tekton-runner"
|
||||
workspace_pvc_size: 2Gi
|
||||
sentinelV03:
|
||||
id: "sentinel-${nodeLower}-v03"
|
||||
repositoryRef: "sentinel-${nodeLower}-v03"
|
||||
|
||||
@@ -51,13 +51,27 @@ const pacEvaluator = createRequire(import.meta.url)("../native/cicd/pac-status-e
|
||||
describe("YAML 组合的 CI/CD delivery authority", () => {
|
||||
test("组合 PaC 与 Gitea YAML,覆盖所有实际 consumer 且 id 唯一", () => {
|
||||
const catalog = readCicdDeliveryAuthorityCatalog();
|
||||
expect(catalog.consumers).toHaveLength(10);
|
||||
expect(new Set(catalog.consumers.map((item) => item.consumerId)).size).toBe(10);
|
||||
expect(catalog.consumers).toHaveLength(15);
|
||||
expect(new Set(catalog.consumers.map((item) => item.consumerId)).size).toBe(15);
|
||||
for (const consumerId of ["agentrun-nc01-v02", "hwlab-nc01-v03", "sentinel-nc01-v03", "unidesk-host", "platform-infra-gitea-nc01", "platform-infra-sub2rank-nc01", "selfmedia-nc01"]) {
|
||||
const authority = resolveCicdDeliveryAuthority({ consumerId });
|
||||
expect(authority.kind).toBe("pac-pr-merge");
|
||||
expect(authority.mutationHintsAllowed).toBe(false);
|
||||
}
|
||||
expect(resolveCicdDeliveryAuthority({
|
||||
node: "NC01",
|
||||
lane: "nc01-release",
|
||||
sourceRepository: "pikasTech/agentrun",
|
||||
sourceBranch: "release",
|
||||
})).toMatchObject({
|
||||
kind: "pac-pr-merge",
|
||||
consumer: {
|
||||
consumerId: "agentrun-nc01-release",
|
||||
repositoryRef: "agentrun-nc01-v02",
|
||||
sourceBranch: "release",
|
||||
sourceSnapshotPrefix: "refs/unidesk/snapshots/gitea-actions/agentrun-release",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("repository identity 从通用 Git remote 解析,不依赖仓库特例", () => {
|
||||
|
||||
@@ -145,16 +145,25 @@ export function readCicdDeliveryAuthorityCatalog(): CicdDeliveryAuthorityCatalog
|
||||
const namespace = requiredString(item.namespace, `${path}.namespace`);
|
||||
const pipelineRunPrefix = requiredString(item.pipelineRunPrefix, `${path}.pipelineRunPrefix`);
|
||||
const repositoryRef = requiredString(item.repositoryRef, `${path}.repositoryRef`);
|
||||
const consumerParams = item.params === undefined ? {} : record(item.params, `${path}.params`);
|
||||
const pacRepository = exactlyOne(
|
||||
pacRepositories.filter((candidate) => same(candidate.id, repositoryRef)),
|
||||
`${path}.repositoryRef=${repositoryRef}`,
|
||||
);
|
||||
const sourceBranch = requiredString(
|
||||
consumerParams.source_branch ?? pacRepository.sourceBranch,
|
||||
`${path}.params.source_branch`,
|
||||
);
|
||||
const sourceSnapshotPrefix = requiredString(
|
||||
consumerParams.source_snapshot_prefix ?? pacRepository.sourceSnapshotPrefix,
|
||||
`${path}.params.source_snapshot_prefix`,
|
||||
);
|
||||
const authorityRepository = exactlyOne(
|
||||
giteaRepositories.filter((candidate) => same(candidate.targetId, node)
|
||||
&& same(candidate.owner, pacRepository.owner)
|
||||
&& same(candidate.repo, pacRepository.repo)
|
||||
&& same(candidate.sourceBranch, pacRepository.sourceBranch)),
|
||||
`${path} source authority ${node}/${pacRepository.owner}/${pacRepository.repo}@${pacRepository.sourceBranch}`,
|
||||
&& same(candidate.sourceBranch, sourceBranch)),
|
||||
`${path} source authority ${node}/${pacRepository.owner}/${pacRepository.repo}@${sourceBranch}`,
|
||||
);
|
||||
return {
|
||||
consumerId,
|
||||
@@ -164,8 +173,8 @@ export function readCicdDeliveryAuthorityCatalog(): CicdDeliveryAuthorityCatalog
|
||||
pipelineRunPrefix,
|
||||
repositoryRef,
|
||||
sourceRepository: authorityRepository.sourceRepository,
|
||||
sourceBranch: authorityRepository.sourceBranch,
|
||||
sourceSnapshotPrefix: pacRepository.sourceSnapshotPrefix,
|
||||
sourceBranch,
|
||||
sourceSnapshotPrefix,
|
||||
giteaOwner: pacRepository.owner,
|
||||
giteaRepository: pacRepository.repo,
|
||||
giteaRepositoryUrl: pacRepository.url,
|
||||
|
||||
Reference in New Issue
Block a user