Skip to content

Commit fc12f4e

Browse files
[LintDiff] Skip readme.md files with no "input-file:" string (#35174)
* LintDiff: Skip readmes that don't have "input-file:" * Add tests * Skip testing on Windows * Update eng/tools/lint-diff/test/fixtures/buildState/specification/no-input-file/readme.md Co-authored-by: Mike Harder <[email protected]> --------- Co-authored-by: Mike Harder <[email protected]>
1 parent fc39e07 commit fc12f4e

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

eng/tools/lint-diff/src/processChanges.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,18 @@ export async function buildState(
135135
// For readme files that have changed but there are no affected swaggers,
136136
// add them to the map with no tags
137137
for (const changedReadme of existingChangedFiles.filter(readme)) {
138+
const readmePath = resolve(rootPath, changedReadme);
139+
140+
// Skip readme.md files that don't have "input-file:" as autorest cannot
141+
// scan them.
142+
const readmeContent = await readFile(readmePath, { encoding: "utf-8" });
143+
if (!readmeContent.includes("input-file:")) {
144+
continue;
145+
}
146+
138147
const service = specModels.get(getService(changedReadme))!;
139148
const readmes = await service.getReadmes();
140-
const readmeObject = readmes.get(resolve(rootPath, changedReadme))!;
149+
const readmeObject = readmes.get(readmePath)!;
141150

142151
if (!changedFileAndTagsMap.has(changedReadme)) {
143152
changedFileAndTagsMap.set(changedReadme, {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Widget
2+
3+
> see https://aka.ms/autorest
4+
> This is the AutoRest configuration file for Widget.
5+
6+
## Configuration
7+
8+
Required if any services under this folder are RPaaS.
9+
10+
```yaml
11+
openapi-type: arm
12+
openapi-subtype: rpaas
13+
```

eng/tools/lint-diff/test/processChanges.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,13 @@ describe("buildState", () => {
249249
),
250250
).not.toThrow();
251251
});
252+
253+
test.skipIf(isWindows())("does not include readme files that has no input-file:", async () => {
254+
const actual = await buildState(
255+
["specification/no-input-file/readme.md"],
256+
"test/fixtures/buildState/",
257+
);
258+
259+
expect(actual).toEqual([new Map<string, ReadmeAffectedTags>(), []]);
260+
});
252261
});

0 commit comments

Comments
 (0)