Skip to content

Commit 532f1c1

Browse files
committed
envoy.code.check: Add bazel checks
Signed-off-by: Ryan Northey <[email protected]>
1 parent b0615f4 commit 532f1c1

File tree

12 files changed

+2249
-9
lines changed

12 files changed

+2249
-9
lines changed

envoy.code.check/envoy/code/check/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ toolshed_library(
1515
"__init__.py",
1616
"abstract/__init__.py",
1717
"abstract/base.py",
18+
"abstract/bazel.py",
1819
"abstract/changelog.py",
1920
"abstract/checker.py",
2021
"abstract/extensions.py",
@@ -30,6 +31,7 @@ toolshed_library(
3031
"cmd.py",
3132
"exceptions.py",
3233
"interface.py",
34+
"shared.py",
3335
"typing.py",
3436
],
3537
)

envoy.code.check/envoy/code/check/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from . import abstract, exceptions, typing
33
from .abstract import (
44
ABackticksCheck,
5+
ABazelCheck,
56
AChangelogChangesChecker,
67
AChangelogCheck,
78
AChangelogStatus,
@@ -20,6 +21,7 @@
2021
AYamllintCheck,
2122
AYapfCheck)
2223
from .checker import (
24+
BazelCheck,
2325
ChangelogChangesChecker,
2426
ChangelogCheck,
2527
ChangelogStatus,
@@ -33,12 +35,13 @@
3335
YamllintCheck,
3436
YapfCheck)
3537
from .cmd import run, main
36-
from . import checker, interface
38+
from . import checker, interface, shared
3739

3840

3941
__all__ = (
4042
"abstract",
4143
"ABackticksCheck",
44+
"ABazelCheck",
4245
"AChangelogChangesChecker",
4346
"AChangelogCheck",
4447
"AChangelogStatus",
@@ -56,6 +59,7 @@
5659
"AShellcheckCheck",
5760
"AYamllintCheck",
5861
"AYapfCheck",
62+
"BazelCheck",
5963
"ChangelogChangesChecker",
6064
"ChangelogCheck",
6165
"ChangelogStatus",
@@ -69,9 +73,8 @@
6973
"interface",
7074
"main",
7175
"run",
72-
"main",
73-
"run",
7476
"RuntimeGuardsCheck",
77+
"shared",
7578
"ShellcheckCheck",
7679
"typing",
7780
"YamllintCheck",

envoy.code.check/envoy/code/check/abstract/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
from .base import ACodeCheck, AFileCodeCheck, AProjectCodeCheck
3+
from .bazel import ABazelCheck
34
from .changelog import (
45
AChangelogCheck,
56
AChangelogChangesChecker,
@@ -19,6 +20,7 @@
1920
from .yapf import AYapfCheck
2021
from . import (
2122
base,
23+
bazel,
2224
checker,
2325
extensions,
2426
flake8,
@@ -32,6 +34,7 @@
3234

3335
__all__ = (
3436
"ABackticksCheck",
37+
"ABazelCheck",
3538
"AChangelogChangesChecker",
3639
"AChangelogCheck",
3740
"AChangelogStatus",
@@ -50,6 +53,7 @@
5053
"AYamllintCheck",
5154
"AYapfCheck",
5255
"base",
56+
"bazel",
5357
"checker",
5458
"extensions",
5559
"flake8",

envoy.code.check/envoy/code/check/abstract/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11

22
import asyncio
3+
import pathlib
4+
import shutil
35
from concurrent import futures
46
from typing import Dict, List, Optional, Set
57

68
import abstracts
79

8-
from aio.core import event
10+
from aio.core import event, subprocess
911
from aio.core.directory import ADirectory
1012
from aio.core.functional import async_property
1113

@@ -35,6 +37,14 @@ def __init__(
3537
def binaries(self):
3638
return self._binaries
3739

40+
def command_path(self, command_name: str) -> pathlib.Path:
41+
if command_name in self.binaries:
42+
return pathlib.Path(self.binaries[command_name]).absolute()
43+
if command := shutil.which(command_name):
44+
return pathlib.Path(command)
45+
raise subprocess.exceptions.OSCommandError(
46+
f"Unable to find {command_name} command")
47+
3848

3949
@abstracts.implementer(interface.IFileCodeCheck)
4050
class AFileCodeCheck(ACodeCheck, metaclass=abstracts.Abstraction):

0 commit comments

Comments
 (0)