Skip to content

Commit

Permalink
Merge pull request #393 from muno92/feature-391
Browse files Browse the repository at this point in the history
Add option to specify minimumReportSeverity
  • Loading branch information
muno92 authored Jun 11, 2023
2 parents e8d42ee + 489e83e commit 8997b0c
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
with:
solutionPath: TestSolution/TestSolution.sln
failOnIssue: '0'
minimumReportSeverity: 'WARNING'
# Reproduce second time execution on self-hosted runner
- uses: ./
with:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Version of the Resharper CLI tool to install. Defaults to the latest available.

### minimumSeverity

- INFO
- HINT (default)
- SUGGESTION
- WARNING
- ERROR

Minimum severity for issues to be reported. Defaults to "HINT".

### minimumSeverity

- error
- warning
- notice (default)
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
version:
required: false
description: Version of the Resharper CLI tool to install. Defaults to the latest available.
minimumReportSeverity:
required: false
description: Minimum severity for issues to be reported. Defaults to "HINT". [INFO, HINT, SUGGESTION, WARNING, ERROR]
default: 'hint'
minimumSeverity:
required: false
description: Minimum severity for issues to cause the action to fail. Defaults to "notice". Ignored if failOnIssue is set to '0'.
Expand Down
20 changes: 19 additions & 1 deletion 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.

12 changes: 9 additions & 3 deletions src/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class Issue {
public FilePath: string,
public Column: number,
public Message: string,
public Severity: Severity,
public Severity: GitHubSeverity,
public Line?: number
) {}

Expand All @@ -15,8 +15,14 @@ export class Issue {
}
}

export type Severity = 'notice' | 'warning' | 'error'
export type GitHubSeverity = 'notice' | 'warning' | 'error'
export type ReSharperSeverity =
| 'INFO'
| 'HINT'
| 'SUGGESTION'
| 'WARNING'
| 'ERROR'

export type IssueTypes = {
[Id: string]: Severity
[Id: string]: GitHubSeverity
}
25 changes: 24 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec'
import {Installer} from './installer'
import {Report} from './report'
import {ReSharperSeverity} from './issue'

async function run(): Promise<void> {
try {
Expand All @@ -12,7 +13,7 @@ async function run(): Promise<void> {
const solutionPath: string = core.getInput('solutionPath')
const outputPath = 'result.xml'

let command = `jb inspectcode --build --output=${outputPath} --severity=HINT --absolute-paths ${solutionPath}`
let command = `jb inspectcode --build --output=${outputPath} --absolute-paths ${solutionPath}`

const include: string = core.getInput('include')
if (include) {
Expand All @@ -32,6 +33,10 @@ async function run(): Promise<void> {
}swea`
}

const minimumReportSeverity = getMinimumReportSeverity()

command += ` --severity=${minimumReportSeverity}`

const workingDir: string = core.getInput('workingDirectory')
if (workingDir) {
core.debug(`Changing to working directory: ${workingDir}`)
Expand Down Expand Up @@ -62,4 +67,22 @@ async function run(): Promise<void> {
}
}

function getMinimumReportSeverity(): ReSharperSeverity {
const minimumReportSeverity =
core.getInput('minimumReportSeverity').toUpperCase() ?? ''

switch (minimumReportSeverity) {
case 'INTO':
return 'INFO'
case 'SUGGESTION':
return 'SUGGESTION'
case 'WARNING':
return 'WARNING'
case 'ERROR':
return 'ERROR'
default:
return 'HINT'
}
}

run()
6 changes: 3 additions & 3 deletions src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as core from '@actions/core'
import * as fs from 'fs'
import * as htmlparser2 from 'htmlparser2'
import {Document, Element} from 'domhandler'
import {Issue, IssueTypes, Severity} from './issue'
import {GitHubSeverity, Issue, IssueTypes} from './issue'
import {issueCommand} from '@actions/core/lib/command'

export class Report {
Expand Down Expand Up @@ -80,7 +80,7 @@ export class Report {
private extractIssueTypes(xml: Document): IssueTypes {
const issueTypes: IssueTypes = {}

const convertSeverity = (severity: string): Severity => {
const convertSeverity = (severity: string): GitHubSeverity => {
switch (severity) {
case 'hint':
case 'suggestion':
Expand Down Expand Up @@ -134,7 +134,7 @@ export class Report {
return this.issues.filter(i => errorTarget.includes(i.Severity)).length > 0
}

private switchErrorTarget(minimumSeverity: string): Severity[] {
private switchErrorTarget(minimumSeverity: string): GitHubSeverity[] {
if (minimumSeverity === 'error') {
return ['error']
}
Expand Down

0 comments on commit 8997b0c

Please sign in to comment.