diff --git a/README.md b/README.md index 83c44ce..4a8c926 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ If you have already followed the steps [here](https://github.com/microsoft/bedro tag_name="$(PARTITION_KEY)-$(Build.SourceBranchName)-$(Build.BuildId)" commitId=$(Build.SourceVersion) commitId=$(echo "${commitId:0:7}") - echo "python update_pipeline.py $(ACCOUNT_NAME) $(ACCOUNT_KEY) $(TABLE_NAME) $(PARTITION_KEY) p1 $(Build.BuildId) imageTag $tag_name commitId $commitId" - python update_pipeline.py $(ACCOUNT_NAME) $(ACCOUNT_KEY) $(TABLE_NAME) $(PARTITION_KEY) p1 $(Build.BuildId) imageTag $tag_name commitId $commitId + echo "python update_pipeline.py $(ACCOUNT_NAME) $(ACCOUNT_KEY) $(TABLE_NAME) $(PARTITION_KEY) p1 $(Build.BuildId) imageTag $tag_name commitId $commitId service $(Build.Repository.Name)" + python update_pipeline.py $(ACCOUNT_NAME) $(ACCOUNT_KEY) $(TABLE_NAME) $(PARTITION_KEY) p1 $(Build.BuildId) imageTag $tag_name commitId $commitId service $(Build.Repository.Name) displayName: Update source pipeline details in Spektate db ``` diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bb584fb..69c7924 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,4 +35,4 @@ steps: - script: | npm run test workingDirectory: "./" - displayName: "npm run test" \ No newline at end of file + displayName: "npm run test" diff --git a/src/Dashboard.tsx b/src/Dashboard.tsx index fc444d1..b98e444 100644 --- a/src/Dashboard.tsx +++ b/src/Dashboard.tsx @@ -44,6 +44,7 @@ export interface IDashboardState { } export interface IDeploymentField { deploymentId: string; + service: string; startTime?: Date; imageTag?: string; srcCommitId?: string; @@ -63,8 +64,8 @@ export interface IDeploymentField { hldPipelineResult?: string; duration: string; status: string; - clusterSync?: string; - clusterSyncDate?: string; + clusterSync?: boolean; + clusterSyncDate?: Date; endTime?: Date; authorName?: string; authorURL?: string; @@ -94,8 +95,59 @@ class Dashboard extends React.Component { ); } + private getDeployments = () => { + const srcPipeline = new AzureDevOpsPipeline( + config.AZURE_ORG, + config.AZURE_PROJECT, + config.SRC_PIPELINE_ID, + false, + config.AZURE_PIPELINE_ACCESS_TOKEN + ); + const hldPipeline = new AzureDevOpsPipeline( + config.AZURE_ORG, + config.AZURE_PROJECT, + config.DOCKER_PIPELINE_ID, + true, + config.AZURE_PIPELINE_ACCESS_TOKEN + ); + const clusterPipeline = new AzureDevOpsPipeline( + config.AZURE_ORG, + config.AZURE_PROJECT, + config.HLD_PIPELINE_ID, + false, + config.AZURE_PIPELINE_ACCESS_TOKEN + ); + + const manifestRepo: Repository = new GitHub( + config.GITHUB_MANIFEST_USERNAME, + config.MANIFEST, + config.MANIFEST_ACCESS_TOKEN + ); + // const manifestRepo: Repository = new AzureDevOpsRepo(config.AZURE_ORG, config.AZURE_PROJECT, config.MANIFEST, config.MANIFEST_ACCESS_TOKEN); + manifestRepo.getManifestSyncState(syncCommit => { + this.setState({ manifestSync: syncCommit }); + }); + Deployment.getDeployments( + config.STORAGE_PARTITION_KEY, + srcPipeline, + hldPipeline, + clusterPipeline, + (deployments: Deployment[]) => { + this.setState({ deployments }); + this.getAuthors(); + } + ); + return
; + }; + private renderPrototypeTable = () => { const columns: Array> = [ + { + id: "status", + name: "State", + renderCell: this.renderDeploymentStatus, + width: new ObservableValue(70) + }, { id: "deploymentId", name: "Deployment ID", @@ -103,17 +155,16 @@ class Dashboard extends React.Component { width: new ObservableValue(140) }, { - id: "status", - name: "State", - renderCell: this.renderDeploymentStatus, - width: new ObservableValue(70) + id: "service", + name: "Service", + renderCell: this.renderSimpleText, + width: new ObservableValue(220), }, - // { id: 'imageTag', name: 'Image Tag', width: new ObservableValue(220), renderCell: this.renderSimpleText}, { id: "srcBranchName", name: "Branch", renderCell: this.renderSimpleText, - width: new ObservableValue(180) + width: new ObservableValue(180), }, { id: "environment", @@ -131,7 +182,7 @@ class Dashboard extends React.Component { id: "dockerPipelineId", name: "ACR to HLD", renderCell: this.renderDockerRelease, - width: new ObservableValue(250) + width: new ObservableValue(250), }, { id: "hldPipelineId", @@ -145,12 +196,6 @@ class Dashboard extends React.Component { renderCell: this.renderSimpleBoldText, width: new ObservableValue(200) }, - { - id: "clusterSync", - name: "Cluster-Sync", - renderCell: this.renderClusterSync, - width: new ObservableValue(120) - }, { id: "deployedAt", name: "Deployed at", @@ -164,6 +209,7 @@ class Dashboard extends React.Component { const author = this.getAuthor(deployment); return { deploymentId: deployment.deploymentId, + service: deployment.service, startTime: deployment.srcToDockerBuild ? deployment.srcToDockerBuild.startTime : new Date(), @@ -215,15 +261,13 @@ class Dashboard extends React.Component { clusterSync: this.state.manifestSync && deployment.manifestCommitId === this.state.manifestSync.commit && - this.state.manifestSync.commit !== "" - ? "Synced" - : "", + this.state.manifestSync.commit !== "", clusterSyncDate: this.state.manifestSync && deployment.manifestCommitId === this.state.manifestSync.commit && this.state.manifestSync.commit !== "" - ? this.state.manifestSync.date.toString() - : "", + ? this.state.manifestSync.date + : new Date(), endTime: deployment.hldToManifestBuild ? Number.isNaN(deployment.hldToManifestBuild!.finishTime.valueOf()) ? new Date() @@ -244,79 +288,6 @@ class Dashboard extends React.Component { ); }; - private getDeployments = () => { - const srcPipeline = new AzureDevOpsPipeline( - config.AZURE_ORG, - config.AZURE_PROJECT, - config.SRC_PIPELINE_ID, - false, - config.AZURE_PIPELINE_ACCESS_TOKEN - ); - const hldPipeline = new AzureDevOpsPipeline( - config.AZURE_ORG, - config.AZURE_PROJECT, - config.DOCKER_PIPELINE_ID, - true, - config.AZURE_PIPELINE_ACCESS_TOKEN - ); - const clusterPipeline = new AzureDevOpsPipeline( - config.AZURE_ORG, - config.AZURE_PROJECT, - config.HLD_PIPELINE_ID, - false, - config.AZURE_PIPELINE_ACCESS_TOKEN - ); - - const manifestRepo: Repository = new GitHub( - config.GITHUB_MANIFEST_USERNAME, - config.MANIFEST, - config.MANIFEST_ACCESS_TOKEN - ); - // const manifestRepo: Repository = new AzureDevOpsRepo(config.AZURE_ORG, config.AZURE_PROJECT, config.MANIFEST, config.MANIFEST_ACCESS_TOKEN); - manifestRepo.getManifestSyncState(syncCommit => { - this.setState({ manifestSync: syncCommit }); - }); - Deployment.getDeployments( - config.STORAGE_PARTITION_KEY, - srcPipeline, - hldPipeline, - clusterPipeline, - (deployments: Deployment[]) => { - this.setState({ deployments }); - this.getAuthors(); - } - ); - return
; - }; - - private renderClusterSync = ( - rowIndex: number, - columnIndex: number, - tableColumn: ITableColumn, - tableItem: IDeploymentField - ): JSX.Element => { - if (tableItem.clusterSyncDate !== "") { - return ( - , - className: "fontSize font-size", - iconProps: { iconName: "Calendar" } - })} - /> - ); - } - return ; - }; - private renderSimpleText = ( rowIndex: number, columnIndex: number, @@ -555,7 +526,6 @@ class Dashboard extends React.Component { tableColumn: ITableColumn, tableItem: IDeploymentField ): JSX.Element => { - console.log(tableItem.status); if (!tableItem.status) { return ; } @@ -567,10 +537,24 @@ class Dashboard extends React.Component { contentClassName="fontWeightSemiBold font-weight-semibold fontSizeM font-size-m scroll-hidden" > + {tableItem.clusterSync && ( + + {this.WithIcon({ + className: "fontSizeM font-size-m", + iconProps: { iconName: "CloudUpload" } + })} + + )} ); }; @@ -588,10 +572,12 @@ class Dashboard extends React.Component { ); }; - private getStatusIndicatorData = (status: string): IStatusIndicatorData => { + private getStatusIndicatorData = ( + status: string, + clusterSync?: boolean + ): IStatusIndicatorData => { status = status || ""; status = status.toLowerCase(); - console.log(status); const indicatorData: IStatusIndicatorData = { label: "Success", statusProps: { ...Statuses.Success, ariaLabel: "Success" } diff --git a/src/models/Deployment.ts b/src/models/Deployment.ts index 5286bf0..5592eee 100644 --- a/src/models/Deployment.ts +++ b/src/models/Deployment.ts @@ -76,6 +76,7 @@ class Deployment { if (!error) { const srcBuildIds: Set = new Set(); const manifestBuildIds: Set = new Set(); + const releaseIds: Set = new Set(); for (const entry of result.entries) { if (entry.p1) { srcBuildIds.add(entry.p1._); @@ -83,11 +84,14 @@ class Deployment { if (entry.p3) { manifestBuildIds.add(entry.p3._); } + if (entry.p2) { + releaseIds.add(entry.p2._); + } } const p1 = srcPipeline.getListOfBuilds(undefined, srcBuildIds); // TODO: send releaseIds to below after bug in release API is fixed - const p2 = hldPipeline.getListOfReleases(); + const p2 = hldPipeline.getListOfReleases(undefined, releaseIds); const p3 = manifestPipeline.getListOfBuilds( undefined, manifestBuildIds @@ -176,6 +180,7 @@ class Deployment { let hldCommitId = ""; let manifestCommitId = ""; let env = ""; + let service = ""; if (entry.p2 != null) { p2 = hldPipeline.releases[entry.p2._]; } @@ -193,6 +198,9 @@ class Deployment { if (entry.env != null) { env = entry.env._; } + if (entry.service != null) { + service = entry.service._; + } const deployment = new Deployment( entry.RowKey._, @@ -201,6 +209,7 @@ class Deployment { imageTag, entry.Timestamp._, env, + service, manifestCommitId, p1, p2, @@ -220,6 +229,7 @@ class Deployment { public manifestCommitId?: string; public author?: Author; public environment: string; + public service: string; constructor( deploymentId: string, @@ -228,6 +238,7 @@ class Deployment { imageTag: string, timeStamp: string, environment: string, + service: string, manifestCommitId?: string, srcToDockerBuild?: Build, dockerToHldRelease?: Release, @@ -243,6 +254,7 @@ class Deployment { this.timeStamp = timeStamp; this.manifestCommitId = manifestCommitId; this.environment = environment; + this.service = service; } public duration(): string { diff --git a/src/models/pipeline/AzureDevOpsPipeline.ts b/src/models/pipeline/AzureDevOpsPipeline.ts index 2831547..21dbdb9 100644 --- a/src/models/pipeline/AzureDevOpsPipeline.ts +++ b/src/models/pipeline/AzureDevOpsPipeline.ts @@ -12,6 +12,8 @@ const baseBuildUrl = "https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitionId}&api-version=5.0&queryOrder=startTimeDescending"; const baseReleaseUrl = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/deployments?api-version=5.0&definitionId={definitionId}&queryOrder=startTimeDescending"; +const releaseFilterUrl = + "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/deployments?api-version=5.0&releaseIdFilter={releaseIds}&queryOrder=startTimeDescending"; class AzureDevOpsPipeline extends Pipeline { // User defined fields @@ -96,7 +98,7 @@ class AzureDevOpsPipeline extends Pipeline { ): Promise { return new Promise((resolve, reject) => { HttpHelper.httpGet( - this.getReleaseUrl(), + this.getReleaseUrl(releaseIds), json => { const releases: Release[] = []; for (const row of json.data.value) { @@ -119,7 +121,6 @@ class AzureDevOpsPipeline extends Pipeline { releases.push(release); this.releases[release.id] = release; } - resolve(); if (callback) { callback(this.releases); @@ -153,8 +154,8 @@ class AzureDevOpsPipeline extends Pipeline { releaseIds.forEach(releaseId => { strBuildIds += releaseId + ","; }); - return buildFilterUrl - .replace("{buildIds}", strBuildIds) + return releaseFilterUrl + .replace("{releaseIds}", strBuildIds) .replace("{organization}", this.org) .replace("{project}", this.project) .replace("{definitionId}", this.definitionId + "");