Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sarangan12 committed Dec 11, 2024
1 parent 2b3cfb5 commit 703b6c1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
14 changes: 14 additions & 0 deletions eng/pipelines/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/azure-http-specs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
spec-coverage.json
manifest.json
48 changes: 39 additions & 9 deletions packages/azure-spec-dashboard/src/apis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CoverageReport,
ResolvedCoverageReport,
ScenarioManifest,
SpecCoverageClient,
Expand Down Expand Up @@ -58,6 +59,32 @@ export function getManifestClient() {
return manifestClient;
}

export function getCoverageForMode(
generatorReports: { [mode: string]: Record<GeneratorNames, ResolvedCoverageReport | undefined> },
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<CoverageSummary[]> {
const coverageClient = getCoverageClient();
const manifestClient = getManifestClient();
Expand All @@ -69,19 +96,23 @@ export async function getCoverageSummaries(): Promise<CoverageSummary[]> {
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"],
};
}
Expand All @@ -99,7 +130,6 @@ export async function getCoverageSummaries(): Promise<CoverageSummary[]> {
}

enum GeneratorMode {
standard = "standard",
azure = "azure",
}

Expand Down

0 comments on commit 703b6c1

Please sign in to comment.