bitwarden_workflow_linter 0.12.2__py3-none-any.whl → 0.12.4__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.
@@ -1,3 +1,3 @@
1
1
  """Metadata for Workflow Linter."""
2
2
 
3
- __version__ = "0.12.2"
3
+ __version__ = "0.12.4"
@@ -249,6 +249,11 @@
249
249
  "sha": "49b3bc8e6bdd4a60e6116a5414239cba5943d3cf",
250
250
  "version": "v3.2.0"
251
251
  },
252
+ "dorny/paths-filter": {
253
+ "name": "dorny/paths-filter",
254
+ "sha": "de90cc6fb38fc0963ad72b210f1f284cd68cea36",
255
+ "version": "v3.0.2"
256
+ },
252
257
  "dorny/test-reporter": {
253
258
  "name": "dorny/test-reporter",
254
259
  "sha": "31a54ee7ebcacc03a09ea97a7e5465a47b84aea5",
@@ -399,11 +404,21 @@
399
404
  "sha": "bfd4e558cda28cda6b5defafb9232d191be8c203",
400
405
  "version": "v4.2.1"
401
406
  },
407
+ "sravinet/toml-select": {
408
+ "name": "sravinet/toml-select",
409
+ "sha": "fe2e680f88a09851a0cd887dba0bbd19d3babe11",
410
+ "version": "v1.0.1"
411
+ },
402
412
  "stackrox/kube-linter-action": {
403
413
  "name": "stackrox/kube-linter-action",
404
414
  "sha": "5792edc6a03735d592b13c08201711327a935735",
405
415
  "version": "v1.0.5"
406
416
  },
417
+ "step-security/changed-files": {
418
+ "name": "step-security/changed-files",
419
+ "sha": "3dbe17c78367e7d60f00d78ae6781a35be47b4a1",
420
+ "version": "v45.0.1"
421
+ },
407
422
  "tyrrrz/action-http-request": {
408
423
  "name": "tyrrrz/action-http-request",
409
424
  "sha": "64c70c67f5ebc54d4c7ea09cbe3553322778afd5",
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: bitwarden_workflow_linter
3
+ Version: 0.12.4
4
+ Summary: Custom GitHub Action Workflow Linter
5
+ Project-URL: Homepage, https://github.com/bitwarden/workflow-linter
6
+ Project-URL: Issues, https://github.com/bitwarden/workflow-linter/issues
7
+ License-File: LICENSE.txt
8
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.11
12
+ Requires-Dist: annotated-types==0.7.0
13
+ Requires-Dist: dataclasses-json==0.6.6
14
+ Requires-Dist: marshmallow==3.21.2
15
+ Requires-Dist: mypy-extensions==1.0.0
16
+ Requires-Dist: packaging==24.0
17
+ Requires-Dist: pydantic-core==2.18.3
18
+ Requires-Dist: pydantic==2.7.2
19
+ Requires-Dist: pyyaml==6.0.1
20
+ Requires-Dist: ruamel-yaml-clib==0.2.8
21
+ Requires-Dist: ruamel-yaml==0.18.6
22
+ Requires-Dist: typing-extensions==4.12.0
23
+ Requires-Dist: typing-inspect==0.9.0
24
+ Requires-Dist: urllib3==2.2.1
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Bitwarden Workflow Linter
28
+
29
+ Bitwarden's Workflow Linter is an extensible linter to apply opinionated organization-specific GitHub Action standards. It was designed to be used alongside [yamllint](https://github.com/adrienverge/yamllint) to enforce specific YAML standards.
30
+
31
+ To see an example of Workflow Linter in practice in GitHub Action, see the [composite Action](https://github.com/bitwarden/gh-actions/tree/main/lint-workflow).
32
+
33
+ ## Prerequisites
34
+
35
+ - Python 3.12
36
+ - pipenv
37
+ - Windows systems: Chocolatey package manager
38
+ - Mac OS systems: Homebrew package manager
39
+ - pipx
40
+
41
+ ## Setup
42
+
43
+ 1. **Create the virtual environment:**
44
+ ```bash
45
+ python3.12 -m venv /Users/$USER/bitwarden_workflow_linter_venv
46
+ ```
47
+
48
+ 2. **Activate the virtual environment:**
49
+ ```bash
50
+ source /Users/$USER/bitwarden_workflow_linter_venv/bin/activate
51
+ ```
52
+
53
+ ## Installation
54
+
55
+ ### From PyPI
56
+ This is the recommended method for most users. Installing from PyPI ensures you get the latest stable release and is the easiest way to install and update the package.
57
+
58
+
59
+ 1. **Install Bitwarden Workflow Linter:**
60
+ ```bash
61
+ pip install --upgrade bitwarden_workflow_linter
62
+ ```
63
+
64
+ 2. **Deactivate the virtual environment (optional):**
65
+ ```bash
66
+ deactivate
67
+ ```
68
+ #### Using pipx
69
+
70
+ Alternatively, you can install `bwwl` globally using `pipx` to keep it isolated:
71
+
72
+ 1. **Install Bitwarden Workflow Linter:**
73
+ ```bash
74
+ pipx install bitwarden_workflow_linter --python python3.12
75
+ ```
76
+
77
+ This method is ideal for running `bwwl` as a standalone CLI tool without managing a virtual environment manually.
78
+
79
+ ### From GitHub Release
80
+ Use this method if you need a specific version of the package that is not yet available on PyPI, or if you want to access pre-release versions.
81
+
82
+ 1. **Download the release tarball or zip file from GitHub:**
83
+ ```bash
84
+ wget https://github.com/bitwarden/workflow-linter/archive/refs/tags/vX.Y.Z.tar.gz
85
+ tar -xzf vX.Y.Z.tar.gz
86
+ cd workflow-linter-X.Y.Z
87
+ ```
88
+
89
+ 2. **Install the package:**
90
+ ```bash
91
+ pip install .
92
+ ```
93
+
94
+ 3. **Deactivate the virtual environment (optional):**
95
+ ```bash
96
+ deactivate
97
+ ```
98
+
99
+ ### Locally
100
+ This method is useful for developers who want to contribute to the project or need to make local modifications to the source code. *Make sure to follow the virtual environment prerequisite setup*
101
+ 1. **Clone the repository:**
102
+ ```bash
103
+ git clone git@github.com:bitwarden/workflow-linter.git
104
+ cd workflow-linter
105
+ ```
106
+
107
+ 2. **Install the package:**
108
+ ```bash
109
+ pip install -e .
110
+ ```
111
+
112
+ 3. **Deactivate the virtual environment (optional):**
113
+ ```bash
114
+ deactivate
115
+ ```
116
+
117
+ ## Usage
118
+
119
+ ### Setup settings.yaml
120
+
121
+ If a non-default configuration is desired (different than `src/bitwarden_workflow_linter/default_settings.yaml`), copy the below and create a `settings.yaml` in the directory that `bwwl` will be running from.
122
+
123
+ ```yaml
124
+ enabled_rules:
125
+ - id: bitwarden_workflow_linter.rules.name_exists.RuleNameExists
126
+ level: error
127
+ - id: bitwarden_workflow_linter.rules.name_capitalized.RuleNameCapitalized
128
+ level: error
129
+ - id: bitwarden_workflow_linter.rules.pinned_job_runner.RuleJobRunnerVersionPinned
130
+ level: error
131
+ - id: bitwarden_workflow_linter.rules.job_environment_prefix.RuleJobEnvironmentPrefix
132
+ level: error
133
+ - id: bitwarden_workflow_linter.rules.step_pinned.RuleStepUsesPinned
134
+ level: error
135
+ - id: bitwarden_workflow_linter.rules.underscore_outputs.RuleUnderscoreOutputs
136
+ level: warning
137
+ - id: bitwarden_workflow_linter.rules.run_actionlint.RunActionlint
138
+ level: warning
139
+
140
+ approved_actions_path: default_actions.json
141
+ ```
142
+
143
+ ### Command Line Usage
144
+
145
+ ```bash
146
+ usage: bwwl [-h] [-v] {lint,actions} ...
147
+
148
+ positional arguments:
149
+ {lint,actions}
150
+ lint Verify that a GitHub Action Workflow follows all of the Rules.
151
+ actions Add or Update Actions in the pre-approved list.
152
+
153
+ options:
154
+ -h, --help show this help message and exit
155
+ -v, --verbose
156
+ ```
157
+ ## Pre-commit Hook Setup
158
+
159
+ ### Navigate to the `.git/hooks` directory in the repository you wish to lint:
160
+
161
+ ```bash
162
+ cd .git/hooks
163
+ ```
164
+
165
+ ### Create the `pre-commit` file (if it does not already exist):
166
+
167
+ ```bash
168
+ touch pre-commit
169
+ ```
170
+
171
+ ### Make the script executable:
172
+
173
+ ```bash
174
+ chmod +x pre-commit
175
+ ```
176
+
177
+ ### Edit the `pre-commit` script:
178
+
179
+ Open the `pre-commit` file with your favorite text editor and add the following content, replacing `/Users/$USER/bitwarden_workflow_linter_venv/bin/activate` with the actual path to your virtual environment:
180
+
181
+ ```bash
182
+ #!/bin/bash
183
+ set -e
184
+ # Activate the virtual environment
185
+ source "/Users/$USER/bitwarden_workflow_linter_venv/bin/activate"
186
+ # Get the repository root directory
187
+ repo_root=$(git rev-parse --show-toplevel)
188
+ # Run your Python script
189
+ bwwl lint -f "$repo_root/.github/workflows"
190
+ # Deactivate the virtual environment (optional)
191
+ deactivate
192
+ ```
193
+
194
+ ### Test the Hook:
195
+
196
+ Try committing a change to the repository. The pre-commit hook should run the workflow linter.
197
+
198
+ ## Development
199
+
200
+ ### Setup
201
+ Refer to the [Locally](#locally) instructions above to clone the repository and install the package.
202
+
203
+ ### Testing
204
+
205
+ All built-in `src/bitwarden_workflow_linter/rules` should have 100% code coverage and we should shoot for an overall coverage of 80%+. We are lax on the [imperative shell](https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell) (code interacting with other systems; ie. disk, network, etc), but we strive to maintain a high coverage over the functional core (objects and models).
206
+
207
+ ```bash
208
+ pipenv shell
209
+ pytest tests --cov=src
210
+ ```
211
+
212
+ ### Code Reformatting
213
+
214
+ We adhere to PEP8 and use `black` to maintain this adherence. `black` should be run on any change being merged to `main`.
215
+
216
+ ```bash
217
+ pipenv shell
218
+ black .
219
+ ```
220
+
221
+ ### Linting
222
+
223
+ We loosely use [Google's Python style guide](https://google.github.io/styleguide/pyguide.html), but yield to `black` when there is a conflict.
224
+
225
+ ```bash
226
+ pipenv shell
227
+ pylint --rcfile pylintrc src/ tests/
228
+ ```
229
+
230
+ ### Add a new Rule
231
+
232
+ A new Rule is created by extending the Rule base class and overriding the `fn(obj: Union[Workflow, Job, Step])` method. Available attributes of `Workflows`, `Jobs` and `Steps` can be found in their definitions under `src/models`.
233
+
234
+ For a simple example, we'll take a look at enforcing the existence of the `name` key in a Job. This is already done by default with the `src.rules.name_exists.RuleNameExists`, but provides a simple enough example to walk through.
235
+
236
+ ```python
237
+ from typing import Union, Tuple
238
+
239
+ from ..rule import Rule
240
+ from ..models.job import Job
241
+ from ..models.workflow import Workflow
242
+ from ..models.step import Step
243
+ from ..utils import LintLevels, Settings
244
+
245
+
246
+ class RuleJobNameExists(Rule):
247
+ def __init__(self, settings: Settings = None, lint_level: Optional[LintLevels] = LintLevels.ERROR) -> None:
248
+ self.message = "name must exist"
249
+ self.on_fail: LintLevels = lint_level
250
+ self.compatibility: List[Union[Workflow, Job, Step]] = [Job]
251
+ self.settings: Settings = settings
252
+
253
+ def fn(self, obj: Job) -> Tuple[bool, str]:
254
+ """<doc block goes here> """
255
+ if obj.name is not None:
256
+ return True, ""
257
+ return False, self.message
258
+ ```
259
+
260
+ By default, a new Rule needs five things:
261
+
262
+ - `self.message`: The message to return to the user on a lint failure
263
+ - `self.on_fail`: The level of failure on a lint failure (NONE, WARNING, ERROR). NONE and WARNING will exit with a code of 0 (unless using `strict` mode for WARNING). ERROR will exit with a non-zero exit code
264
+ - `self.compatibility`: The list of objects this rule is compatible with. This is used to create separate instances of the Rule for each object in the Rules collection.
265
+ - `self.settings`: In general, this should default to what is shown here, but allows for overrides
266
+ - `self.fn`: The function doing the actual work to check the object and enforce the standard.
267
+
268
+ `fn` can be as simple or as complex as it needs to be to run a check on a _single_ object. This linter currently does not support Rules that check against multiple objects at a time OR file level formatting (one empty between each step or two empty lines between each job).
269
+
270
+ _IMPORTANT: A rule must be implemented and tested then merged into `main` before it can be activated._ This is because the released version of `bwwl` will use the current `settings.yaml` file, but it will not have the new rule functionality yet and cause an error in the workflow linting of this repository.
271
+
272
+ To activate a rule after implementing and releasing it, add it to `settings.yaml` in the project's base folder and `src/bitwarden_workflow_linter/default_settings.yaml` to make the rule default.
273
+
274
+ Before creating a new rule please read the [Workflow linter rule rollout process](./RULE_ROLLOUT.md) document in which you'll find the process for rolling out new workflow linter rules.
@@ -1,8 +1,8 @@
1
- bitwarden_workflow_linter/__about__.py,sha256=ZkC-jyGFP28oUxaPSW3IgB35zbfGdOzVuDyIcWW5xuU,60
1
+ bitwarden_workflow_linter/__about__.py,sha256=D7QFlCK7qPdtHl_P2_TtGR0Mvkey1nGr65Qb1_EawFs,60
2
2
  bitwarden_workflow_linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  bitwarden_workflow_linter/actions.py,sha256=LAn3yQeMMmCOvJWeTn3dE1U2nyEJqIBMwESq3TtY9hE,9069
4
4
  bitwarden_workflow_linter/cli.py,sha256=wgkK1MlVbo6Zx3f2CZZ_tkSWq_hdsGciHJA1knX6Yuw,1699
5
- bitwarden_workflow_linter/default_actions.json,sha256=Xy-iHgIbWXVJRzSHf_WFpYQW6WSUbQvoZCHrPNKQfls,13068
5
+ bitwarden_workflow_linter/default_actions.json,sha256=gmjTUnLl1QpovMt5siNxP-qGkSNmXMSRvt4Ud1jne4c,13523
6
6
  bitwarden_workflow_linter/default_settings.yaml,sha256=XCaRFqdJ_lbNUDlPthySZzF0dGjnpW28iNSRQsJaJJE,1044
7
7
  bitwarden_workflow_linter/lint.py,sha256=R0dXkwir0KzXFHWfWlqpH_CyBwa7O8wHSBTy560u94g,6322
8
8
  bitwarden_workflow_linter/load.py,sha256=FWxotIlB0vyKzrVw87sOx3qdRiJG_0hVHRbbLXZY4Sc,5553
@@ -23,8 +23,8 @@ bitwarden_workflow_linter/rules/run_actionlint.py,sha256=K-RLQRXs591Ud_kiNQHhIJf
23
23
  bitwarden_workflow_linter/rules/step_approved.py,sha256=4pUCrOlWomo43bwGBunORphv1RJzc3spRKgZ4VLtDS0,3304
24
24
  bitwarden_workflow_linter/rules/step_pinned.py,sha256=MagV8LNdgRKyncmSdH9V-TlIcsdjzoDHDWqovzWon9E,3559
25
25
  bitwarden_workflow_linter/rules/underscore_outputs.py,sha256=LoCsDN_EfQ8H9n5BfZ5xCe7BeHqJGPMcV0vo1c9YJcw,4275
26
- bitwarden_workflow_linter-0.12.2.dist-info/METADATA,sha256=6LO1t5fe_hbvfcBI94Hgk1Xap9pyU2D27jjv6LQqQ3M,6956
27
- bitwarden_workflow_linter-0.12.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- bitwarden_workflow_linter-0.12.2.dist-info/entry_points.txt,sha256=SA_yF9CwL4VMUvdcmCd7k9rjsQNzfeOUBuDnMnaO8QQ,60
29
- bitwarden_workflow_linter-0.12.2.dist-info/licenses/LICENSE.txt,sha256=uY-7N9tbI7xc_c0WeTIGpacSCnsB91N05eCIg3bkaRw,35140
30
- bitwarden_workflow_linter-0.12.2.dist-info/RECORD,,
26
+ bitwarden_workflow_linter-0.12.4.dist-info/METADATA,sha256=EWiwAQy-MWJ3H0PWc3ret2N0KIZV61WCJwotxIy5glI,9797
27
+ bitwarden_workflow_linter-0.12.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ bitwarden_workflow_linter-0.12.4.dist-info/entry_points.txt,sha256=SA_yF9CwL4VMUvdcmCd7k9rjsQNzfeOUBuDnMnaO8QQ,60
29
+ bitwarden_workflow_linter-0.12.4.dist-info/licenses/LICENSE.txt,sha256=uY-7N9tbI7xc_c0WeTIGpacSCnsB91N05eCIg3bkaRw,35140
30
+ bitwarden_workflow_linter-0.12.4.dist-info/RECORD,,
@@ -1,200 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: bitwarden_workflow_linter
3
- Version: 0.12.2
4
- Summary: Custom GitHub Action Workflow Linter
5
- Project-URL: Homepage, https://github.com/bitwarden/workflow-linter
6
- Project-URL: Issues, https://github.com/bitwarden/workflow-linter/issues
7
- License-File: LICENSE.txt
8
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
9
- Classifier: Operating System :: OS Independent
10
- Classifier: Programming Language :: Python :: 3
11
- Requires-Python: >=3.11
12
- Requires-Dist: annotated-types==0.7.0
13
- Requires-Dist: dataclasses-json==0.6.6
14
- Requires-Dist: marshmallow==3.21.2
15
- Requires-Dist: mypy-extensions==1.0.0
16
- Requires-Dist: packaging==24.0
17
- Requires-Dist: pydantic-core==2.18.3
18
- Requires-Dist: pydantic==2.7.2
19
- Requires-Dist: pyyaml==6.0.1
20
- Requires-Dist: ruamel-yaml-clib==0.2.8
21
- Requires-Dist: ruamel-yaml==0.18.6
22
- Requires-Dist: typing-extensions==4.12.0
23
- Requires-Dist: typing-inspect==0.9.0
24
- Requires-Dist: urllib3==2.2.1
25
- Description-Content-Type: text/markdown
26
-
27
- # Bitwarden Workflow Linter
28
-
29
- Bitwarden's Workflow Linter is an extensible linter to apply opinionated organization-specific
30
- GitHub Action standards. It was designed to be used alongside
31
- [yamllint](https://github.com/adrienverge/yamllint) to enforce
32
- specific YAML standards.
33
-
34
- To see an example of Workflow Linter in practice in GitHub Action, see the
35
- [composite Action](https://github.com/bitwarden/gh-actions/tree/main/lint-workflow).
36
-
37
- ## Installation
38
-
39
- ## From GitHub Release
40
-
41
- ```
42
- Not yet implemented
43
- ```
44
-
45
- ### Locally
46
-
47
- ```
48
- git clone git@github.com:bitwarden/workflow-linter.git
49
- cd workflow-linter
50
-
51
- pip install -e .
52
- ```
53
-
54
- ## Usage
55
-
56
- ### Setup settings.yaml
57
-
58
- If a non-default configuration is desired (different than `src/bitwarden_workflow_linter/default_settings.yaml`), copy
59
- the below and create a `settings.yaml` in the directory that `bwwl` will be running from.
60
-
61
- ```yaml
62
- enabled_rules:
63
- - id: bitwarden_workflow_linter.rules.name_exists.RuleNameExists
64
- level: error
65
- - id: bitwarden_workflow_linter.rules.name_capitalized.RuleNameCapitalized
66
- level: error
67
- - id: bitwarden_workflow_linter.rules.pinned_job_runner.RuleJobRunnerVersionPinned
68
- level: error
69
- - id: bitwarden_workflow_linter.rules.job_environment_prefix.RuleJobEnvironmentPrefix
70
- level: error
71
- - id: bitwarden_workflow_linter.rules.step_pinned.RuleStepUsesPinned
72
- level: error
73
- - id: bitwarden_workflow_linter.rules.underscore_outputs.RuleUnderscoreOutputs
74
- level: warning
75
- - id: bitwarden_workflow_linter.rules.run_actionlint.RunActionlint
76
- level: warning
77
-
78
- approved_actions_path: default_actions.json
79
- ```
80
-
81
- ```
82
- usage: bwwl [-h] [-v] {lint,actions} ...
83
-
84
- positional arguments:
85
- {lint,actions}
86
- lint Verify that a GitHub Action Workflow follows all of the Rules.
87
- actions Add or Update Actions in the pre-approved list.
88
-
89
- options:
90
- -h, --help show this help message and exit
91
- -v, --verbose
92
- ```
93
-
94
- ## Development
95
-
96
- ### Requirements
97
-
98
- - Python 3.11
99
- - pipenv
100
- - Windows systems: Chocolatey package manager
101
- - Mac OS systems: Homebrew package manager
102
-
103
- ### Setup
104
-
105
- ```
106
- pipenv install --dev
107
- pipenv shell
108
- ```
109
-
110
- ### Testing
111
-
112
- All built-in `src/bitwarden_workflow_linter/rules` should have 100% code coverage and we should shoot for an overall coverage of 80%+.
113
- We are lax on the
114
- [imperative shell](https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell)
115
- (code interacting with other systems; ie. disk, network, etc), but we strive to maintain a high coverage over the
116
- functional core (objects and models).
117
-
118
- ```
119
- pipenv shell
120
- pytest tests --cov=src
121
- ```
122
-
123
- ### Code Reformatting
124
-
125
- We adhere to PEP8 and use `black` to maintain this adherence. `black` should be run on any change being merged
126
- to `main`.
127
-
128
- ```
129
- pipenv shell
130
- black .
131
- ```
132
-
133
- ### Linting
134
-
135
- We loosely use [Google's Python style guide](https://google.github.io/styleguide/pyguide.html), but yield to
136
- `black` when there is a conflict
137
-
138
- ```
139
- pipenv shell
140
- pylint --rcfile pylintrc src/ tests/
141
- ```
142
-
143
- ### Add a new Rule
144
-
145
- A new Rule is created by extending the Rule base class and overriding the `fn(obj: Union[Workflow, Job, Step])` method.
146
- Available attributes of `Workflows`, `Jobs` and `Steps` can be found in their definitons under `src/models`.
147
-
148
- For a simple example, we'll take a look at enforcing the existence of the `name` key in a Job. This is already done by
149
- default with the src.rules.name_exists.RuleNameExists, but provides a simple enough example to walk through.
150
-
151
- ```python
152
- from typing import Union, Tuple
153
-
154
- from ..rule import Rule
155
- from ..models.job import Job
156
- from ..models.workflow import Workflow
157
- from ..models.step import Step
158
- from ..utils import LintLevels, Settings
159
-
160
-
161
- class RuleJobNameExists(Rule):
162
- def __init__(self, settings: Settings = None, lint_level: Optional[LintLevels] = LintLevels.ERROR) -> None:
163
- self.message = "name must exist"
164
- self.on_fail: LintLevels = lint_level
165
- self.compatibility: List[Union[Workflow, Job, Step]] = [Job]
166
- self.settings: Settings = settings
167
-
168
- def fn(self, obj: Job) -> Tuple[bool, str]:
169
- """<doc block goes here> """
170
- if obj.name is not None:
171
- return True, ""
172
- return False, self.message
173
- ```
174
-
175
- By default, a new Rule needs five things:
176
-
177
- - `self.message`: The message to return to the user on a lint failure
178
- - `self.on_fail`: The level of failure on a lint failure (NONE, WARNING, ERROR).
179
- NONE and WARNING will exit with a code of 0 (unless using `strict` mode for WARNING).
180
- ERROR will exit with a non-zero exit code
181
- - `self.compatibility`: The list of objects this rule is compatible with. This is used to create separate instances of
182
- the Rule for each object in the Rules collection.
183
- - `self.settings`: In general, this should default to what is shown here, but allows for overrides
184
- - `self.fn`: The function doing the actual work to check the object and enforce the standard.
185
-
186
- `fn` can be as simple or as complex as it needs to be to run a check on a _single_ object. This linter currently does
187
- not support Rules that check against multiple objects at a time OR file level formatting (one empty between each step or
188
- two empty lines between each job)
189
-
190
- _IMPORTANT: A rule must be implemented and tested then merged into `main` before it can be activated.<br>_
191
- This is because the released version of bwwl will use the current `settings.yaml` file, but it will not have the new rule functionality yet and cause an error in the workflow linting of this repository.
192
-
193
- To activate a rule after implementing and releasing it, add it to `settings.yaml` in the project's base folder
194
- and `src/bitwarden_workflow_linter/default_settings.yaml` to make the rule default
195
-
196
- Before creating a new rule please read the [Workflow linter rule rollout process](./RULE_ROLLOUT.md) document in which you'll find the process for rolling out new workflow linter rules.
197
-
198
- ### To-Do
199
-
200
- - [ ] Add Rule to assert correct format for single line run