feat(pipelines): add pipelines view modes, time-range filtering, group aggregation, sorting, and job log polling

This commit is contained in:
2026-03-02 12:12:41 +00:00
parent 423860c21c
commit c3d50736cd
12 changed files with 659 additions and 54 deletions

View File

@@ -11,6 +11,12 @@ export interface IListOptions {
perPage?: number;
}
export interface IPipelineListOptions extends IListOptions {
status?: string;
ref?: string;
source?: string;
}
/**
* Abstract base class for Git provider implementations.
* Subclasses implement Gitea API v1 or GitLab API v4.
@@ -36,6 +42,9 @@ export abstract class BaseProvider {
// Groups / Orgs
abstract getGroups(opts?: IListOptions): Promise<interfaces.data.IGroup[]>;
// Group Projects
abstract getGroupProjects(groupId: string, opts?: IListOptions): Promise<interfaces.data.IProject[]>;
// Secrets — project scope
abstract getProjectSecrets(projectId: string): Promise<interfaces.data.ISecret[]>;
abstract createProjectSecret(
@@ -71,7 +80,7 @@ export abstract class BaseProvider {
// Pipelines / CI
abstract getPipelines(
projectId: string,
opts?: IListOptions,
opts?: IPipelineListOptions,
): Promise<interfaces.data.IPipeline[]>;
abstract getPipelineJobs(
projectId: string,

View File

@@ -1,6 +1,6 @@
import * as plugins from '../plugins.ts';
import type * as interfaces from '../../ts_interfaces/index.ts';
import { BaseProvider, type ITestConnectionResult, type IListOptions } from './classes.baseprovider.ts';
import { BaseProvider, type ITestConnectionResult, type IListOptions, type IPipelineListOptions } from './classes.baseprovider.ts';
/**
* Gitea API v1 provider implementation
@@ -70,6 +70,23 @@ export class GiteaProvider extends BaseProvider {
return allOrgs.map((o) => this.mapGroup(o));
}
async getGroupProjects(groupId: string, opts?: IListOptions): Promise<interfaces.data.IProject[]> {
if (opts?.page) {
const repos = await this.client.getOrgRepos(groupId, opts);
return repos.map((r) => this.mapProject(r));
}
const allRepos: plugins.giteaClient.IGiteaRepository[] = [];
const perPage = opts?.perPage || 50;
let page = 1;
while (true) {
const repos = await this.client.getOrgRepos(groupId, { ...opts, page, perPage });
allRepos.push(...repos);
if (repos.length < perPage) break;
page++;
}
return allRepos.map((r) => this.mapProject(r));
}
// --- Branches / Tags ---
async getBranches(projectFullPath: string, opts?: IListOptions): Promise<interfaces.data.IBranch[]> {
@@ -166,9 +183,15 @@ export class GiteaProvider extends BaseProvider {
async getPipelines(
projectId: string,
opts?: IListOptions,
opts?: IPipelineListOptions,
): Promise<interfaces.data.IPipeline[]> {
const runs = await this.client.getActionRuns(projectId, opts);
const runs = await this.client.getActionRuns(projectId, {
page: opts?.page,
perPage: opts?.perPage,
status: opts?.status,
branch: opts?.ref,
event: opts?.source,
});
return runs.map((r) => this.mapPipeline(r, projectId));
}
@@ -236,11 +259,11 @@ export class GiteaProvider extends BaseProvider {
};
}
private mapPipeline(r: plugins.giteaClient.IGiteaActionRun, projectId: string): interfaces.data.IPipeline {
private mapPipeline(r: plugins.giteaClient.IGiteaActionRun, projectId: string, projectName?: string): interfaces.data.IPipeline {
return {
id: String(r.id),
projectId,
projectName: projectId,
projectName: projectName || projectId,
connectionId: this.connectionId,
status: this.mapStatus(r.status || r.conclusion),
ref: r.head_branch || '',

View File

@@ -1,6 +1,6 @@
import * as plugins from '../plugins.ts';
import type * as interfaces from '../../ts_interfaces/index.ts';
import { BaseProvider, type ITestConnectionResult, type IListOptions } from './classes.baseprovider.ts';
import { BaseProvider, type ITestConnectionResult, type IListOptions, type IPipelineListOptions } from './classes.baseprovider.ts';
/**
* GitLab API v4 provider implementation
@@ -85,6 +85,23 @@ export class GitLabProvider extends BaseProvider {
return allGroups.map((g) => this.mapGroup(g));
}
async getGroupProjects(groupId: string, opts?: IListOptions): Promise<interfaces.data.IProject[]> {
if (opts?.page) {
const projects = await this.client.getGroupProjects(groupId, opts);
return projects.map((p) => this.mapProject(p));
}
const allProjects: plugins.gitlabClient.IGitLabProject[] = [];
const perPage = opts?.perPage || 50;
let page = 1;
while (true) {
const projects = await this.client.getGroupProjects(groupId, { ...opts, page, perPage });
allProjects.push(...projects);
if (projects.length < perPage) break;
page++;
}
return allProjects.map((p) => this.mapProject(p));
}
// --- Branches / Tags ---
async getBranches(projectFullPath: string, opts?: IListOptions): Promise<interfaces.data.IBranch[]> {
@@ -183,9 +200,15 @@ export class GitLabProvider extends BaseProvider {
async getPipelines(
projectId: string,
opts?: IListOptions,
opts?: IPipelineListOptions,
): Promise<interfaces.data.IPipeline[]> {
const pipelines = await this.client.getPipelines(projectId, opts);
const pipelines = await this.client.getPipelines(projectId, {
page: opts?.page,
perPage: opts?.perPage,
status: opts?.status,
ref: opts?.ref,
source: opts?.source,
});
return pipelines.map((p) => this.mapPipeline(p, projectId));
}
@@ -258,11 +281,11 @@ export class GitLabProvider extends BaseProvider {
};
}
private mapPipeline(p: plugins.gitlabClient.IGitLabPipeline, projectId: string): interfaces.data.IPipeline {
private mapPipeline(p: plugins.gitlabClient.IGitLabPipeline, projectId: string, projectName?: string): interfaces.data.IPipeline {
return {
id: String(p.id),
projectId,
projectName: projectId,
projectName: projectName || projectId,
connectionId: this.connectionId,
status: (p.status || 'pending') as interfaces.data.TPipelineStatus,
ref: p.ref || '',