Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cicd #25

Merged
merged 18 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/scripts/parse_pylint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import sys


def main(file):
with open(file, "r", encoding="utf-8") as f:
lines = f.readlines()

summary = [line for line in lines if line.startswith(
"Your code has been rated at")][0]

report_start_index = [i for i, line in enumerate(
lines) if line.startswith("Raw metrics")][0]
report_end_index = [i for i, line in enumerate(
lines) if line.startswith("Your code has been rated at")][0]

report = lines[report_start_index:report_end_index-2]

new_report = []
for line in report:
if len(line.strip()) == 0:
new_report.append(line)
elif len(line.strip().replace("-", "")) == 0:
line = line.replace("-", "#")
new_report.append(line)
elif line.startswith("+="):
line = line.replace("+", "|")
line = line.replace("=", "-")
new_report.append(line)
elif line.startswith("+-"):
continue
else:
new_report.append(line)

print("PYLINT REPORT ")
print(" ")
print(summary, " ")
print(" ")
print("<details>")
print(" <summary>Full report</summary>")
print(" ")
for line in new_report:
print(" ", line, end="")
print("</details>")


if __name__ == "__main__":
main(*sys.argv[1:])
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Test Coverage
on:
push:
branches:
- '*'
- main
- dev
pull_request:
branches:
- '*'
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Pylint

on:
push:
branches:
- main
- dev
pull_request:
branches:
- '*'
workflow_dispatch:

permissions:
contents: read
pull-requests: write

jobs:
pylint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: build PQAnalysis
run: |
pip install pylint
pip install pylint-django
pip install .

- name: Lint with pylint
shell: bash
run: |
pylint PQAnalysis --exit-zero | tee pylint_output.txt
python .github/scripts/parse_pylint.py pylint_output.txt | tee comment.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: (success() || failure()) && github.event.pull_request
with:
recreate: true
path: comment.txt
- if: (success() || failure()) && !github.event.pull_request
run: |
cat comment.txt >> "${GITHUB_STEP_SUMMARY}"



9 changes: 6 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension-pkg-whitelist=
fail-on=

# Specify a score threshold under which the program will exit with error.
fail-under=10
fail-under=9.5

# Interpret the stdin as a python script, whose filename needs to be passed as
# the module_or_package argument.
Expand Down Expand Up @@ -206,7 +206,10 @@ good-names=i,
k,
ex,
Run,
_
_,
x,
y,
z

# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
Expand Down Expand Up @@ -514,7 +517,7 @@ msg-template=
#output-format=

# Tells whether to display a full report or only the messages.
reports=no
reports=yes

# Activate the evaluation score.
score=yes
Expand Down
Loading
Loading