Skip to content

Commit

Permalink
Merge pull request #8 from JetBrains/v2.2-eap-baseline
Browse files Browse the repository at this point in the history
V2.2 eap baseline
  • Loading branch information
ak1113 authored Sep 14, 2021
2 parents 9b7a026 + 09b875d commit 19a26b6
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/baseline-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Qodana - Code Inspection Example

on:
workflow_dispatch:
push:

jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache Qodana dependencies
uses: actions/cache@v2
with:
path: ~/work/_temp/_github_home/qodana-cache
key: ${{ runner.os }}-qodana-${{ github.ref }}
restore-keys: |
${{ runner.os }}-qodana-${{ github.ref }}
${{ runner.os }}-qodana-
- name: Qodana - Code Inspection
uses: JetBrains/[email protected]
with:
fail-threshold: 1
baseline: ".github/workflows/baseline.sarif.json"
baseline-include-absent: true

- name: Save Qodana's results to artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/qodana
40 changes: 40 additions & 0 deletions .github/workflows/baseline.sarif.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "qodana-intellij",
"fullName": "Qodana Intellij Linter",
"version": "212.5145",
"rules": [],
"taxa": [],
"language": "en-US",
"contents": [
"localizedData",
"nonLocalizedData"
],
"isComprehensive": false
},
"extensions": []
},
"invocations": [
{
"exitCode": 0,
"executionSuccessful": true
}
],
"language": "en-US",
"results": [],
"automationDetails": {
"id": "project - 9/14/21, 12:51 PM",
"guid": "6819b8c2-dd31-4203-b37f-345f02c6a5bf"
},
"newlineSequences": [
"\r\n",
"\n"
]
}
]
}

2 changes: 1 addition & 1 deletion .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
${{ runner.os }}-qodana-
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@v2.1-eap
uses: JetBrains/qodana-action@v2.2-eap

- uses: actions/upload-artifact@v2
with:
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ Input parameters:
* `project-dir` - Project folder to inspect (default `${{ github.workspace }}`)
* `results-dir` - Save results to folder (default `${{ github.workspace }}/qodana`)
* `cache-dir` - Save cache to folder (default `/home/runner/work/_temp/_github_home/qodana-cache`)
* `inspected-dir` - Directory to be inspected. If not specified, the whole project is inspected by default
* `baseline` - Run in baseline mode. Provide the path to an exisitng SARIF report to be used in the baseline state calculation
* `baseline-include-absent` - Include in the output report the results from the baseline run that are absent in the current run (default `false`)
* `fail-threshold` - Set the number of problems that will serve as a quality gate. If this number is reached, the inspection run is terminated
* `save-html-report` - Generate HTML report (default `false`)
* `profile-name` - Name of a profile defined in project
* `profile-path` - Absolute path to the profile file

```yaml
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@v2.1-eap
uses: JetBrains/qodana-action@v2.2-eap
```
All action's inputs are optional.
```yaml
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@v2.1-eap
uses: JetBrains/qodana-action@v2.2-eap
with:
project-dir: ${{ github.workspace }}
results-dir: ${{ github.workspace }}/qodana
Expand Down
38 changes: 35 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,42 @@ inputs:
description: 'Save cache to folder'
required: false
default: "/home/runner/work/_temp/_github_home/qodana-cache"
inspected-dir:
description: 'Directory to be inspected. If not specified, the whole project is inspected by default'
required: false
baseline:
description: 'Run in baseline mode. Provide the path to an exisitng SARIF report to be used in the baseline state calculation'
required: false
baseline-include-absent:
description: 'Include in the output report the results from the baseline run that are absent in the current run'
required: false
default: false
fail-threshold:
description: 'Set the number of problems that will serve as a quality gate. If this number is reached, the inspection run is terminated'
required: false
save-html-report:
description: 'Generate HTML report'
required: false
default: false
profile-name:
description: 'Name of a profile defined in project'
required: false
profile-path:
description: 'Absolute path to the profile file'
required: false
runs:
using: 'composite'
steps:
- run: mkdir -p "${{inputs.results-dir}}" "${{inputs.cache-dir}}"
shell: bash
- run: docker run -u $UID -v ${{inputs.project-dir}}:/data/project -v ${{inputs.results-dir}}:/data/results -v ${{inputs.cache-dir}}:/data/cache jetbrains/qodana:2021.2-eap --save-report
- run: ./run_qodana.sh
shell: bash
env:
PROJECT_DIR: "${{ inputs.project-dir }}"
RESULTS_DIR: "${{ inputs.results-dir }}"
CACHE_DIR: "${{ inputs.cache-dir }}"
INSPECTED_DIR: "${{ inputs.inspected-dir }}"
BASELINE: "${{ inputs.baseline }}"
BASELINE_INCLUDE_ABSENT: "${{ inputs.baseline-include-absent }}"
FAIL_THRESHOLD: "${{ inputs.fail-threshold }}"
SAVE_HTML_REPORT: "${{ inputs.save-html-report }}"
PROFILE_NAME: "${{ inputs.profile-name }}"
PROFILE_PATH: "${{ inputs.profile-path }}"
25 changes: 25 additions & 0 deletions run_qodana.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

get_str_arg_or_empty() {
local argument_name=$1
local argument_value=$2
[ -n "$argument_value" ] && echo "$argument_name $argument_value" || echo ""
}

get_bool_arg_or_empty() {
local argument_name=$1
local argument_value=$2
[ "$argument_value" == "true" ] && echo "$argument_name" || echo ""
}

mkdir -p "$RESULTS_DIR" "$CACHE_DIR"

docker run -u $UID -v "$PROJECT_DIR:/data/project" -v "$RESULTS_DIR:/data/results" \
-v "$CACHE_DIR:/data/cache" jetbrains/qodana:2021.2-eap \
$(get_str_arg_or_empty "-d" "$INSPECTED_DIR") \
$(get_str_arg_or_empty "-b" "$BASELINE") \
$(get_bool_arg_or_empty "--baseline-include-absent" "$BASELINE_INCLUDE_ABSENT") \
$(get_str_arg_or_empty "--fail-threshold" "$FAIL_THRESHOLD") \
$(get_bool_arg_or_empty "--save-report" "$SAVE_HTML_REPORT") \
$(get_str_arg_or_empty "-profileName" "$PROFILE_NAME") \
$(get_str_arg_or_empty "-profilePath" "$PROFILE_PATH")

0 comments on commit 19a26b6

Please sign in to comment.