Skip to content

Commit b7226a5

Browse files
authored
ci: add lints + format check (#114)
Link to PR: Arm-Debug/vgf-adapter-model-explorer#114
1 parent c072bbb commit b7226a5

File tree

8 files changed

+53
-30
lines changed

8 files changed

+53
-30
lines changed

.github/actions/build-wheel/action.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ runs:
198198
NPROC=$(sysctl -n hw.ncpu)
199199
fi
200200
python ${SDK_PATH}/sw/vgf-lib/scripts/build.py -j $NPROC
201-
202201
203202
- name: Copy dependencies
204203
shell: bash
@@ -228,9 +227,9 @@ runs:
228227
shell: bash
229228
run: |
230229
cd "$WORK_DIR"
231-
python -m pip install .[test]
230+
python -m pip install . --group dev
232231
if [ "${{ github.repository_owner }}" != "arm" ]; then
233-
python -m pip install .[coverage]
232+
python -m pip install . --group coverage
234233
fi
235234
236235
- name: Update PATH
@@ -269,7 +268,7 @@ runs:
269268
shell: bash
270269
run: |
271270
cd "$WORK_DIR"
272-
python -m pip install .[sbom]
271+
python -m pip install . --group sbom
273272
python ./scripts/generate-mlir-bin-sbom.py \
274273
--llvm-ref ${{ steps.dep-revisions.outputs.llvm-ref }} \
275274
--model-converter-ref ${{ steps.dep-revisions.outputs.model-converter-ref }} \
@@ -286,7 +285,7 @@ runs:
286285
287286
echo -e "[bdist_wheel]\npython_tag = cp$TAG\nplat_name = ${{ inputs.platform }}" > setup.cfg
288287
289-
python -m pip install build wheel
288+
python -m pip install --group build
290289
python -m build
291290
292291
mkdir -p wheelhouse

.github/workflows/check.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,28 @@ on:
66

77
jobs:
88
lint-and-format:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python-version: ["3.13", "3.12", "3.11", "3.10"]
913
runs-on: ubuntu-latest
1014
steps:
11-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12-
- name: Install qlty
13-
uses: qltysh/qlty-action/install@v1
14-
- name: Check lint
15+
- uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Checkout plugin repo
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
21+
- name: Install plugin Python packages
22+
run: |
23+
pip install --upgrade pip
24+
pip install . --group dev
25+
26+
- name: Lint and Format Check
27+
run: |
28+
ruff check --output-format=github
29+
ruff format --check
30+
31+
- name: Type Check
1532
run: |
16-
qlty check
33+
pyright

pyproject.toml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,31 @@ dependencies = [
3737
Repository = "https://github.com/arm/vgf-adapter-model-explorer"
3838
Changelog = "https://github.com/arm/vgf-adapter-model-explorer/releases"
3939

40-
[project.optional-dependencies]
41-
test = [
42-
"pytest",
43-
"pytest-timeout",
40+
[dependency-groups]
41+
dev = [
42+
"pytest==9.0.1",
43+
"pytest-timeout==2.4.0",
44+
"ruff==0.14.2",
45+
"pyright==1.1.407",
4446
"ai-edge-model-explorer==0.1.28"
4547
]
46-
format = [
47-
"ruff==0.14.2"
48-
]
4948
coverage = [
50-
"pytest-cov"
49+
"pytest-cov==7.0.0",
50+
]
51+
build = [
52+
"build==1.3.0",
53+
"wheel==0.45.1"
5154
]
5255
sbom = [
5356
"spdx-tools==0.8.3"
5457
]
5558

5659
[tool.pyright]
57-
extraPaths = [
58-
".",
59-
"./src",
60+
include = [
61+
"src",
6062
]
61-
autoSearchPaths = true
62-
useLibraryCodeForTypes = true
63-
diagnosticMode = "workspace"
63+
typeCheckingMode = "standard"
64+
6465

6566
[tool.setuptools]
6667
include-package-data = true
@@ -84,7 +85,7 @@ testpaths = ["src/vgf_adapter_model_explorer/tests"]
8485

8586
[tool.ruff]
8687
line-length = 79
87-
target-version = "py312"
88+
target-version = "py310"
8889

8990
[tool.ruff.lint]
9091
# https://docs.astral.sh/ruff/rules/

src/vgf_adapter_model_explorer/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Any, Dict, List, Optional
88

99
import numpy as np
10-
from mlir import ir
10+
from mlir import ir # type: ignore[reportMissingImports]
1111
from model_explorer import graph_builder as gb
1212

1313
from . import constants as cn

src/vgf_adapter_model_explorer/parser/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import json
88
import os
9+
from pathlib import Path
910
from typing import Any, Callable, Dict
1011

1112
from .types import (
@@ -24,7 +25,7 @@ class Parser:
2425
def __init__(
2526
self,
2627
model_path: str,
27-
spirv_binary_extractor: Callable[[str], Dict[str, Any]],
28+
spirv_binary_extractor: Callable[[str], Path],
2829
):
2930
self.model_name = os.path.basename(model_path)
3031
spv_path = spirv_binary_extractor(os.path.abspath(model_path))

src/vgf_adapter_model_explorer/spirv/spirv.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import Dict
88

9-
from mlir import ir
9+
from mlir import ir # type: ignore[reportMissingImports]
1010
from model_explorer import graph_builder as gb
1111

1212
from .. import constants as cn
@@ -70,7 +70,10 @@ def build_function_graph(
7070
traversed_ops=traversed_ops,
7171
)
7272

73-
if "Tosa" not in operation.name and "GraphOutputs" not in operation.name:
73+
if (
74+
"Tosa" not in operation.name
75+
and "GraphOutputs" not in operation.name
76+
):
7477
continue
7578

7679
function_graph.nodes.append(node)

src/vgf_adapter_model_explorer/spirv/spirv_node_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Licensed under the Apache License v2.0
55
# See http://www.apache.org/licenses/LICENSE-2.0 for license information.
66

7-
from mlir import ir
7+
from mlir import ir # type: ignore[reportMissingImports]
88
from model_explorer import graph_builder as gb
99

1010
from ..constants import GRAPH_INPUT_ANNOTATION

src/vgf_adapter_model_explorer/tests/test_model_explorer_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def test_model_explorer_smoke():
4141
]
4242
seen_lines = dict.fromkeys(searched_lines, False)
4343

44+
assert proc.stdout is not None
45+
4446
for line in proc.stdout:
4547
if searched_lines[curr_searched] in line:
4648
seen_lines[searched_lines[curr_searched]] = True

0 commit comments

Comments
 (0)