Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typespec-azure repository - Upload Manifest file to the new storage account #1976

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/azure-http-specs"
---

Added a .gitignore file
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
46 changes: 37 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,30 @@ export function getManifestClient() {
return manifestClient;
}

export function getCoverageForMode(
generatorReports: { [mode: string]: Record<GeneratorNames, ResolvedCoverageReport | undefined> },
key: string,
mode: string,
): CoverageReport {
/*
* The generator reports is an array from of reports from Standard and Azure mode in any order.
* So, if the first report is from Azure mode, the second one is from Standard mode and vice versa.
* When the mode is standard, check if the first report is from Azure mode, if so, return the second one.
* Otherwise, return the first one.
* When the mode is azure, check if the first report is from Azure mode, if so, return the first one.
* Otherwise, return the second one.
*/
const reports = (generatorReports["azure"] as any)[key];
const isFirstReportAzure =
reports[0]["scenariosMetadata"].packageName === "@azure-tools/azure-http-specs";
if (mode === "standard") {
return isFirstReportAzure ? reports[1] : reports[0];
} else {
// mode === "azure"
return isFirstReportAzure ? reports[0] : reports[1];
}
}

export async function getCoverageSummaries(): Promise<CoverageSummary[]> {
const coverageClient = getCoverageClient();
const manifestClient = getManifestClient();
Expand All @@ -69,19 +94,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 +128,6 @@ export async function getCoverageSummaries(): Promise<CoverageSummary[]> {
}

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

Expand Down
Loading