-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Verify package data in setup.py installs all files #59537
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test needs to be added to https://github.com/ansible/ansible/blob/devel/test/sanity/code-smell/ansible-only.txt since it should not be run on collections.
Also, I don't particularly like having an always running sanity test that runs for 10+ seconds, since it will more than double the time it takes to run sanity tests on a single file.
One option would be to parse package_data
from setup.py
and check that, rather than performing an actual install. It would be very fast, and nearly as good as performing an actual install. That may be good enough, unless you're aware of scenarios where that is likely to miss something.
for root, dirs, files in os.walk('lib/ansible/'): | ||
for filename in files: | ||
path = os.path.join(root, filename) | ||
if os.path.splitext(path)[-1] not in ('.py', '.pyc', '.pyo'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if os.path.splitext(path)[-1] not in ('.py', '.pyc', '.pyo'): | |
if os.path.splitext(path)[1] not in ('.py', '.pyc', '.pyo'): |
if fnmatch.fnmatch(path, ignore): | ||
add = False | ||
if add: | ||
non_py_files.append(path[12:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer using os.path
functions for path manipulation instead of string slicing.
for filename in non_py_files: | ||
path = os.path.join(match.group(1), filename) | ||
if not os.path.exists(path): | ||
print('lib/ansible/%s: File not installed' % filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer os.path.join
here.
It's not a big issue though -- we certainly have plenty of other places where string concatenation is done.
@sivel I discussed this with @nitzmahone and he pointed out that if entries are not correct in To avoid unnecessary overhead, lets treat this like we do the
Then enabled in CI here: ansible/test/utils/shippable/sanity.sh Line 20 in 97edfcc
|
SUMMARY
Verify package data in setup.py installs all files
We recently added a new data file and it was not matched by
package_data
and thus not installed: #59452This test will help ensure new data files are properly installed, as we have missed several in the past.
ISSUE TYPE
COMPONENT NAME
test/sanity/code-smell/package-data.py
ADDITIONAL INFORMATION
before the change to setup.py: