Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5458d85
[TSV] Skip FolderStructureRule
mikeharder May 22, 2025
9cea263
Merge branch 'main' into folder-structure-v2
mikeharder May 22, 2025
b6d7d5e
[avocado] Exclude TSP examples
mikeharder May 22, 2025
1536857
Exclude paths containing "/examples/" but not "/stable/" or "/preview/"
mikeharder May 23, 2025
b5b85aa
simplify regex
mikeharder May 23, 2025
2a579fc
fix quoting
mikeharder May 23, 2025
d4e010d
Merge branch 'main' into folder-structure-v2
mikeharder May 23, 2025
177e9e2
Merge branch 'main' into folder-structure-v2
mikeharder May 23, 2025
bfd50e9
Merge branch 'main' into folder-structure-v2
mikeharder May 27, 2025
a5bd917
[TypeSpecValidation] Allow folder structure v2
mikeharder May 27, 2025
a4371ef
revert formatting
mikeharder May 27, 2025
f06ccb8
set success=false after reporting error
mikeharder May 27, 2025
1577743
Add unit tests for v2
mikeharder May 27, 2025
930181a
Merge branch 'main' into folder-structure-v2
mikeharder May 27, 2025
6fd752d
Merge branch 'main' into folder-structure-v2
mikeharder May 28, 2025
829c714
Add TODO comment
mikeharder May 28, 2025
e761239
consider typespec under resource-manager as mgmt typespec
raych1 May 29, 2025
99ecbd5
Merge branch 'main' into folder-structure-v2
mikeharder May 30, 2025
9627a5a
Merge branch 'main' into folder-structure-v2
mikeharder Jun 5, 2025
757907a
Merge branch 'main' into folder-structure-v2
mikeharder Jun 6, 2025
e140b82
Update eng/tools/typespec-validation/src/rules/folder-structure.ts
mikeharder Jun 6, 2025
3224d25
Update eng/tools/typespec-validation/src/rules/folder-structure.ts
mikeharder Jun 6, 2025
6162802
update rpnamespace and service regexes
mikeharder Jun 6, 2025
486e170
Merge branch 'main' into folder-structure-v2
mikeharder Jun 6, 2025
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
Prev Previous commit
Next Next commit
update rpnamespace and service regexes
  • Loading branch information
mikeharder committed Jun 6, 2025
commit 61628023c640bbec9dd99fc6599b53d65df524cc
15 changes: 6 additions & 9 deletions eng/tools/typespec-validation/src/rules/folder-structure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debug from "debug";

Check failure on line 1 in eng/tools/typespec-validation/src/rules/folder-structure.ts

View workflow job for this annotation

GitHub Actions / Protected Files

File 'eng/tools/typespec-validation/src/rules/folder-structure.ts' should only be updated by the Azure SDK team. If intentional, the PR may be merged by the Azure SDK team via bypassing the branch protections.
import { readFile } from "fs/promises";
import { globby } from "globby";
import path from "path";
Expand Down Expand Up @@ -122,9 +122,6 @@
success = false;
}

// TODO: Decide if v2 should validate folder names and structure to ensure specs align, or allow a more loose structure to ease
// migration from v1 to v2.

const specType = folder.includes("data-plane") ? "data-plane" : "resource-manager";
if (specType === "data-plane") {
if (folderStruct.length !== 4) {
Expand All @@ -139,21 +136,21 @@
success = false;
}

const rpNamespaceRegex = /^[A-Za-z0-9\.]+$/;
const rpNamespaceFolder = folderStruct[folderStruct.length - 2];

// Verify service folder is capitalized after each '.'
if (/(^|\. *)([a-z])/g.test(rpNamespaceFolder)) {
if (!rpNamespaceRegex.test(rpNamespaceFolder)) {
success = false;
errorOutput += `Invalid RP namespace folder '${rpNamespaceFolder}'. RP namespace folders must be capitalized after each '.'`;
errorOutput += `RPNamespace folder '${rpNamespaceFolder}' does not match regex ${rpNamespaceRegex}`;
}
}

const serviceRegex = /^[A-Za-z0-9]+$/;
const serviceFolder = folderStruct[folderStruct.length - 1];

// Verify service folder is capitalized after each '.'
if (/(^|\. *)([a-z])/g.test(serviceFolder)) {
if (!serviceRegex.test(serviceFolder)) {
success = false;
errorOutput += `Invalid service folder '${serviceFolder}'. Service folders must be capitalized after each '.'`;
errorOutput += `Service folder '${serviceFolder}' does not match regex ${serviceRegex}`;
}
}

Expand Down
4 changes: 2 additions & 2 deletions eng/tools/typespec-validation/test/folder-structure.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mockAll, mockFolder } from "./mocks.js";

Check failure on line 1 in eng/tools/typespec-validation/test/folder-structure.test.ts

View workflow job for this annotation

GitHub Actions / Protected Files

File 'eng/tools/typespec-validation/test/folder-structure.test.ts' should only be updated by the Azure SDK team. If intentional, the PR may be merged by the Azure SDK team via bypassing the branch protections.
mockAll();

import { contosoTspConfig } from "@azure-tools/specs-shared/test/examples";
Expand Down Expand Up @@ -95,7 +95,7 @@

const result = await new FolderStructureRule().execute("/gitroot/specification/foo/data-plane");
assert(result.errorOutput);
assert(result.errorOutput.includes("must be capitalized"));
assert(result.errorOutput.includes("does not match regex"));
});

it("should fail if second level folder is resource-manager", async function () {
Expand All @@ -108,7 +108,7 @@
"/gitroot/specification/foo/resource-manager",
);
assert(result.errorOutput);
assert(result.errorOutput.includes("must be capitalized"));
assert(result.errorOutput.includes("does not match regex"));
});

it("should fail if Shared does not follow Management ", async function () {
Expand Down
Loading