Skip to content

Commit

Permalink
Allow the codeowners validation in integrations-core
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentClarret committed Mar 15, 2024
1 parent 4771758 commit 0c8860e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
# Validations
agent-reqs: true
ci: true
codeowners: true
config: true
dashboards: true
dep: true
Expand Down
1 change: 1 addition & 0 deletions datadog_checks_dev/changelog.d/17199.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow the codeowners validation in integrations-core
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,34 @@ def create_codeowners_map():
@click.command(
context_settings=CONTEXT_SETTINGS, short_help='Validate `CODEOWNERS` file has an entry for each integration'
)
def codeowners():
@click.pass_context
def codeowners(ctx):
"""Validate that every integration has an entry in the `CODEOWNERS` file."""

has_failed = False
codeowner_map = create_codeowners_map()
codeowners_file = get_codeowners_file()
for integration, codeowner in codeowner_map.items():
if not codeowner:
has_failed = True
message = f"Integration {integration} does not have a valid `CODEOWNERS` entry."
echo_failure(message)
annotate_error(codeowners_file, message)
elif codeowner == "empty":
has_failed = True
message = f"Integration {integration} has a `CODEOWNERS` entry, but the codeowner is empty."
echo_failure(message)
annotate_error(codeowners_file, message)
elif not codeowner.startswith("@") and integration not in IGNORE_TILES:
has_failed = True
message = (
f"Integration {integration} has a `CODEOWNERS` entry, but the codeowner is not a username or team."
)
echo_failure(message)
annotate_error(codeowners_file, message)
is_core_check = ctx.obj['repo_choice'] == 'core'

if not is_core_check: # We do not need this rule in integrations-core
codeowner_map = create_codeowners_map()
codeowners_file = get_codeowners_file()
for integration, codeowner in codeowner_map.items():
if not codeowner:
has_failed = True
message = f"Integration {integration} does not have a valid `CODEOWNERS` entry."
echo_failure(message)
annotate_error(codeowners_file, message)
elif codeowner == "empty":
has_failed = True
message = f"Integration {integration} has a `CODEOWNERS` entry, but the codeowner is empty."
echo_failure(message)
annotate_error(codeowners_file, message)
elif not codeowner.startswith("@") and integration not in IGNORE_TILES:
has_failed = True
message = (
f"Integration {integration} has a `CODEOWNERS` entry, but the codeowner is not a username or team."
)
echo_failure(message)
annotate_error(codeowners_file, message)

if not has_failed:
echo_success("All integrations have valid codeowners.")
Expand Down

0 comments on commit 0c8860e

Please sign in to comment.