diff --git a/eng/pipelines/publish.yml b/eng/pipelines/publish.yml index 4c3df6384a..505b8fdac0 100644 --- a/eng/pipelines/publish.yml +++ b/eng/pipelines/publish.yml @@ -89,6 +89,20 @@ extends: --source "./packages/typespec-azure-playground-website/dist/" ^ --overwrite + - script: pnpm run validate-scenarios --debug + displayName: Validate Scenarios + + - script: pnpm run validate-mock-apis --debug + displayName: Validate mock apis + + - task: AzureCLI@2 + displayName: Upload scenario manifest + inputs: + azureSubscription: "TypeSpec Storage" + scriptType: "bash" + scriptLocation: "inlineScript" + inlineScript: "pnpm upload-manifest" + - job: npm_preview timeoutInMinutes: 90 dependsOn: npm_stable diff --git a/packages/azure-http-specs/.gitignore b/packages/azure-http-specs/.gitignore index ceecc046a0..6093ba4508 100644 --- a/packages/azure-http-specs/.gitignore +++ b/packages/azure-http-specs/.gitignore @@ -1 +1,2 @@ spec-coverage.json +manifest.json diff --git a/packages/azure-spec-dashboard/src/apis.ts b/packages/azure-spec-dashboard/src/apis.ts index de6b348113..d9f3665c27 100644 --- a/packages/azure-spec-dashboard/src/apis.ts +++ b/packages/azure-spec-dashboard/src/apis.ts @@ -1,4 +1,5 @@ import { + CoverageReport, ResolvedCoverageReport, ScenarioManifest, SpecCoverageClient, @@ -58,6 +59,32 @@ export function getManifestClient() { return manifestClient; } +export function getCoverageForMode( + generatorReports: { [mode: string]: Record }, + key: string, + mode: string, +): CoverageReport { + if (mode === "standard") { + if ( + (generatorReports["azure"] as any)[key][0]["scenariosMetadata"].packageName === + "@azure-tools/azure-http-specs" + ) { + return (generatorReports["azure"] as any)[key][1]; + } else { + return (generatorReports["azure"] as any)[key][0]; + } + } else { + if ( + (generatorReports["azure"] as any)[key][0]["scenariosMetadata"].packageName === + "@azure-tools/azure-http-specs" + ) { + return (generatorReports["azure"] as any)[key][0]; + } else { + return (generatorReports["azure"] as any)[key][1]; + } + } +} + export async function getCoverageSummaries(): Promise { const coverageClient = getCoverageClient(); const manifestClient = getManifestClient(); @@ -69,19 +96,23 @@ export async function getCoverageSummaries(): Promise { const manifestStandard = manifests.filter( (manifest: ScenarioManifest) => manifest.setName !== "@azure-tools/azure-http-specs", )[0]; - for (const key in generatorReports["standard"]) { - (generatorReports["standard"] as any)[key] = { - ...(generatorReports["standard"] as any)[key][0], - generatorMetadata: (generatorReports["standard"] as any)[key]["generatorMetadata"], - }; - } - const manifestAzure = manifests.filter( (manifest: ScenarioManifest) => manifest.setName === "@azure-tools/azure-http-specs", )[0]; + + (generatorReports["standard"] as any) = {}; + for (const key in generatorReports["azure"]) { + if (!(generatorReports["azure"] as any)[key]) { + (generatorReports["standard"] as any)[key] = undefined; + continue; + } + (generatorReports["standard"] as any)[key] = { + ...getCoverageForMode(generatorReports, key, "standard"), + generatorMetadata: (generatorReports["azure"] as any)[key]["generatorMetadata"], + }; (generatorReports["azure"] as any)[key] = { - ...(generatorReports["azure"] as any)[key][0], + ...getCoverageForMode(generatorReports, key, "azure"), generatorMetadata: (generatorReports["azure"] as any)[key]["generatorMetadata"], }; } @@ -99,7 +130,6 @@ export async function getCoverageSummaries(): Promise { } enum GeneratorMode { - standard = "standard", azure = "azure", }