generated from reviewdog/action-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hollow Man <hollowman@opensuse.org>
- Loading branch information
1 parent
a56a83c
commit b0c0eb7
Showing
9 changed files
with
145 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,14 @@ ENV REVIEWDOG_VERSION=v0.14.1 | |
|
||
SHELL ["/bin/ash", "-eo", "pipefail", "-c"] | ||
|
||
# hadolint ignore=DL3006 | ||
RUN apk --no-cache add git | ||
|
||
RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} | ||
|
||
# TODO: Install a linter and/or change docker image as you need. | ||
RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/ | ||
ENV PYTHONUNBUFFERED=1 | ||
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python | ||
Check warning on line 10 in Dockerfile GitHub Actions / runner / hadolint
|
||
RUN python3 -m ensurepip | ||
RUN pip3 install --no-cache --upgrade pip setuptools | ||
Check warning on line 12 in Dockerfile GitHub Actions / runner / hadolint
Check warning on line 12 in Dockerfile GitHub Actions / runner / hadolint
Check warning on line 12 in Dockerfile GitHub Actions / runner / hadolint
|
||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
COPY convert.py /convert.py | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
import json | ||
|
||
content = {} | ||
with open(sys.argv[1]) as file: | ||
content = json.load(file) | ||
|
||
for run in content["runs"]: | ||
rdjson = {} | ||
tool = run["tool"] | ||
driver = tool["driver"] | ||
name = driver["name"] | ||
informationUri = driver["informationUri"] | ||
rule = {} | ||
ruleLevel = {} | ||
rdjson["source"] = { | ||
"name": name, | ||
"url": informationUri | ||
} | ||
diagnostics = [] | ||
for r in driver["rules"]: | ||
id = r["id"] | ||
description = "\n#### " + id + " " | ||
level = r["defaultConfiguration"]["level"] | ||
if level == "warning": | ||
level = "WARNING" | ||
elif level == "error": | ||
level = "ERROR" | ||
elif level == "note": | ||
level = "INFO" | ||
else: | ||
level = "UNKNOWN_SEVERITY" | ||
if "shortDescription" in r: | ||
description += r["shortDescription"]["text"] + ":\n" | ||
if "fullDescription" in r: | ||
description += r["fullDescription"]["text"] + "\n\n" | ||
if "help" in r: | ||
description += "*" + r["help"]["text"] + "*\n" | ||
rule[id] = description | ||
ruleLevel[id] = level | ||
for result in run["results"]: | ||
ruleId = result["ruleId"] | ||
description = rule[ruleId] | ||
# if "message" in result: | ||
# description += result["message"]["text"] + "\n" | ||
sarifLocation = result["locations"][0]["physicalLocation"] | ||
path = sarifLocation["artifactLocation"]["uri"] | ||
location = { | ||
"path": path, | ||
"range": { | ||
"start": { | ||
"line": sarifLocation["region"]["startLine"], | ||
"column": sarifLocation["region"]["startColumn"] | ||
} | ||
} | ||
} | ||
if "endLine" in sarifLocation["region"]: | ||
location["range"]["end"] = { | ||
"line": sarifLocation["region"]["endLine"], | ||
"column": sarifLocation["region"]["endColumn"] | ||
} | ||
suggestions = [] | ||
if "fixes" in result: | ||
for fix in result["fixes"]: | ||
ac = fix["artifactChanges"][0] | ||
if path != ac["artifactLocation"]["uri"]: | ||
continue | ||
replace = ac["replacements"][0] | ||
deleted = replace["deletedRegion"] | ||
suggest = { | ||
"range": { | ||
"start": { | ||
"line": deleted["startLine"], | ||
"column": deleted["startColumn"] | ||
}, | ||
"end": { | ||
"line": deleted["endLine"], | ||
"column": deleted["endColumn"] | ||
} | ||
} | ||
} | ||
location["range"] = suggest | ||
if "insertedContent" in replace: | ||
suggest["text"] = replace["insertedContent"]["text"] | ||
suggestions.append(suggest) | ||
diagnostic = { | ||
"message": description, | ||
"location": location, | ||
"severity": ruleLevel[ruleId], | ||
"code": { | ||
"value": ruleId, | ||
}, | ||
"suggestions": suggestions, | ||
} | ||
diagnostics.append(diagnostic) | ||
rdjson["diagnostics"] = diagnostics | ||
print(json.dumps(rdjson)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.