Skip to content
This repository was archived by the owner on Aug 25, 2026. It is now read-only.

feat: Introduce proper py_library and py_test support in bazel rules - #1360

Merged
vam-google merged 2 commits into
googleapis:mainfrom
vam-google:master
Jul 20, 2022
Merged

vam-google merged 2 commits into
googleapis:mainfrom
vam-google:master

Conversation

@vam-google

@vam-google vam-google commented Jul 20, 2022 •

Copy link
Copy Markdown
Contributor

These changes allow running the generated python gapic unit tests on the fly by bazel right after generation in our CI.

As a result of this change some of the issues with the generated code became immediatelly visible (because now we ran the generated tests) and will be addressed separately in these issues:

#1358
#1359

The tests can be now added in BUILD.bazel files as follows:

py_test(
    name = "credentials_py_gapic_test",
    srcs = [
        "credentials_py_gapic_pytest.py",
        "credentials_py_gapic_test.py",
    ],
    legacy_create_init = False,
    deps = [
        ":credentials_py_gapic",
    ],
)

These changes allow running the generated python gapic unit tests on the fly by bazel right after generation in our CI.

As a result of this change some of the issues with the generated code became immediatelly visible (because now we ran the generated tests) and will be addressed separately in these issues:

googleapis#1358
googleapis#1359
@vam-google
vam-google requested review from a team July 20, 2022 01:48
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Jul 20, 2022
@vam-google
vam-google requested review from atulep and parthea July 20, 2022 01:48

@parthea parthea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added minor observations, otherwise LGTM

],
)

py_test(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we add a placeholder for asset as well?

# uncomment once...
#py_test(
#    name = "asset_py_gapic_test",
#    srcs = [
#        "asset_py_gapic_pytest.py",
#        "asset_py_gapic_test.py",
#    ],
#    legacy_create_init = False,
#    deps = [
#        ":asset_py_gapic",
#    ],
#)

@vam-google vam-google Jul 20, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably. Asset has other issues though (not that much about generator but about the wierdeness of the API itself, as it depends on many other APIs). I'll add it when fix the dependencies porition in googleapis itself (need to have explicit py_proto targets form ohter apis to specify as dependencies for asset)


if __name__ == '__main__':
sys.exit(pytest.main([
'--disable-pytest-warnings',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we keep warnings?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It emits a lot of garbage warnings, contaminating the output and those warnings seem to be more related to the execution environment instead of the tests themselves, so I decided to turn them off. It won't affect execution much, but it will make our log even longer (the current full build log accross whole googleapis is multple megabytes already)

@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 20, 2022
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 20, 2022
@vam-google
vam-google merged commit d6fa6c7 into googleapis:main Jul 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants