Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
88d53d5
working through initial setup of actions and package installation. ju…
scbedd May 15, 2025
99b550c
Add oav-runner to eng/tools/package.json
mikeharder May 15, 2025
c1230fb
[eng/tools/tsconfig.json] Add oav-runner, formatting
mikeharder May 15, 2025
dd67632
much further along in the journey. have it factored closer to what i …
scbedd May 20, 2025
74d2d13
tests properly running
scbedd May 20, 2025
5e4ce29
further updates around calling properly. I really need to clean up th…
scbedd May 23, 2025
1e819ae
adding nice error reporting. working on summary files
scbedd May 23, 2025
c81d71c
make necessary changes to package-lock and other files
scbedd May 23, 2025
5e26c3e
more updates + updating workflow invocation
scbedd May 23, 2025
ce6255b
strictly miming lint-diff to try to figure out why my bin isn't build…
scbedd May 23, 2025
247d942
update specs to call properly
scbedd May 23, 2025
5fa8eaf
update to package-lock.json
scbedd May 23, 2025
0a811b5
fix error-reporting
scbedd May 23, 2025
895ca4b
further refinements
scbedd May 23, 2025
1f92197
fix npm build error
scbedd May 23, 2025
aff13eb
properly setting the exit code when there are actually errors
scbedd May 23, 2025
493f335
update the success summary!
scbedd May 23, 2025
c56eeb9
should be able to run either specs or examples properly now
scbedd May 24, 2025
3609afa
cleanup commit
scbedd May 24, 2025
52bed60
formatting the project properly now
scbedd May 24, 2025
d471af6
rename our specs etc
scbedd May 27, 2025
6b55122
add a test case for an example scenario that absolutely exists
scbedd May 27, 2025
ff4acba
populate more tests
scbedd May 27, 2025
1196a2d
pretty
scbedd May 27, 2025
a4bf7bb
skin out the associatedswaggers and find related to example changes
scbedd May 28, 2025
e840c18
going to need to get rid of all the .filter() or .foreach() as they d…
scbedd May 28, 2025
2029387
cleanup and finishing up the tests. update the summary to output the …
scbedd May 29, 2025
0c5a642
Apply suggestions from code review
scbedd May 29, 2025
31de60f
PR feedback. removing prettierrc. renaming test job. renaming checks
scbedd May 29, 2025
9314de6
refactor the refs usage
scbedd May 29, 2025
912d5bf
Apply suggestions from code review
scbedd May 30, 2025
f37ba49
update getRefs and getExamples to use a common property function
scbedd May 30, 2025
7ce114a
finish rename standardization of the PR. update cli to allow optional…
scbedd May 30, 2025
519423f
honor the new os.cwd usage
scbedd May 30, 2025
92a59db
Apply suggestions from code review
scbedd May 30, 2025
55f9283
commit my package lock. need to do a merge from main now
scbedd May 30, 2025
0ce1c41
git merge main. now need to fix swagger.js
scbedd May 30, 2025
d59f135
merge main
scbedd May 30, 2025
8d08617
remove usage of consolelogger. update from main. update package lock.…
scbedd May 30, 2025
3239dd1
remove the vitest fie
scbedd May 30, 2025
bc8ec0a
Merge branch 'main' into add-model/semantic-gitvalidation
mikeharder May 30, 2025
3422037
switch to local files instead of forcing a huge copy
scbedd Jun 2, 2025
48ec587
remove debug output
scbedd Jun 2, 2025
c33a994
Merge branch 'main' into add-model/semantic-gitvalidation
mikeharder Jun 2, 2025
0fbb537
remove unused var
mikeharder Jun 2, 2025
637ba58
prettier
mikeharder Jun 2, 2025
431c768
Add helper path.includesFolder()
mikeharder Jun 2, 2025
52cacc3
this should be it for crossplat I hope
scbedd Jun 3, 2025
e222d8e
add error reporting tests
scbedd Jun 3, 2025
45ff0b7
remove debug log lines
scbedd Jun 3, 2025
c781fe3
[error-reporting.test] Convert to async, remove empty catch
mikeharder Jun 3, 2025
ee14479
prettier
mikeharder Jun 3, 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
adding nice error reporting. working on summary files
  • Loading branch information
scbedd committed May 23, 2025
commit 1e819aea6b87174efea3a99cfe622b3e37da4802
34 changes: 34 additions & 0 deletions .github/shared/src/error-reporting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check
import * as fs from "fs";
import { consoleLogger } from "./logger.js";

/**
* Set the summary of the github step summary for a job. This feature is intended for formatted markdown,
* which can be used to display the results of a job in a more readable format.
*
* Format your results as a markdown table and go to town!
* @param {string} content
* @returns {void}
*/
export function setSummary(content) {
if (!process.env.GITHUB_STEP_SUMMARY) {
consoleLogger.info("GITHUB_STEP_SUMMARY is not set. Skipping summary update.");
return;
}
const summaryFile = process.env.GITHUB_STEP_SUMMARY;

fs.writeFileSync(summaryFile, content);
}

/**
* This function is used to ask the github agent to annotate a file in a github PR with an error message.
* @param {string} repoPath
* @param {string} line
* @param {string} col
* @param {string} message
* @returns {void}
*/
export function annotateFileError(repoPath, line, col, message) {
const errorLine = `::error file=${repoPath},line=${line},col=${col}::${message}`;
consoleLogger.info(errorLine);
}
12 changes: 11 additions & 1 deletion eng/tools/oav-runner/src/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@

export interface ReportableOavError {
message: string;
file: string;
line?: number; // we don't always have a line or column if the spec is invalid
column?: number;
}


// todo: come up with a better type for this
export function outputAnnotatedErrors(errors: Array<object>){
// echo "::error file=src/app.js,line=42,col=13::Something went wrong here"
Expand All @@ -13,4 +22,5 @@ export function outputSummaryReport(targetDirectory: string, errors: Array<objec
>> $GITHUB_STEP_SUMMARY
*/
console.log(`outputting ${errors} to summary report to ${targetDirectory}`);
}
}

37 changes: 27 additions & 10 deletions eng/tools/oav-runner/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import * as path from 'path';
// import * as glob from 'glob';
import * as fs from 'fs';

import { consoleLogger } from '@azure-tools/specs-shared/logger';
import { getChangedFiles, swagger } from "@azure-tools/specs-shared/changed-files";
import { ReportableOavError } from './formatting.js';

export async function checkSpecs(rootDirectory: string): Promise<[number, Array<object>]> {
let errors: Array<object> = [];
export async function checkSpecs(rootDirectory: string): Promise<[number, Array<ReportableOavError>]> {
let errors: Array<ReportableOavError> = [];

console.log(`Executing checks in ${rootDirectory}`);
consoleLogger.info(`Executing checks in ${rootDirectory}`);

const changedFiles = await getChangedFiles({
cwd: rootDirectory
Expand All @@ -23,14 +25,29 @@ export async function checkSpecs(rootDirectory: string): Promise<[number, Array<
for (const swaggerFile of swaggerFiles) {
try {
const errorResults = await oav.validateSpec(swaggerFile, undefined);

if (errorResults.validateSpec && errorResults.validateSpec.errors){
errors.push(errorResults.validateSpec.errors);
for(const error of errorResults.validateSpec.errors) {
errors.push( {
message: `${error.code}: ${error.message}`,
file: swaggerFile,
line: error.position?.line,
column: error.position?.column
} as ReportableOavError);
}
}
}
catch (e) {
// todo: add error handling beyond logging
console.log(e);
if (e instanceof Error) {
errors.push( {
message: e.message,
file: swaggerFile
} as ReportableOavError);
} else {
errors.push( {
message: `Unhandled error validating ${swaggerFile}: ${e}`,
file: swaggerFile
} as ReportableOavError);
}
}
}

Expand Down Expand Up @@ -64,9 +81,9 @@ export async function processFilesToSpecificationList(rootDirectory: string, fil
return false;
}

let swaggerResult = swagger(file);
let targetFile = path.join(rootDirectory, file);
console.log(`Checking ${targetFile}`);
const swaggerResult = swagger(file);
const targetFile = path.join(rootDirectory, file);
consoleLogger.info(`Checking ${targetFile}`);

// if it's a swagger file, we should check to see if it exists
// as a deleted file will also show up in the changed files list
Expand Down