Merge pull request #31649 from woocommerce/try/remove-some-test-label

Remove smoke test label on failure
This commit is contained in:
Ron Rennick 2022-02-02 10:31:21 -04:00 committed by GitHub
commit 8e98a7c1e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -96,7 +96,9 @@ jobs:
await script({github, context})
- name: Remove label from pull request.
if: always() && ${{ contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':')) }}
if: |
always()
&& contains( github.event.pull_request.labels.*.name, format('run{0} smoke tests', ':'))
uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -5,14 +5,22 @@ const resultsFile = path.resolve( __dirname, '../test-results.json' );
const buildOutput = ( results ) => {
const { TITLE, SMOKE_TEST_URL } = process.env;
const resultKeys = Object.keys( results );
let output = `## ${ TITLE }:\n\n`;
output += `**Test URL:** ${ SMOKE_TEST_URL }\n`;
output += `**Total Number of Passed Tests:** ${ results.numTotalTests }\n`;
output += `**Total Number of Failed Tests:** ${ results.numFailedTests }\n`;
output += `**Total Number of Test Suites:** ${ results.numTotalTestSuites }\n`;
output += `**Total Number of Passed Test Suites:** ${ results.numPassedTestSuites }\n`;
output += `**Total Number of Failed Test Suites:** ${ results.numFailedTestSuites }\n`;
resultKeys.forEach( ( key ) => {
// The keys that we care about all start with 'num'
if ( key.includes( 'num' ) ) {
// match only capitalized words
const words = key.match( /[A-Z][a-z]+/g );
output += `**Total Number of ${ words.join( ' ' ) }:** ${
results[ key ]
}\n`;
}
} );
return output;
};
@ -26,7 +34,8 @@ module.exports = async ( { github, context } ) => {
output = buildOutput( results );
} else {
output = `## Test Results Not Found!`;
output = `## Test Results Not Found! \n\n`;
output += 'The path to the `test-results.json` file may need to be updated.';
}
await github.rest.issues.createComment( {