You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To enhance performance in the CI workflow, we propose optimizing the NUnit XML file check in results-check.ts by reading only the initial 4KB of each file when verifying the presence of the <test-run> tag. This change will reduce unnecessary I/O operations on large files and prevent processing of non-NUnit XML files in the artifacts directory. This improvement is particularly useful for projects with large test suites that produce sizeable XML files, as it minimizes memory usage and enhances CI performance.
Replace the current full-file read logic with the following snippet to implement the optimization:
try{constfilePath=path.join(artifactsPath,filepath);constfd=fs.openSync(filePath,'r');constbufferSize=4096;// Read the first 4KBconstbuffer=Buffer.alloc(bufferSize);constbytesRead=fs.readSync(fd,buffer,0,bufferSize,0);fs.closeSync(fd);constcontentStart=buffer.toString('utf8',0,bytesRead);if(!contentStart.includes('<test-run')){core.warning(`File does not appear to be a NUnit XML file: ${filepath}`);return;}constfileData=awaitResultsParser.parseResults(filePath);core.info(fileData.summary);runs.push(fileData);}catch(error: any){core.warning(`Failed to parse ${filepath}: ${error.message}`);}
Benefits
Performance Boost: Minimizes I/O operations and memory usage by only reading a small portion of each file.
Improved Efficiency: Enhances processing speed for large projects with extensive XML test results.
Streamlined Workflow: Reduces CI workflow interruptions by logging warnings for non-NUnit files instead of failing the entire run.
This improvement streamlines error handling and increases the resilience of file parsing in CI environments, benefiting large-scale Unity projects.
The text was updated successfully, but these errors were encountered:
GabLeRoux
changed the title
Optimize NUnit File Check by Reading Only Initial Portion for <test-run Tag
Optimize NUnit File Check by Reading Only Initial Portion of file to find <test-run Tag
Nov 11, 2024
GabLeRoux
changed the title
Optimize NUnit File Check by Reading Only Initial Portion of file to find <test-run Tag
Optimize NUnit file check by reading only initial portion of file to find <test-run tag
Nov 11, 2024
To enhance performance in the CI workflow, we propose optimizing the NUnit XML file check in
results-check.ts
by reading only the initial 4KB of each file when verifying the presence of the<test-run>
tag. This change will reduce unnecessary I/O operations on large files and prevent processing of non-NUnit XML files in the artifacts directory. This improvement is particularly useful for projects with large test suites that produce sizeable XML files, as it minimizes memory usage and enhances CI performance.For more details, refer to the discussion on the GitHub pull request here.
Proposed Code Change
Replace the current full-file read logic with the following snippet to implement the optimization:
Benefits
This improvement streamlines error handling and increases the resilience of file parsing in CI environments, benefiting large-scale Unity projects.
The text was updated successfully, but these errors were encountered: