Skip to content

Commit

Permalink
use artifact metadata for labelling runs
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Dec 2, 2024
1 parent 80568be commit a604214
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions sample/test-reporter.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
artifact_filter = url.artifact_name ?: "";
variance_threshold = url.variance_threshold ?: 10; // threshold for reporting test case different performance
commit_base_hef = "https://github.com/#repo#/commit/";
github_token = url.githubToken ?: "";
if ( !len( github_token ) )
throw "no github token?";
Expand All @@ -28,7 +30,7 @@
for (a = 1; a LTE len(response.artifacts); a++ ){
if (response.artifacts[a].name contains artifact_filter
&& response.artifacts[a].workflow_run.head_branch eq branch){
// systemOutput(response.artifacts[a], true);
systemOutput(response.artifacts[a], true);
if (response.artifacts[a].expired)
break;
artifact_zip = getTempFile(getTempDirectory(),"github-artifact", "zip");
Expand All @@ -45,7 +47,7 @@
httpparam type="header" name="X-GitHub-Api-Version" value="2022-11-28";
}; // this will return a 302
systemOutput( cfhttp, true );
//systemOutput( cfhttp, true );
if ( cfhttp.errorDetail does not contain "302 Found" )
throw "get download artifact url failed [#cfhttp.errordetail#]";
Expand All @@ -59,7 +61,7 @@
//httpparam type="header" name="Authorization" value="Bearer #github_token#";
//httpparam type="header" name="X-GitHub-Api-Version" value="2022-11-28";
};
systemOutput( cfhttp, true );
//systemOutput( cfhttp, true );
if ( cfhttp.error )
throw "download artifact failed [#cfhttp.errordetail#]";
// dump(cfhttp);
Expand All @@ -69,6 +71,10 @@
artifacts_files = directoryList( path=tmp_dir, filter=file_filter, sort="datelastmodifed desc" );
if ( len( artifacts_files ) eq 1){
ArrayAppend( files, artifacts_files[ 1 ] );
// add artifact metadata to json
json = deserializeJson( fileRead( artifacts_files[ 1 ] ) );
json["runMetaData"] = response.artifacts[a];
fileWrite( artifacts_files[ 1 ], serializeJSON( json ) );
ArrayAppend( artifact_found, response.artifacts[a].workflow_run.id );
} else {
systemOutput("No results found in artifacts missing? ")
Expand Down Expand Up @@ -113,12 +119,18 @@
}
}
arrayAppend( runs, {
"java": json.javaVersion,
"version": json.CFMLEngineVersion,
run = {
"java": json.javaVersion ?: "",
"version": json.CFMLEngineVersion ?: "",
"branch": json.runMetaData.workflow_run.head_branch,
"commit": json.runMetaData.workflow_run.head_sha,
"commitUrl": commit_base_hef & json.runMetaData.workflow_run.head_sha;
"commitDate": ParseDatetime(json.runMetaData.created_at),
"totalDuration": json.totalDuration,
"stats": queryToStruct(q, "suiteSpec")
});
};
arrayAppend( runs, duplicate( run ) );
};
if ( IsEmpty( runs ) ) throw "No json report files found?";
Expand Down Expand Up @@ -164,8 +176,8 @@
}
); // fastest to slowest
var hdr = [ "Version", "Java", "Time" ];
var div = [ "---", "---", "---:" ];
var hdr = [ "Version", "Java", "Branch", "Date", "Time" ];
var div = [ "---", "---", "---", "---", "---:" ];
_logger( "" );
_logger( "|" & arrayToList( hdr, "|" ) & "|" );
_logger( "|" & arrayToList( div, "|" ) & "|" );
Expand All @@ -175,6 +187,8 @@
loop array=runs item="local.run" {
ArrayAppend( row, run.version );
ArrayAppend( row, run.java );
ArrayAppend( row, run.branch );
ArrayAppend( row, DateTimeFormat( run.commitDate ) );
arrayAppend( row, numberFormat( run.totalDuration ) );
_logger( "|" & arrayToList( row, "|" ) & "|" );
html &= "<tr><td>" & arrayToList( row, "<td>" ) & "</tr>";
Expand All @@ -195,15 +209,19 @@
arraySort(
sortedRuns,
function (e1, e2){
return compare(e1.version & e1.java, e2.version & e2.java);
return dateCompare( e1.commitDate, e2.commitDate );
//return compare(e1.version & e1.java, e2.version & e2.java);
}
); // sort runs by oldest version to newest version
var hdr = [ "Suite", "Spec" ];
var div = [ "---", "---" ];
loop array=sortedRuns item="local.run" {
arrayAppend( hdr, run.version & " " & listFirst(run.java,".") );
if ( len ( run.version ) gt 0 )
arrayAppend( hdr, run.version & " " & listFirst( run.java,"." ) );
else
arrayAppend( hdr, REReplace( wrap( DateTimeFormat( run.commitDate ), 11 ), "\n", " ", "ALL") );
arrayAppend( div, "---:" ); // right align as they are all numeric
}
Expand Down Expand Up @@ -246,8 +264,8 @@
var row = [];
loop array=suiteSpecs item="test" {
// force long names to wrap without breaking markdown
ArrayAppend( row, REReplace( wrap(test.suite, 70), "\n", " ", "ALL") );
ArrayAppend( row, REReplace( wrap(test.Spec, 70), "\n", " ", "ALL") );
ArrayAppend( row, REReplace( wrap( test.suite, 70 ), "\n", " ", "ALL") );
ArrayAppend( row, REReplace( wrap( test.Spec, 70 ), "\n", " ", "ALL") );
loop array=sortedRuns item="local.run" {
if ( structKeyExists( run.stats, test.suiteSpec ) )
arrayAppend( row, numberFormat( run.stats[test.suiteSpec].time ) );
Expand Down

0 comments on commit a604214

Please sign in to comment.