Skip to content

Commit

Permalink
⚡ Use annotations API for GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Jun 13, 2023
1 parent 2cdf56e commit fa7d231
Show file tree
Hide file tree
Showing 6 changed files with 627 additions and 251 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,17 @@ jobs:
- uses: ./
with:
args: --print-problems,--log-level,debug,-l,jetbrains/qodana-js:latest
upload-result: true
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

qodana-no-pr: # pr mode disabled
qodana-no-pr: # pr mode disabled and no cloud token
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
args: --print-problems,--log-level,debug
pr-mode: false
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

# Not possible at the moment for GitHub-hosted Windows agents: https://github.com/JetBrains/qodana-action/pull/31#issue-812728409
# test-windows:
Expand Down
58 changes: 26 additions & 32 deletions scan/__tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {expect, test} from '@jest/globals'
import {parseSarif, Annotation} from '../src/output'
import {
sha256sum,
getQodanaSha256,
Expand All @@ -16,50 +15,45 @@ import * as fs from 'fs'
import path = require('path')

import * as os from 'os'
import {Annotation, parseSarif} from '../src/annotations'

const {execSync} = require('child_process')

function outputEmptyFixture(): Annotation[] {
return []
}

function outputDefaultFixture(): Annotation[] {
function annotationsDefaultFixture(): Annotation[] {
return [
{
level: 'warning',
annotation_level: 'warning',
message: "'while' has empty body",
properties: {
startLine: 271,
endLine: 271,
file: 'dokker/src/main/kotlin/io/github/tiulpin/Dokker.kt',
title: 'Control flow with empty body',
startColumn: undefined,
endColumn: undefined
}
start_line: 271,
end_line: 271,
path: 'dokker/src/main/kotlin/io/github/tiulpin/Dokker.kt',
title: 'Control flow with empty body',
start_column: undefined,
end_column: undefined
},
{
level: 'notice',
annotation_level: 'notice',
message: "Condition is always 'true'",
properties: {
startLine: 268,
endLine: 268,
file: 'dokker/src/main/kotlin/io/github/tiulpin/Dokker.kt',
title: "Condition of 'if' expression is constant",
startColumn: undefined,
endColumn: undefined
}
start_line: 268,
end_line: 268,
path: 'dokker/src/main/kotlin/io/github/tiulpin/Dokker.kt',
title: "Condition of 'if' expression is constant",
start_column: undefined,
end_column: undefined
},
{
level: 'notice',
annotation_level: 'notice',
message: "Might be 'const'",
properties: {
endLine: 283,
file: 'dokker/src/main/kotlin/io/github/tiulpin/Dokker.kt',
startLine: 283,
title: "Might be 'const'",
startColumn: undefined,
endColumn: undefined
}
end_line: 283,
path: 'dokker/src/main/kotlin/io/github/tiulpin/Dokker.kt',
start_line: 283,
title: "Might be 'const'",
start_column: undefined,
end_column: undefined
}
]
}
Expand Down Expand Up @@ -106,15 +100,15 @@ test('qodana scan command args', () => {
})

test('test sarif with problems to output annotations', () => {
const output = outputDefaultFixture()
const output = annotationsDefaultFixture()
const result = parseSarif('__tests__/data/some.sarif.json')
expect(result).toEqual(output)
expect(result.annotations).toEqual(output)
})

test('test sarif with no problems to output annotations', () => {
const output = outputEmptyFixture()
const result = parseSarif('__tests__/data/empty.sarif.json')
expect(result).toEqual(output)
expect(result.annotations).toEqual(output)
})

test('check whether action README.md has the latest version mentioned everywhere', () => {
Expand Down
Loading

0 comments on commit fa7d231

Please sign in to comment.