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

Add link on badge when using GH Action Summary #492

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion __tests__/__outputs__/dart-json.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/dart-json.json|1 ✅|4 ❌|1 ⚪|4s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/dotnet-nunit.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-3%20passed%2C%205%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-3%20passed%2C%205%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/dotnet-nunit.xml|3 ✅|5 ❌|1 ⚪|230ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/dotnet-trx.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-5%20passed%2C%205%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-5%20passed%2C%205%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/dotnet-trx.trx|5 ✅|5 ❌|1 ⚪|1s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/fluent-validation-test-results.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![Tests passed successfully](https://img.shields.io/badge/tests-803%20passed%2C%201%20skipped-success)
[![Tests passed successfully](https://img.shields.io/badge/tests-803%20passed%2C%201%20skipped-success)](#user-content-test-report)
<details><summary>Expand for details</summary>

# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/FluentValidation.Tests.trx|803 ✅||1 ⚪|4s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/jest-junit-eslint.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)
[![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)](#user-content-test-report)
<details><summary>Expand for details</summary>

# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/jest-junit-eslint.xml|1 ✅|||0ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/jest-junit.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/jest-junit.xml|1 ✅|4 ❌|1 ⚪|1s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/jest-react-component-test-results.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)
[![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)](#user-content-test-report)
<details><summary>Expand for details</summary>

# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/jest/jest-react-component-test-results.xml|1 ✅|||1000ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/jest-test-results.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-4207%20passed%2C%202%20failed%2C%2030%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-4207%20passed%2C%202%20failed%2C%2030%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/jest/jest-test-results.xml|4207 ✅|2 ❌|30 ⚪|166s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/mocha-json.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%204%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/mocha-json.json|1 ✅|4 ❌|1 ⚪|12ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/mocha-test-results.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![Tests passed successfully](https://img.shields.io/badge/tests-833%20passed%2C%206%20skipped-success)
[![Tests passed successfully](https://img.shields.io/badge/tests-833%20passed%2C%206%20skipped-success)](#user-content-test-report)
<details><summary>Expand for details</summary>

# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/mocha/mocha-test-results.json|833 ✅||6 ⚪|6s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/provider-test-results.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-268%20passed%2C%201%20failed-critical)
[![Tests failed](https://img.shields.io/badge/tests-268%20passed%2C%201%20failed-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/flutter/provider-test-results.json|268 ✅|1 ❌||0ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/pulsar-test-results-no-merge.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-1%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-1%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/java/TEST-org.apache.pulsar.AddMissingPatchVersionTest.xml||1 ❌|1 ⚪|116ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/pulsar-test-results.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-793%20passed%2C%201%20failed%2C%2014%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-793%20passed%2C%201%20failed%2C%2014%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/java/pulsar-test-report.xml|793 ✅|1 ❌|14 ⚪|2127s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/rspec-json.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%201%20failed%2C%201%20skipped-critical)
[![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%201%20failed%2C%201%20skipped-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/rspec-json.json|1 ✅|1 ❌|1 ⚪|0ms|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/silent-notes-test-results.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![Tests passed successfully](https://img.shields.io/badge/tests-67%20passed%2C%2012%20skipped-success)
[![Tests passed successfully](https://img.shields.io/badge/tests-67%20passed%2C%2012%20skipped-success)](#user-content-test-report)
<details><summary>Expand for details</summary>

# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/external/SilentNotes.trx|67 ✅||12 ⚪|1s|
Expand Down
3 changes: 2 additions & 1 deletion __tests__/__outputs__/swift-xunit.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Tests failed](https://img.shields.io/badge/tests-2%20passed%2C%201%20failed-critical)
[![Tests failed](https://img.shields.io/badge/tests-2%20passed%2C%201%20failed-critical)](#user-content-test-report)
# <a name="user-content-test-report"></a> Tests report
|Report|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|fixtures/swift-xunit.xml|2 ✅|1 ❌||220ms|
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/report/get-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function getBadge(passed: number, failed: number, skipped: number, options: Repo
}
const hint = failed > 0 ? 'Tests failed' : 'Tests passed successfully'
const uri = encodeURIComponent(`${options.badgeTitle}-${message}-${color}`)
return `![${hint}](https://img.shields.io/badge/${uri})`
return `[![${hint}](https://img.shields.io/badge/${uri})](#user-content-test-report)`
}

function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): string[] {
Expand All @@ -149,6 +149,8 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s
sections.push(` `)
}

sections.push('# <a name="user-content-test-report"></a> Tests report')

if (testRuns.length > 0 || options.onlySummary) {
const tableData = testRuns
.filter(tr => tr.passed > 0 || tr.failed > 0 || tr.skipped > 0)
Expand Down