Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional results and multiple tables #72

Open
msorens opened this issue Jan 13, 2025 · 1 comment
Open

Conditional results and multiple tables #72

msorens opened this issue Jan 13, 2025 · 1 comment

Comments

@msorens
Copy link

msorens commented Jan 13, 2025

Got this hooked up in my github actions and works well with the default "all" tables. Thanks for doing this!

Two questions:
(1) Rather than all I would like more terse output, really just summary and failed. Is it possible to specify more than one table? All of your examples use a single table.
(2) Even more terse 😁 : only show those selected tables if there are failures; is this possible?

@Ma11hewThomas
Copy link
Contributor

It's best to use the custom report - for example -

npx github-actions-ctrf custom ctrf-reports/ctrf-report.json templates/custom-report.hbs

The custom templates/custom-report.hbs can make use of the anyFailedTests helper to show the failed report when failed tests are detected - Something like below:

| **Build {{getCtrfEmoji "build"}}** | **Result {{getCtrfEmoji "result"}}** | **Tests {{getCtrfEmoji "tests"}}** | **Passed {{getCtrfEmoji "passed"}}** | **Failed {{getCtrfEmoji "failed"}}** | **Skipped {{getCtrfEmoji "skipped"}}** | **Pending {{getCtrfEmoji "pending"}}** | **Other {{getCtrfEmoji "other"}}** | **Flaky {{getCtrfEmoji "flaky"}}** | **Duration {{getCtrfEmoji "duration"}}** |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [#{{ctrf.environment.extra.runNumber}}]({{ctrf.environment.extra.buildUrl}}) | {{getCtrfEmoji ctrf.summary.extra.result}} | {{ctrf.summary.tests}} | {{ctrf.summary.passed}} | {{ctrf.summary.failed}} | {{ctrf.summary.skipped}} | {{ctrf.summary.pending}} | {{ctrf.summary.other}} | {{countFlaky ctrf.tests}} | {{formatDuration ctrf.summary.start ctrf.summary.stop}} |
{{#each ctrf.extra.previousReports}}
| [#{{this.results.environment.extra.runNumber}}]({{this.results.environment.extra.buildUrl}}) | {{getCtrfEmoji this.results.summary.extra.result}} | {{this.results.summary.tests}} | {{this.results.summary.passed}} | {{this.results.summary.failed}} | {{this.results.summary.skipped}} | {{this.results.summary.pending}} | {{this.results.summary.other}} | {{this.results.summary.extra.flaky}} | {{formatDuration this.results.summary.start this.results.summary.stop}} |
{{/each}}

{{#if (anyFailedTests ctrf.tests)}}
<table>
    <thead>
      <tr>
        <th>Failed Tests {{getCtrfEmoji "failed"}}</th>
        <th>Fail Message</th>
      </tr>
    </thead>
    <tbody>
      {{#each ctrf.tests}}
        {{#if (eq status "failed")}}
        <tr>
          <td>{{getCtrfEmoji "failed"}} {{name}}</td>
          <td>{{#if message}}{{~{formatMessage message}}}{{else}}No failure message{{/if}}</td>
        </tr>
        {{/if}}
      {{/each}}
    </tbody>
  </table>
{{/if}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants