Skip to content

Commit

Permalink
Merge pull request #11 from mikepenz/feature/improve_log_output
Browse files Browse the repository at this point in the history
Improved GitHub Actions logging
  • Loading branch information
mikepenz authored Jan 17, 2021
2 parents 456d947 + 2fb9ffb commit e02bf4b
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 10 deletions.
Binary file added .github/images/action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/annotated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/annotations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: mikepenz/action-junit-report-2@main
- name: Test JUnit test import
uses: ./
if: endsWith(github.ref, 'main') == false
with:
token: ${{ secrets.GITHUB_TOKEN }}
check_name: Example JUnit Test Report
report_paths: '**/surefire-reports/TEST-*.xml'
- uses: mikepenz/action-junit-report-2@main
- name: Test PyTest test import
uses: ./
if: endsWith(github.ref, 'main') == false
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
... reports JUnit test results as GitHub pull request check.
</p>

<div align="center">
<img src=".github/images/action.png"/>
</div>

<div align="center">
<a href="https://github.com/mikepenz/action-junit-report">
<img src="https://github.com/mikepenz/action-junit-report/workflows/CI/badge.svg"/>
Expand All @@ -22,7 +26,7 @@

This action processes JUnit XML test reports on pull requests and shows the result as a PR check with summary and annotations.

If you are looking for surefire reporting check out the amazing plugin by [ScaCap - action-surefire-report](https://github.com/ScaCap/action-surefire-report)
Based on action for [Surefire Reports by ScaCap](https://github.com/ScaCap/action-surefire-report)

### Inputs

Expand Down Expand Up @@ -59,7 +63,13 @@ jobs:
## Sample
![Screenshot](./screenshot.png)
<div align="center">
<img src=".github/images/annotated.png"/>
</div>
<div align="center">
<img src=".github/images/annotations.png"/>
</div>
## Contribute
Expand Down
8 changes: 8 additions & 0 deletions __tests__/testParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { resolveFileAndLine, resolvePath, parseFile } from '../src/testParser'

/**
* Original test cases:
* Copyright 2020 ScaCap
* https://github.com/ScaCap/action-surefire-report/blob/master/utils.test.js
*
* New test cases:
* Copyright Mike Penz
*/
describe('resolveFileAndLine', () => {
it('should default to 1 if no line found', async () => {
const { fileName, line } = await resolveFileAndLine(null, 'someClassName', 'not a stacktrace');
Expand Down
22 changes: 19 additions & 3 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function run(): Promise<void> {
const failOnFailure = core.getInput('fail_on_failure') === 'true'

core.endGroup()
core.startGroup(`📘 Process test results`)
core.startGroup(`📦 Process test results`)

const testResult = await parseTestReports(reportPaths)
const foundResults = testResult.count > 0 || testResult.skipped > 0
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function run(): Promise<void> {
core.debug(JSON.stringify(createCheckRequest, null, 2))
core.endGroup()

core.startGroup(`📘 Publish results`)
core.startGroup(`🚀 Publish results`)

try {
const octokit = new Octokit({
Expand Down
16 changes: 16 additions & 0 deletions src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export interface Position {
line: number
}

/**
* Copyright 2020 ScaCap
* https://github.com/ScaCap/action-surefire-report/blob/master/utils.js#L6
*/
export async function resolveFileAndLine(
file: string | null,
className: string,
Expand All @@ -42,6 +46,10 @@ export async function resolveFileAndLine(
return {fileName, line: parseInt(line)}
}

/**
* Copyright 2020 ScaCap
* https://github.com/ScaCap/action-surefire-report/blob/master/utils.js#L18
*/
export async function resolvePath(fileName: string): Promise<string> {
core.debug(`Resolving path for ${fileName}`)
const globber = await glob.create(`**/${fileName}.*`, {
Expand All @@ -59,6 +67,10 @@ export async function resolvePath(fileName: string): Promise<string> {
return fileName
}

/**
* Copyright 2020 ScaCap
* https://github.com/ScaCap/action-surefire-report/blob/master/utils.js#L43
*/
export async function parseFile(file: string): Promise<TestResult> {
core.debug(`Parsing file ${file}`)
let count = 0
Expand Down Expand Up @@ -137,6 +149,10 @@ export async function parseFile(file: string): Promise<TestResult> {
return {count, skipped, annotations}
}

/**
* Copyright 2020 ScaCap
* https://github.com/ScaCap/action-surefire-report/blob/master/utils.js#L113
*/
export async function parseTestReports(
reportPaths: string
): Promise<TestResult> {
Expand Down

0 comments on commit e02bf4b

Please sign in to comment.