bitwarden_workflow_linter 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bitwarden_workflow_linter/__about__.py +1 -1
- bitwarden_workflow_linter/actions.py +2 -0
- bitwarden_workflow_linter/cli.py +2 -0
- bitwarden_workflow_linter/lint.py +1 -0
- bitwarden_workflow_linter/load.py +4 -0
- bitwarden_workflow_linter/models/job.py +1 -0
- bitwarden_workflow_linter/models/step.py +1 -0
- bitwarden_workflow_linter/rule.py +2 -0
- bitwarden_workflow_linter/rules/job_environment_prefix.py +1 -0
- bitwarden_workflow_linter/rules/name_capitalized.py +10 -3
- bitwarden_workflow_linter/rules/name_exists.py +1 -0
- bitwarden_workflow_linter/rules/pinned_job_runner.py +1 -0
- bitwarden_workflow_linter/rules/step_approved.py +1 -0
- bitwarden_workflow_linter/rules/step_pinned.py +4 -0
- bitwarden_workflow_linter/rules/underscore_outputs.py +11 -5
- bitwarden_workflow_linter/utils.py +8 -0
- {bitwarden_workflow_linter-0.1.0.dist-info → bitwarden_workflow_linter-0.2.0.dist-info}/METADATA +1 -2
- bitwarden_workflow_linter-0.2.0.dist-info/RECORD +27 -0
- {bitwarden_workflow_linter-0.1.0.dist-info → bitwarden_workflow_linter-0.2.0.dist-info}/WHEEL +1 -1
- bitwarden_workflow_linter-0.1.0.dist-info/RECORD +0 -27
- {bitwarden_workflow_linter-0.1.0.dist-info → bitwarden_workflow_linter-0.2.0.dist-info}/entry_points.txt +0 -0
- {bitwarden_workflow_linter-0.1.0.dist-info → bitwarden_workflow_linter-0.2.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -11,11 +11,13 @@ from typing import Optional, Union
|
|
11
11
|
|
12
12
|
from .utils import Colors, Settings, Action
|
13
13
|
|
14
|
+
|
14
15
|
class GitHubApiSchemaError(Exception):
|
15
16
|
"""A generic Exception to catch redefinitions of GitHub Api Schema changes."""
|
16
17
|
|
17
18
|
pass
|
18
19
|
|
20
|
+
|
19
21
|
class ActionsCmd:
|
20
22
|
"""Command to manage the pre-approved list of Actions
|
21
23
|
|
bitwarden_workflow_linter/cli.py
CHANGED
@@ -11,6 +11,7 @@ from .utils import Settings
|
|
11
11
|
|
12
12
|
local_settings = Settings.factory()
|
13
13
|
|
14
|
+
|
14
15
|
def main(input_args: Optional[List[str]] = None) -> int:
|
15
16
|
"""CLI utility to lint GitHub Action Workflows.
|
16
17
|
|
@@ -48,5 +49,6 @@ def main(input_args: Optional[List[str]] = None) -> int:
|
|
48
49
|
|
49
50
|
return -1
|
50
51
|
|
52
|
+
|
51
53
|
if __name__ == "__main__":
|
52
54
|
sys.exit(main())
|
@@ -15,11 +15,13 @@ from .utils import Settings
|
|
15
15
|
|
16
16
|
yaml = YAML()
|
17
17
|
|
18
|
+
|
18
19
|
class WorkflowBuilderError(Exception):
|
19
20
|
"""Exception to indicate an error with the WorkflowBuilder."""
|
20
21
|
|
21
22
|
pass
|
22
23
|
|
24
|
+
|
23
25
|
class WorkflowBuilder:
|
24
26
|
"""Collection of methods to build Workflow objects."""
|
25
27
|
|
@@ -82,11 +84,13 @@ class WorkflowBuilder:
|
|
82
84
|
"The workflow must either be built from a file or from a CommentedMap"
|
83
85
|
)
|
84
86
|
|
87
|
+
|
85
88
|
class LoadRulesError(Exception):
|
86
89
|
"""Exception to indicate an error with loading rules."""
|
87
90
|
|
88
91
|
pass
|
89
92
|
|
93
|
+
|
90
94
|
class Rules:
|
91
95
|
"""A collection of all of the types of rules.
|
92
96
|
|
@@ -7,11 +7,13 @@ from .models.job import Job
|
|
7
7
|
from .models.step import Step
|
8
8
|
from .utils import LintFinding, LintLevels, Settings
|
9
9
|
|
10
|
+
|
10
11
|
class RuleExecutionException(Exception):
|
11
12
|
"""Exception for the Base Rule class."""
|
12
13
|
|
13
14
|
pass
|
14
15
|
|
16
|
+
|
15
17
|
class Rule:
|
16
18
|
"""Base class of a Rule to extend to create a linting Rule."""
|
17
19
|
|
@@ -8,6 +8,7 @@ from ..models.workflow import Workflow
|
|
8
8
|
from ..rule import Rule
|
9
9
|
from ..utils import LintLevels, Settings
|
10
10
|
|
11
|
+
|
11
12
|
class RuleNameCapitalized(Rule):
|
12
13
|
"""Rule to enforce all 'name' values start with a capital letter.
|
13
14
|
|
@@ -50,6 +51,12 @@ class RuleNameCapitalized(Rule):
|
|
50
51
|
capitalized names. This Rule DOES NOT enforce that the name exists.
|
51
52
|
It only enforces capitalization IF it does.
|
52
53
|
"""
|
53
|
-
if obj
|
54
|
-
|
55
|
-
|
54
|
+
if isinstance(obj, Workflow):
|
55
|
+
if obj.name:
|
56
|
+
if obj.name[0] != "_":
|
57
|
+
return obj.name[0].isupper(), self.message
|
58
|
+
else:
|
59
|
+
if obj.name:
|
60
|
+
return obj.name[0].isupper(), self.message
|
61
|
+
|
62
|
+
return True, "" # Force passing
|
@@ -6,6 +6,7 @@ from ..models.step import Step
|
|
6
6
|
from ..rule import Rule
|
7
7
|
from ..utils import LintLevels, Settings
|
8
8
|
|
9
|
+
|
9
10
|
class RuleStepUsesPinned(Rule):
|
10
11
|
"""Rule to contain the enforcement logic for pinning Actions versions.
|
11
12
|
|
@@ -94,4 +95,7 @@ class RuleStepUsesPinned(Rule):
|
|
94
95
|
if len(ref) != 40:
|
95
96
|
return False, "Please use the full commit sha to pin the action"
|
96
97
|
|
98
|
+
if not obj.uses_comment:
|
99
|
+
return False, "Please comment the version of the action commit sha"
|
100
|
+
|
97
101
|
return True, ""
|
@@ -1,3 +1,5 @@
|
|
1
|
+
""" Rule to enforce all GitHub outputs with more than one words use an underscore."""
|
2
|
+
|
1
3
|
import re
|
2
4
|
|
3
5
|
from typing import Optional, Union, Tuple
|
@@ -8,8 +10,9 @@ from ..models.workflow import Workflow
|
|
8
10
|
from ..models.step import Step
|
9
11
|
from ..utils import LintLevels, Settings
|
10
12
|
|
13
|
+
|
11
14
|
class RuleUnderscoreOutputs(Rule):
|
12
|
-
"""Rule to enforce all GitHub
|
15
|
+
"""Rule to enforce all GitHub outputs with more than one word use an underscore.
|
13
16
|
|
14
17
|
A simple standard to ensure uniformity in naming.
|
15
18
|
"""
|
@@ -90,7 +93,8 @@ class RuleUnderscoreOutputs(Rule):
|
|
90
93
|
outputs.extend(obj.on["workflow_dispatch"]["outputs"].keys())
|
91
94
|
|
92
95
|
if obj.on.get("workflow_call"):
|
93
|
-
|
96
|
+
if obj.on["workflow_call"].get("outputs"):
|
97
|
+
outputs.extend(obj.on["workflow_call"]["outputs"].keys())
|
94
98
|
|
95
99
|
if isinstance(obj, Job):
|
96
100
|
if obj.outputs:
|
@@ -98,9 +102,11 @@ class RuleUnderscoreOutputs(Rule):
|
|
98
102
|
|
99
103
|
if isinstance(obj, Step):
|
100
104
|
if obj.run:
|
101
|
-
outputs.extend(
|
102
|
-
|
103
|
-
|
105
|
+
outputs.extend(
|
106
|
+
re.findall(
|
107
|
+
r"\b([a-zA-Z0-9_-]+)\s*=\s*[^=]*>>\s*\$GITHUB_OUTPUT", obj.run
|
108
|
+
)
|
109
|
+
)
|
104
110
|
|
105
111
|
for output_name in outputs:
|
106
112
|
if "-" in output_name:
|
@@ -12,6 +12,7 @@ from ruamel.yaml import YAML
|
|
12
12
|
|
13
13
|
yaml = YAML()
|
14
14
|
|
15
|
+
|
15
16
|
@dataclass
|
16
17
|
class Colors:
|
17
18
|
"""Class containing color codes for printing strings to output."""
|
@@ -25,6 +26,7 @@ class Colors:
|
|
25
26
|
cyan = "36m"
|
26
27
|
white = "37m"
|
27
28
|
|
29
|
+
|
28
30
|
@dataclass
|
29
31
|
class LintLevel:
|
30
32
|
"""Class to contain the numeric level and color of linting."""
|
@@ -32,6 +34,7 @@ class LintLevel:
|
|
32
34
|
code: int
|
33
35
|
color: Colors
|
34
36
|
|
37
|
+
|
35
38
|
class LintLevels(LintLevel, Enum):
|
36
39
|
"""Collection of the different types of LintLevels available."""
|
37
40
|
|
@@ -39,6 +42,7 @@ class LintLevels(LintLevel, Enum):
|
|
39
42
|
WARNING = 1, Colors.yellow
|
40
43
|
ERROR = 2, Colors.red
|
41
44
|
|
45
|
+
|
42
46
|
class LintFinding:
|
43
47
|
"""Represents a problem detected by linting."""
|
44
48
|
|
@@ -57,6 +61,7 @@ class LintFinding:
|
|
57
61
|
f"{self.description}"
|
58
62
|
)
|
59
63
|
|
64
|
+
|
60
65
|
@dataclass
|
61
66
|
class Action:
|
62
67
|
"""Collection of the metadata associated with a GitHub Action."""
|
@@ -93,13 +98,16 @@ class Action:
|
|
93
98
|
"""
|
94
99
|
return not self.__eq__(other)
|
95
100
|
|
101
|
+
|
96
102
|
class SettingsError(Exception):
|
97
103
|
"""Custom Exception to indicate an error with loading Settings."""
|
98
104
|
|
99
105
|
pass
|
100
106
|
|
107
|
+
|
101
108
|
SettingsFromFactory = TypeVar("SettingsFromFactory", bound="Settings")
|
102
109
|
|
110
|
+
|
103
111
|
class Settings:
|
104
112
|
"""Class that contains configuration-as-code for any portion of the app."""
|
105
113
|
|
{bitwarden_workflow_linter-0.1.0.dist-info → bitwarden_workflow_linter-0.2.0.dist-info}/METADATA
RENAMED
@@ -1,10 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: bitwarden_workflow_linter
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: Custom GitHub Action Workflow Linter
|
5
5
|
Project-URL: Homepage, https://github.com/bitwarden/workflow-linter
|
6
6
|
Project-URL: Issues, https://github.com/bitwarden/workflow-linter/issues
|
7
|
-
License-File: LICENSE.txt
|
8
7
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
9
8
|
Classifier: Operating System :: OS Independent
|
10
9
|
Classifier: Programming Language :: Python :: 3
|
@@ -0,0 +1,27 @@
|
|
1
|
+
bitwarden_workflow_linter/__about__.py,sha256=si3RgiuWR12lqpriKwtC4ny_xoVAWdz9oa4DWW-3QuY,59
|
2
|
+
bitwarden_workflow_linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
bitwarden_workflow_linter/actions.py,sha256=daob3be2Y22gfsAmGhTgBRCgGk18mlGduqc5Zn1Onz4,7897
|
4
|
+
bitwarden_workflow_linter/cli.py,sha256=wgkK1MlVbo6Zx3f2CZZ_tkSWq_hdsGciHJA1knX6Yuw,1699
|
5
|
+
bitwarden_workflow_linter/default_actions.json,sha256=BeFllnAu9v6cX6eeGeNoQf3rXs7ZOjAtjTNBQuAZ8-k,8087
|
6
|
+
bitwarden_workflow_linter/default_settings.yaml,sha256=EMKRFPFlbgkWtZGUA10Y758RJfAjuI8IUDeqRnRTTs8,505
|
7
|
+
bitwarden_workflow_linter/lint.py,sha256=z83h7XOnULngPqTwlo5LKCK2ciUu4oalwixKVcFLWac,5461
|
8
|
+
bitwarden_workflow_linter/load.py,sha256=Ece2bwSSYeQ1xQQEjjqY6DlCkwznFYLG56VW_VTxU4E,4472
|
9
|
+
bitwarden_workflow_linter/rule.py,sha256=Qb60JiUDAWN3ayrMGoSbbDCSFmw-ql8djzAkxISaob4,3250
|
10
|
+
bitwarden_workflow_linter/utils.py,sha256=9WO3T9w9vKAow_xR6JDz2MvdMXKExV18AzucF0vh67s,4695
|
11
|
+
bitwarden_workflow_linter/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
+
bitwarden_workflow_linter/models/job.py,sha256=nBK7_VYu6RRST7WLtdLsoRErl5j4Er8W9hCw9XlSECk,2043
|
13
|
+
bitwarden_workflow_linter/models/step.py,sha256=1bKAtKZmHcO8O1e_HuoXxR1bwHDEXUssYo7EHOjY7QI,1711
|
14
|
+
bitwarden_workflow_linter/models/workflow.py,sha256=MkqvIY4JX2eWFODNTodS_l4I8uUq08WCHy3C4kYcL0s,1395
|
15
|
+
bitwarden_workflow_linter/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
+
bitwarden_workflow_linter/rules/job_environment_prefix.py,sha256=QCYNj-sX5VB5v49OkBdmFGDkm1E2ebcfiAvlkDVNx7g,2415
|
17
|
+
bitwarden_workflow_linter/rules/name_capitalized.py,sha256=XwRZ33OeQv_i7z_2Yf7TEgJNodOl5byXfegqfmhaTYQ,1914
|
18
|
+
bitwarden_workflow_linter/rules/name_exists.py,sha256=MxcaNQz64JXeHRPiOip9BxJNgPdpKQa7Z51mDoNw2hU,1681
|
19
|
+
bitwarden_workflow_linter/rules/pinned_job_runner.py,sha256=Dm6_sdPX0yFMji_y2LMFj4gWFaToEgauyBVpNRP2qiI,1606
|
20
|
+
bitwarden_workflow_linter/rules/step_approved.py,sha256=UIi9_z9j75SpQUmo29MLDhjLklqd4h0D-UYqkdcaju0,3307
|
21
|
+
bitwarden_workflow_linter/rules/step_pinned.py,sha256=e9yhbo9wsz7CDj1s4fGEsktA8B9YarzE26R_zmNLs7M,3400
|
22
|
+
bitwarden_workflow_linter/rules/underscore_outputs.py,sha256=s1tySiVCAQOd0-GbKan-bfR6g75WYhf-kiGHin6Iecc,4101
|
23
|
+
bitwarden_workflow_linter-0.2.0.dist-info/METADATA,sha256=Ngdn_7McvWBsZdScPnK0oIDaFvq_I9vjw-RCIa1_Sgo,6146
|
24
|
+
bitwarden_workflow_linter-0.2.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
25
|
+
bitwarden_workflow_linter-0.2.0.dist-info/entry_points.txt,sha256=SA_yF9CwL4VMUvdcmCd7k9rjsQNzfeOUBuDnMnaO8QQ,60
|
26
|
+
bitwarden_workflow_linter-0.2.0.dist-info/licenses/LICENSE.txt,sha256=uY-7N9tbI7xc_c0WeTIGpacSCnsB91N05eCIg3bkaRw,35140
|
27
|
+
bitwarden_workflow_linter-0.2.0.dist-info/RECORD,,
|
@@ -1,27 +0,0 @@
|
|
1
|
-
bitwarden_workflow_linter/__about__.py,sha256=MXkdpln7M2kqsAFMZY-qjYn8eOBN6pR3T26TyjoZEtI,59
|
2
|
-
bitwarden_workflow_linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
bitwarden_workflow_linter/actions.py,sha256=bjuFAP72QHXlDTmMBZffNmSCjZDzyNHGzqEC78ABAgg,7895
|
4
|
-
bitwarden_workflow_linter/cli.py,sha256=GABKYWYmcKl4LrA-cgo4ME0mWD4xaO4AgZHBeCCDMy4,1697
|
5
|
-
bitwarden_workflow_linter/default_actions.json,sha256=BeFllnAu9v6cX6eeGeNoQf3rXs7ZOjAtjTNBQuAZ8-k,8087
|
6
|
-
bitwarden_workflow_linter/default_settings.yaml,sha256=EMKRFPFlbgkWtZGUA10Y758RJfAjuI8IUDeqRnRTTs8,505
|
7
|
-
bitwarden_workflow_linter/lint.py,sha256=Ftz9I3hZS0Vbpn-zk3XKp35Cth3eEo9yf-25rZHrY4k,5460
|
8
|
-
bitwarden_workflow_linter/load.py,sha256=E3DPC66rObcmktOKGu3YkGAzWPZLVgSLdZr59DQzz5w,4468
|
9
|
-
bitwarden_workflow_linter/rule.py,sha256=H1uwzxck849gh7-kigBgu9RgpJ3lCu3hizQWtZupRJE,3248
|
10
|
-
bitwarden_workflow_linter/utils.py,sha256=IyPnxgb91XKXqCifRR5RWEfmZv5F2G9qvwVQVLZd-Bs,4687
|
11
|
-
bitwarden_workflow_linter/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
-
bitwarden_workflow_linter/models/job.py,sha256=fkoAC_OV1ekGK40M01iJTtoUJX3Ey6sZWpUTAL5TlSM,2042
|
13
|
-
bitwarden_workflow_linter/models/step.py,sha256=C5GNp-pn4GJ0xhAvOKhrFdNYpnCujxGOzKtpACaV5Xg,1710
|
14
|
-
bitwarden_workflow_linter/models/workflow.py,sha256=MkqvIY4JX2eWFODNTodS_l4I8uUq08WCHy3C4kYcL0s,1395
|
15
|
-
bitwarden_workflow_linter/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
bitwarden_workflow_linter/rules/job_environment_prefix.py,sha256=lAjvnn2PU1uVyHKRtJiehHmPHfQVaMNY-MLPPRuFvoY,2414
|
17
|
-
bitwarden_workflow_linter/rules/name_capitalized.py,sha256=VlxPpM82-vg2PlJGU5GWzdamYaz8DJ_AWuMgYzHNgsQ,1751
|
18
|
-
bitwarden_workflow_linter/rules/name_exists.py,sha256=eEPtU5y5T0aRQrICdiW1vju1Ny31VUCh_gOf6C6yFSI,1680
|
19
|
-
bitwarden_workflow_linter/rules/pinned_job_runner.py,sha256=hg8R6JDAAAhoiEgA9ihWhwLznIicbSw0knJvYI1TYEI,1605
|
20
|
-
bitwarden_workflow_linter/rules/step_approved.py,sha256=KhQTmqLkYjwZRZHspUwPBWXy1DExLoOQLp3sEoGM9qI,3306
|
21
|
-
bitwarden_workflow_linter/rules/step_pinned.py,sha256=BBCSbC-XyeB_ZILtA1q59NOB3IbY1QY8qpYt_gQ4YvM,3285
|
22
|
-
bitwarden_workflow_linter/rules/underscore_outputs.py,sha256=A-EDU_0uexQEwzjg5bwgqkPQInI-hVYRqCNX-BTRXL4,3909
|
23
|
-
bitwarden_workflow_linter-0.1.0.dist-info/METADATA,sha256=m97phO-mQ9T2UwYjM9u0tgusHpuka825k6OVBreN9K4,6172
|
24
|
-
bitwarden_workflow_linter-0.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
25
|
-
bitwarden_workflow_linter-0.1.0.dist-info/entry_points.txt,sha256=SA_yF9CwL4VMUvdcmCd7k9rjsQNzfeOUBuDnMnaO8QQ,60
|
26
|
-
bitwarden_workflow_linter-0.1.0.dist-info/licenses/LICENSE.txt,sha256=uY-7N9tbI7xc_c0WeTIGpacSCnsB91N05eCIg3bkaRw,35140
|
27
|
-
bitwarden_workflow_linter-0.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|