-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR: #2
- Loading branch information
Showing
7 changed files
with
265 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
name: "lint" | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
flake8: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- name: Install python packages | ||
run: | | ||
pip install -e .[lint] | ||
- name: flake8 | ||
if: always() | ||
run: | | ||
flake8 src --format=json >> flake8.json | ||
- name: flake8 report | ||
if: always() | ||
run: | | ||
python scripts/flake82md.py flake8.json "flake8 report" >> flake8.md | ||
cat flake8.md >> $GITHUB_STEP_SUMMARY | ||
- name: Upload report | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: flake8 | ||
path: | | ||
flake8.json | ||
flake8.md | ||
mypy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- name: Install python packages | ||
run: | | ||
pip install -e .[lint] | ||
- name: mypy | ||
if: always() | ||
run: | | ||
mypy --strict src | mypy-json-report parse --output-file mypy.json | ||
exit ${PIPESTATUS[0]} | ||
- name: mypy report | ||
if: always() | ||
run: | | ||
python scripts/mypy2md.py mypy.json "mypy report" >> mypy.md | ||
cat mypy.md >> $GITHUB_STEP_SUMMARY | ||
- name: Upload report | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: mypy | ||
path: | | ||
mypy.json | ||
mypy.md | ||
black: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- name: Install python packages | ||
run: | | ||
pip install -e .[lint] | ||
- name: black | ||
if: always() | ||
run: | | ||
echo "# black report" >> black.md | ||
echo "These files have not been formatted" >> black.md | ||
black --check src &>> black.md | ||
- name: black report | ||
if: always() | ||
run: | | ||
sed -i "s/would reformat \/home\/runner\/work\/plotly-gtk\/plotly-gtk\///g" black.md | ||
sed -i "s/_/\\_/g" black.md | ||
cat black.md >> $GITHUB_STEP_SUMMARY | ||
- name: Upload report | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: black | ||
path: black.md | ||
|
||
isort: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- name: Install python packages | ||
run: | | ||
pip install -e .[lint] | ||
- name: isort | ||
if: always() | ||
run: | | ||
echo "# isort report" >> isort.md | ||
echo "These files have not been formatted" >> isort.md | ||
isort -c src &>> isort.md | ||
- name: isort report | ||
if: always() | ||
run: | | ||
sed -i "s/\/home\/runner\/work\/plotly-gtk\/plotly-gtk\///g" isort.md | ||
cat isort.md >> $GITHUB_STEP_SUMMARY | ||
- name: Upload report | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: isort | ||
path: isort.md | ||
deptry: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- name: Install python packages | ||
run: | | ||
pip install -e .[lint] | ||
- name: deptry | ||
run: | | ||
deptry src --json-output deptry.json | ||
- name: deptry report | ||
if: always() | ||
run: | | ||
python scripts/deptry2md.py deptry.json "deptry report" >> deptry.md | ||
cat deptry.md >> $GITHUB_STEP_SUMMARY | ||
- name: Upload report | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: deptry | ||
path: | | ||
deptry.json | ||
deptry.md |
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
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,18 @@ | ||
import json | ||
import sys | ||
|
||
codes_dict={"DEP002": "Project should not contain unused dependencies"} | ||
|
||
with open(sys.argv[1]) as f: | ||
data = json.load(f) | ||
if len(sys.argv) > 1: | ||
print(f"# {sys.argv[2]}") | ||
codes = list({d["error"]["code"] for d in data}) | ||
for code in codes: | ||
if code in codes_dict: | ||
print(f"## {code}: {codes_dict[code]}") | ||
else: | ||
print(f"# {code}") | ||
modules = [d["module"] for d in data if d["error"]["code"] == code] | ||
for module in modules: | ||
print(module) |
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,46 @@ | ||
import json | ||
import sys | ||
|
||
with open(sys.argv[1]) as f: | ||
data = json.load(f) | ||
if len(sys.argv) > 1: | ||
print(f"# {sys.argv[2]}") | ||
n = 0 | ||
errors = {} | ||
for i in data: | ||
n += len(data[i]) | ||
errors[i] = len(data[i]) | ||
print(f"{len(data)} files checked, {n} issues found") | ||
print("| File | Issues |") | ||
print("| - | - |") | ||
for i in errors: | ||
print(f"| {i.replace("_", "\_")} | {errors[i]} |") | ||
for i in data: | ||
if len(data[i]) > 0: | ||
print(f"## {i.replace("_", "\_")}:") | ||
print(f"{len(data[i])} issues found") | ||
print("The following code(s) occurred in this file") | ||
print("| Occurences | Code | Meaning |") | ||
print("| - | - | - |") | ||
codes = sorted(set(d["code"] for d in data[i])) | ||
codeCount = {} | ||
codeText = {} | ||
for line in data[i]: | ||
codeCount[line["code"]] = codeCount.get(line["code"], 0) + 1 | ||
codeText[line["code"]] = line["text"] | ||
for code in codes: | ||
print(f"| {codeCount[code]} | {code} | {codeText[code]} |") | ||
print() | ||
count = 0 | ||
for line in data[i]: | ||
count += 1 | ||
print( | ||
f'{line["code"]}:{line["line_number"]}:{line["column_number"]}: {line["text"]}' | ||
) | ||
print("```python") | ||
if line["physical_line"] is not None: | ||
print(line["physical_line"].strip()) | ||
print("```") | ||
if count > 100: | ||
print(f"Truncated at {count} errors") | ||
break |
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,19 @@ | ||
import json | ||
import sys | ||
|
||
with open(sys.argv[1]) as f: | ||
data = json.load(f) | ||
if len(sys.argv) > 1: | ||
print(f"# {sys.argv[2]}") | ||
n = 0 | ||
for i in data: | ||
for line in data[i]: | ||
n += data[i][line] | ||
print(f"{len(data)} files checked, {n} issues found") | ||
for i in data: | ||
print(f"## {i}") | ||
print("| Occurrences | Message |") | ||
print("| - | - |") | ||
for line in data[i]: | ||
print(f"| {data[i][line]} | {line} |") | ||
print() |