Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for readmes #7088

Merged
merged 22 commits into from
Jul 24, 2020
Merged

Add validation for readmes #7088

merged 22 commits into from
Jul 24, 2020

Conversation

sarah-witt
Copy link
Contributor

What does this PR do?

Adds validation for images in READMEs.

Motivation

Additional Notes

TODO: update developer docs

depends on:

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@sarah-witt sarah-witt marked this pull request as ready for review July 8, 2020 19:49
@sarah-witt sarah-witt requested a review from a team as a code owner July 8, 2020 19:49
Copy link
Contributor

@ChristineTChen ChristineTChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome!! Could we also add validation that the Overview and Setup headers must be there since those are used for tiles tabs?

@sarah-witt sarah-witt requested a review from ChristineTChen July 9, 2020 17:52
Comment on lines 64 to 70
if not has_overview and integration not in NON_TILE_INTEGRATIONS:
errors = True
echo_failure(f"{integration} readme file does not have an overview section")

if not has_setup and integration not in NON_TILE_INTEGRATIONS:
errors = True
echo_failure(f"{integration} readme file does not have a setup section")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not has_overview and integration not in NON_TILE_INTEGRATIONS:
errors = True
echo_failure(f"{integration} readme file does not have an overview section")
if not has_setup and integration not in NON_TILE_INTEGRATIONS:
errors = True
echo_failure(f"{integration} readme file does not have a setup section")
if integration not in NON_TILE_INTEGRATIONS and not has_overview or not has_setup:
errors = True
echo_failure(f"{integration} readme file needs to have an overview and setup section.")

Since these two are same issue (README section headers), I think we could simplify the error. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I could do that

Copy link
Member

@AlexandreYang AlexandreYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🥇

ChristineTChen
ChristineTChen previously approved these changes Jul 13, 2020
Copy link
Contributor

@ChristineTChen ChristineTChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sarah-witt sarah-witt requested a review from AlexandreYang July 15, 2020 13:07
…e/readmes.py

Co-authored-by: Nicholas Muesch <nicholas.muesch@datadoghq.com>
nmuesch
nmuesch previously approved these changes Jul 22, 2020
Copy link
Collaborator

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks!

f"https://raw.githubusercontent.com/DataDog/{repo}/master/{integration}/images/<IMAGE_NAME>"
)

rel_path = match.groups()[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think need to abort above or put this in an else, otherwise we never see the failure message above if match doesn't exist.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: sorry you do see the error message above, but it gets drowned out a bit by a stacktrace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I updated to break if there's a failure!

AlexandreYang
AlexandreYang previously approved these changes Jul 24, 2020
ChristineTChen
ChristineTChen previously approved these changes Jul 24, 2020
nmuesch
nmuesch previously approved these changes Jul 24, 2020
Copy link
Collaborator

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for this! I left one note about the formatting of the output but I don't think it needs to block.

match = re.match(IMAGE_REGEX, line)
if not match:
errors = True
echo_failure(f"{integration} readme file does not have a valid image file on line {line_no}")
Copy link
Collaborator

@nmuesch nmuesch Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I noticed is that the other validations print the integration name once when there is an error, then print each error message on a newline with a slight indent, to group errors per integration
Example in the manifest validations - https://github.com/DataDog/integrations-core/blob/master/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/manifest.py#L289-L301

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that format! I updated the PR

@sarah-witt sarah-witt dismissed stale reviews from nmuesch and ChristineTChen via 127556e July 24, 2020 14:15
Copy link
Collaborator

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

@sarah-witt sarah-witt merged commit e220790 into master Jul 24, 2020
@sarah-witt sarah-witt deleted the sarah/readme-validation branch July 24, 2020 18:38
github-actions bot pushed a commit that referenced this pull request Jul 24, 2020
* Add utility functions

* Add readme validation

* Move function

* Add to CI

* Go back to original comment

* Simplify logic

* Check for overview and setup

* Fix style

* Simplify error

* Test for exact wording

* Fix style

* Check that path exists

* Update extensions

* Remove test for non tile ints

* Update datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/readmes.py

Co-authored-by: Nicholas Muesch <nicholas.muesch@datadoghq.com>

* Break if readme is invalid

* Fix style

* Fix style

* Update to have display queue

* Add noqa

Co-authored-by: Nicholas Muesch <nicholas.muesch@datadoghq.com> e220790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants