Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-flinn committed Jan 12, 2024
1 parent 8ca7b95 commit 5e4c980
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 7 deletions.
8 changes: 3 additions & 5 deletions lint-workflow/src/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def extend_parser(subparsers: argparse.ArgumentParser) -> argparse.ArgumentParse
subparsers_actions = parser_actions.add_subparsers(
required=True, dest="actions_command"
)
subparsers_actions.add_parser(
"update", help="update action versions"
)
subparsers_actions.add_parser("update", help="update action versions")
parser_actions_add = subparsers_actions.add_parser(
"add", help="add action to approved list"
)
Expand All @@ -80,15 +78,15 @@ def get_github_api_response(
if response.status == 403 and response.reason == "rate limit exceeded":
logging.error(
"Failed to call GitHub API for action: %s due to rate limit exceeded.",
action_name
action_name,
)
return None

if response.status == 401 and response.reason == "Unauthorized":
logging.error(
"Failed to call GitHub API for action: %s: %s.",
action_name,
response.data
response.data,
)
return None

Expand Down
3 changes: 2 additions & 1 deletion lint-workflow/src/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class LinterCmd:
Supporting logic is supplied to:
- build out the list of Rules desired
- select and validate the workflow files to lint
"""
"""

def __init__(self, settings: Settings = None) -> None:
"""Initailized the LinterCmd class.
Expand Down
3 changes: 2 additions & 1 deletion lint-workflow/src/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ class Rules:
workflow. It also assists in making sure the Rules that apply to multiple
types are not skipped.
"""

workflow: List[Rule] = []
job: List[Rule] = []
step: List[Rule] = []

def __init__(self, settings: Settings) -> None:
"""Initializes the Rules
"""Initializes the Rules
Args:
settings:
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/models/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Job:
Rules against. If a new Rule requies a key that is missing, the attribute should
be added to this class to make it available for use in linting.
"""

runs_on: str = field(metadata=config(field_name="runs-on"))
key: Optional[str] = None
name: Optional[str] = None
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/models/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Step:
Rules against. If a new Rule requies a key that is missing, the attribute should
be added to this class to make it available for use in linting.
"""

key: Optional[int] = None
job: Optional[str] = None
name: Optional[str] = None
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Workflow:
See src/models/job.py for an example if the key in the workflow data does not map
one-to-one in the model (ex. 'with' => 'uses_with')
"""

key: str = ""
name: Optional[str] = None
on: Optional[CommentedMap] = None
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class RuleExecutionException(Exception):
"""Exeception for the Base Rule class."""

pass


Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rules/job_environment_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class RuleJobEnvironmentPrefix(Rule):
variables are normally at the top of the file and Step level ones are pretty
visible when debugging a shell Step.
"""

def __init__(self, settings: Settings = None) -> None:
"""RuleJobEnvironmentPrefix constructor to override the Rule class.
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rules/name_capitalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class RuleNameCapitalized(Rule):
A simple standard to help keep uniformity in naming.
"""

def __init__(self, settings: Settings = None) -> None:
"""Contructor for RuleNameCapitalized to override the Rule class.
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rules/name_exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class RuleNameExists(Rule):
It also helps with uniformity of runs.
"""

def __init__(self, settings: Settings = None) -> None:
"""Contructor for RuleNameCapitalized to override Rule class.
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rules/pinned_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RuleJobRunnerVersionPinned(Rule):
in the past. To avoid this and prevent a single event from breaking the majority of
our pipelines, we pin the versions.
"""

def __init__(self, settings: Settings = None) -> None:
"""Constructor for RuleJobRunnerVersionPinned to override Rule class.
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rules/step_approved.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RuleStepUsesApproved(Rule):
are required to pass a security review and be added to the pre-approved list to
check against.
"""

def __init__(self, settings: Settings = None) -> None:
"""Constructor for RuleStepUsesApproved to override Rule class.
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/rules/step_pinned.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RuleStepUsesPinned(Rule):
spamming a bunch of PRs across all of our repos when `bitwarden/gh-actions` is
updated.
"""

def __init__(self, settings: Settings = None) -> None:
"""Constructor for RuleStepUsesPinned to override base Rule.
Expand Down
1 change: 1 addition & 0 deletions lint-workflow/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class SettingsError(Exception):

class Settings:
"""Class that contains configuration-as-code for any portion of the app."""

enabled_rules: list[str]
approved_actions: dict[str, Action]

Expand Down

0 comments on commit 5e4c980

Please sign in to comment.