Skip to content

Commit

Permalink
feat!: rename repo checks to be more concise & consitent
Browse files Browse the repository at this point in the history
No need to prefix them with "Ensure", when they are all ensuring
something.

This will make it easier to read the list of required of checks in the
--help text. It will also make it easier to type out which checks to
run.
  • Loading branch information
kdmccormick committed Aug 7, 2024
1 parent 165e7d6 commit 17c885a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions edx_repo_tools/repo_checks/repo_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def dry_run(self):


@Check.register
class EnsureRepoSettings(Check):
class Settings(Check):
"""
There are certain settings that we agree we want to be set a specific way on all repos. This check
will ensure that those settings are set correctly on all non-security repos.
Expand Down Expand Up @@ -257,7 +257,7 @@ def fix(self, dry_run=False):


@Check.register
class EnsureNoAdminOrMaintainTeams(Check):
class NoAdminOrMaintainTeams(Check):
"""
Teams should not be granted `admin` or `maintain` access to a repository unless the access
is exceptional and it is noted here. All other `admin` and `maintain` access is downgraded to
Expand Down Expand Up @@ -327,7 +327,7 @@ def fix(self, dry_run=False):


@Check.register
class EnsureWorkflowTemplates(Check):
class Workflows(Check):
"""
There are certain github action workflows that we to exist on all
repos exactly as they are defined in the `.github` repo in the org.
Expand Down Expand Up @@ -613,7 +613,7 @@ def fix(self, dry_run=False):


@Check.register
class EnsureLabels(Check):
class Labels(Check):
"""
All repos in the org should have certain labels.
"""
Expand Down Expand Up @@ -728,12 +728,12 @@ def _simplify_label(self, label: str):
return simplified_label


class RequireTeamPermission(Check):
class TeamAccess(Check):
"""
Require that a team has a certain level of access to a repository.
To use this class as a check, create a subclass that specifies a particular
team and permission level, such as RequireTriageTeamAccess below.
team and permission level, such as TriageTeam below.
"""

def __init__(self, api: GhApi, org: str, repo: str, team: str, permission: str):
Expand Down Expand Up @@ -802,7 +802,7 @@ def fix(self, dry_run=False):


@Check.register
class RequireTriageTeamAccess(RequireTeamPermission):
class TriageTeam(TeamAccess):
"""
Ensure that the openedx-triage team grants Triage access to every public repo in the org.
"""
Expand All @@ -818,7 +818,7 @@ def is_relevant(self):


@Check.register
class RequiredCLACheck(Check):
class EnforceCLA(Check):
"""
This class validates the following:
Expand All @@ -838,7 +838,7 @@ def __init__(self, api, org, repo):
self.cla_team = "cla-checker"
self.cla_team_permission = "push"

self.team_check = RequireTeamPermission(
self.team_check = TeamAccess(
api,
org,
repo,
Expand Down Expand Up @@ -1079,7 +1079,7 @@ def _get_update_params_from_get_branch_protection(self):


@Check.register
class EnsureNoDirectRepoAccessToUsers(Check):
class NoDirectUsers(Check):
"""
Users should not have direct repo access
"""
Expand Down
12 changes: 6 additions & 6 deletions tests/test_repo_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from edx_repo_tools.repo_checks.repo_checks import EnsureLabels
from edx_repo_tools.repo_checks import repo_checks


@pytest.fixture
Expand Down Expand Up @@ -35,20 +35,20 @@ def maintenance_label():
]


@patch.object(EnsureLabels, "labels", labels_yaml)
class TestEnsureLabels:
@patch.object(repo_checks.Labels, "labels", labels_yaml)
class TestLabelsCheck:
def test_check_for_no_change(self, maintenance_label):
api = MagicMock()
api.issues.list_labels_for_repo.side_effect = [[maintenance_label], None]
check_cls = EnsureLabels(api, "test_org", "test_repo")
check_cls = repo_checks.Labels(api, "test_org", "test_repo")

# Make sure that the check returns True, indicating that no changes need to be made.
assert check_cls.check()[0]

def test_addition(self, maintenance_label):
api = MagicMock()
api.issues.list_labels_for_repo.return_value = []
check_cls = EnsureLabels(api, "test_org", "test_repo")
check_cls = repo_checks.Labels(api, "test_org", "test_repo")

# The check should be false because the maintenance label should be missing.
assert check_cls.check()[0] == False
Expand All @@ -72,7 +72,7 @@ def test_update_label(self, maintenance_label):
api = MagicMock()
api.issues.list_labels_for_repo.side_effect = [[maintenance_label], None]

check_cls = EnsureLabels(api, "test_org", "test_repo")
check_cls = repo_checks.Labels(api, "test_org", "test_repo")

assert check_cls.check()[0] == False
check_cls.fix()
Expand Down

0 comments on commit 17c885a

Please sign in to comment.