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/badges #2

Merged
merged 5 commits into from
Jul 17, 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
175 changes: 175 additions & 0 deletions .github/workflows/lint.yaml
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
7 changes: 4 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ permissions:
jobs:
test:
uses: ./.github/workflows/test.yaml
lint:
uses: ./.github/workflows/lint.yaml
# Build job
build-docs:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -55,12 +57,11 @@ jobs:
- name: Build pages
run: |
cd sphinx
make github
make html
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: docs
# Deployment job
path: sphinx/build/html
deploy-docs:
concurrency:
group: "pages"
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
pip install -e .[dev]
- name: Demo
run: |
pytest -rP --cov-report html:pytest/coverage --cov=src test --html=pytest/report.html
pytest test/demo
- name: Test
run: |
pytest -rP --cov-report html:pytest/coverage --cov=src test --html=pytest/report.html --ignore=test/demo
- name: Upload demo artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -37,3 +40,9 @@
with:
name: report
path: pytest
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4

Check warning on line 44 in .github/workflows/test.yaml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/test.yaml#L44

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
verbose: true # optional (default = false)
use_oidc: true

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ build:
post_checkout:
- git fetch --unshallow || true
- git fetch --all --tags || true
pre_build:
- pytest -rP --cov-report html:pytest/coverage --cov=src test --html=pytest/report.html --ignore=test/demo
- mkdir sphinx/source/prebuilt
- cp -r pytest/* sphinx/source/prebuilt

sphinx:
configuration: sphinx/source/conf.py
Expand All @@ -25,4 +29,4 @@ python:
- method: pip
path: .
extra_requirements:
- doc
- dev
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# plotly-gtk

| Master |
| - |
| [![Checks](https://img.shields.io/github/actions/workflow/status/slaclau/plotly-gtk/main.yaml?logo=github&label=Checks)](https://github.com/slaclau/plotly-gtk/actions/workflows/main.yaml) |
| [![codecov](https://img.shields.io/codecov/c/github/slaclau/plotly-gtk?logo=codecov&label=Coverage)](https://codecov.io/github/slaclau/plotly-gtk) |
| [![codacy](https://img.shields.io/codacy/grade/db07fc38606a432dae8f2dc316ff6913?logo=codacy&label=Code%20quality)]() |

Check notice on line 7 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L7

No empty links

## Introdution

GTK renderer for charts in plotly Figure or dict format

## Examples

### [Line and scatter plots](https://plotly.com/python/line-and-scatter/)

<summary>Scatter plots with Plotly Express</summary>
<details>

Expand Down
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
status:
project:
default:
target: auto
threshold: 5
base: auto
comment:
require_head: no
require_base: no
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ build-backend = "setuptools.build_meta"

[project.optional-dependencies]
doc = ["pylint", "sphinx", "sphinx-pyreverse", "pydata-sphinx-theme", "sphinx-rtd-theme", "plotly"]
lint = ["black", "isort", "flake8", "flake8-pylint", "flake8-json", "flake8-bugbear", "mypy", "mypy-json-report", "pygobject-stubs", "deptry"]
test = ["plotly", "pytest", "pillow", "selenium","pytest-subtests", "pytest-cov", "pytest-html"]
dev = ["plotly-gtk[doc, test]"]
dev = ["plotly-gtk[doc, lint, test]"]

[tool.setuptools.dynamic]
readme = {file = "README.md", content-type = "text/markdown"}
Expand Down Expand Up @@ -105,6 +106,5 @@ require-plugins = [
]
docstring_style = "numpy"

[tool.coverage.run]
omit = ["test/demo"]

[tool.deptry]
pep621_dev_dependency_groups = ["doc", "lint", "test"]
18 changes: 18 additions & 0 deletions scripts/deptry2md.py
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)
46 changes: 46 additions & 0 deletions scripts/flake82md.py
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]} |")

Check notice on line 17 in scripts/flake82md.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/flake82md.py#L17

f-string: unmatched '(' (F999)
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
19 changes: 19 additions & 0 deletions scripts/mypy2md.py
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()
Loading
Loading