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 test for package readme syntax errors #492

Merged
merged 12 commits into from
Mar 28, 2020
Merged

Add test for package readme syntax errors #492

merged 12 commits into from
Mar 28, 2020

Conversation

ffe4
Copy link
Contributor

@ffe4 ffe4 commented Mar 16, 2020

See #445

I’ve gone ahead and wrote a simple test script that assumes a README.rst is and should be present. Not sure what output and exit behavior would be desirable in that case. I exit normally and print a warning if the README.rst is missing. sys.exit(1) if there is a syntax error. Example output of is below.

There is apparently already an error in one of the readme files which I'll look at tomorrow (fixed in 9ddbfd8). Would something like this be sufficient?

python scripts/eachdist.py lint
>>> python tests/check_for_valid_readme.py opentelemetry-api opentelemetry-sdk ext/opentelemetry-ext-wsgi ext/opentelemetry-ext-opentracing-shim ext/opentelemetry-ext-jaeger ext/opentelemetry-ext-otcollector ext/opentelemetry-ext-http-requests ext/opentelemetry-ext-flask ext/opentelemetry-ext-pymongo ext/opentelemetry-ext-psycopg2 ext/opentelemetry-ext-testutil ext/opentelemetry-ext-dbapi ext/opentelemetry-ext-prometheus ext/opentelemetry-ext-mysql ext/opentelemetry-ext-zipkin docs/examples/opentelemetry-example-app
✗ RST syntax errors in ext/opentelemetry-ext-otcollector/README.rst
✗ No README.rst in ext/opentelemetry-ext-testutil
'python tests/check_for_valid_readme.py opentelemetry-api opentelemetry-sdk ext/opentelemetry-ext-wsgi ext/opentelemetry-ext-opentracing-shim ext/opentelemetry-ext-jaeger ext/opentelemetry-ext-otcollector ext/opentelemetry-ext-http-requests ext/opentelemetry-ext-flask ext/opentelemetry-ext-pymongo ext/opentelemetry-ext-psycopg2 ext/opentelemetry-ext-testutil ext/opentelemetry-ext-dbapi ext/opentelemetry-ext-prometheus ext/opentelemetry-ext-mysql ext/opentelemetry-ext-zipkin docs/examples/opentelemetry-example-app' failed with code 1

Fixes invalid references in README and fixes errors in 26bddb7
@ffe4 ffe4 marked this pull request as ready for review March 16, 2020 09:57
@ffe4 ffe4 requested a review from a team March 16, 2020 09:57
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this, just a non-blocking question.

if all_readmes_found:
print("All clear.")
else:
print("No errors found but not all packages have a README.rst")
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to treat this as an error and exit as above? I would assume we'd want a README.rst for all packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The package does not technically need to have a README.rst. The file could be named differently, it could be an markdown or plain text file, or the description could be embedded inline, instead of in a separate file. testutil does not have a README and seems to be marked for deletion (#374 5.), so I felt this behavior might be desirable.

If someone adds a README.rst it will get checked, and if they do not include a README.rst we just assume that the package is still WIP and/or will not be uploaded to PyPI. If there is another README file the warning basically indicates departure from implicit convention.

Copy link
Member

Choose a reason for hiding this comment

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

We can just force everyone to put the readme in README.rst. If we want to allow README.md, then this tool will need to support it too.

If we want to exclude packages, I think we can add the exclusion list to eachdist.ini (but I'm not sure if it has support for configured exclusions yet).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exclusions do not seem to be supported, so I added a README to the testutil package for now.

dev-requirements.txt Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Mar 25, 2020

Codecov Report

Merging #492 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #492   +/-   ##
=======================================
  Coverage   89.47%   89.47%           
=======================================
  Files          43       43           
  Lines        2195     2195           
  Branches      247      247           
=======================================
  Hits         1964     1964           
  Misses        159      159           
  Partials       72       72           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 046057d...2be6971. Read the comment docs.

@ffe4 ffe4 requested a review from Oberon00 March 25, 2020 09:36
tests/check_for_valid_readme.py Outdated Show resolved Hide resolved
tests/check_for_valid_readme.py Outdated Show resolved Hide resolved
tests/check_for_valid_readme.py Outdated Show resolved Hide resolved

for path in [Path(path) for path in args.paths]:
readme = path / "README.rst"
if not readme.exists():
Copy link
Member

Choose a reason for hiding this comment

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

I would move this check under the if not is_valid_rst (or in a try/except around it). We should first try to parse the readme, and if parsing failed we check to see if a nonexistent file was the reason.

if all_readmes_found:
print("All clear.")
else:
print("No errors found but not all packages have a README.rst")
Copy link
Member

Choose a reason for hiding this comment

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

We can just force everyone to put the readme in README.rst. If we want to allow README.md, then this tool will need to support it too.

If we want to exclude packages, I think we can add the exclusion list to eachdist.ini (but I'm not sure if it has support for configured exclusions yet).

Commit via GitHub web interface.

Co-Authored-By: Christian Neumüller <[email protected]>
@codeboten codeboten requested a review from Oberon00 March 26, 2020 15:22
tests/check_for_valid_readme.py Outdated Show resolved Hide resolved
Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

@ffe4 thanks for the change! And it looks good. Only change is to move the script itself to ./scripts, to follow the standard convention of all of our helper scripts.

@ffe4 ffe4 requested a review from toumorokoshi March 26, 2020 17:04
Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

Great! Thanks for making that change.

@toumorokoshi toumorokoshi merged commit 5fbf999 into open-telemetry:master Mar 28, 2020
@ffe4 ffe4 deleted the add-test-for-package-readme branch March 28, 2020 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants