Add build-tests and create-samples subcommands to azpysdk CLI#45825
Add build-tests and create-samples subcommands to azpysdk CLI#45825
build-tests and create-samples subcommands to azpysdk CLI#45825Conversation
Co-authored-by: l0lawrence <100643745+l0lawrence@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/6c11cb61-4032-4ed0-9cef-91775d2e9434
build-tests and create-samples subcommands to azpysdk CLI
|
@copilot i wanted skills on building tests and samples no scripts |
Both azpysdk build-tests <target>
azpysdk create-samples <target> |
|
@copilot I want gh copilot skills |
Could you clarify what you mean by "gh copilot skills"? The current implementation adds |
Adds two new skills to the
azpysdkCLI ineng/tools/azure-sdk-tools/azpysdk/.build-tests(azpysdk/build_tests.py)Subclasses
InstallAndTestwithcoverage_enabled=False. Overridesrun()to execute onlyinstall_all_requirements()— installs packaging tools,eng/test_tools.txt, dev requirements, and builds/installs the package as a wheel — without invoking pytest or coverage. Useful for isolating build/dependency failures from test failures in CI.create-samples(azpysdk/create_samples.py)Subclasses
Check. For each targeted package, creates asamples/directory scaffold (README.md+sample_hello_world.py) if the files don't already exist (idempotent). Accepts an optional--output-dirto override the default<package_dir>/sampleslocation. Both the help text and generated README point users toazpysdk generate <target>for full SDK codegen from TypeSpec/Swagger.main.pyBoth skills imported and registered —
build_testsnearwhl,create_samplesnearsamples.Tests (
tests/test_build_interactions.py)Implements the three existing stubs with minimal smoke-test assertions and adds five new tests covering: subcommand registration, no-op on empty target list, scaffold creation, and file-skipping idempotency.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
pypi.org/home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/lib/python3.9/site-packages/pip/__pip-REDACTED__.py install --ignore-installed --no-user --prefix /tmp/pip-build-env-0m98n3_w/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i REDACTED -- setuptools>=42 wheel(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Overview
Add two new skills (subcommands) to the
azpysdkCLI ineng/tools/azure-sdk-tools/azpysdk/:build_tests— A newChecksubclass that builds the test environment for a targeted package (installs packaging tools, test tools, dev requirements, and builds/installs the package as a wheel) without running pytest or coverage. Useful for pre-validating the test environment in isolation.create_samples— A newChecksubclass that generates a starter samples scaffold for a targeted package and mentions theazpysdk generate samplestool (the existinggeneratecheck).Design Details
build_testsskillFile to create:
eng/tools/azure-sdk-tools/azpysdk/build_tests.pyThe
build_testscheck should:InstallAndTest(frominstall_and_test.py).run()to only perform the install/build steps — no pytest, no coverage.install_all_requirements()fromInstallAndTest, which installs packaging requirements, test tools (fromeng/test_tools.txt), dev requirements, and builds/installs the package (as a wheel by default)."build-tests".target,--isolate,--service) via parent parsers.Example class structure:
create_samplesskillFile to create:
eng/tools/azure-sdk-tools/azpysdk/create_samples.pyThe
create_samplescheck should:Checkdirectly (fromCheck.py)."create-samples".target,--isolate,--service) via parent parsers.--output-dirargument (defaults to<package_dir>/samples).samples/directory path relative to the package.samples/directory if it does not already exist.README.mdinsidesamples/if one does not already exist, with a template that includes the package name and standard boilerplate.sample_hello_world.pyinsidesamples/if one does not already exist.azpysdk generatesubcommand (i.e., the existinggeneratecheck backed byeng/tools/azure-sdk-tools/azpysdk/generate.py) for more advanced code generation from a TypeSpec or Swagger spec.The docstring and help text of
create_samplesmust mention that for full SDK code generation (including samples) from a TypeSpec/Swagger spec, users should use:Wire both skills into
main.pyFile to update:
eng/tools/azure-sdk-tools/azpysdk/main.pybuild_testsfrom.build_testsandcreate_samplesfrom.create_samples.build_parser(), in a logical position (e.g. nearwhlandsamplesrespectively):Add tests
File to update:
eng/tools/azure-sdk-tools/tests/test_build_interactions.pyImplement the existing stub test functions and add new ones covering
build_testsandcreate_samples:test_build_tests_registers_subcommand()— verify thebuild-testssubcommand is registered in the CLI parser built bybuild_parser().test_build_tests_no_op_on_missing_target()— verifybuild_tests.run()returns 0 when no packages are discovered (mockget_targeted_directoriesto return[]).test_create_samples_registers_subcommand()— verify thecreate-samplessubcommand is registered.test_create_samples_creates_scaffold()— verify thatcreate_samples.run()creates asamples/directory,README.md, andsample_hello_world.pyunder the targeted package directory (usetempfile.mkdtemp()and a minimalsetup.pyorsetup.cfg).test_create_samples_skips_existing_files()— verify that ifsamples/README.mdalready exists, the tool does not overwrite it.test_build_core,test_discover_targeted_packages,test_build_packages) with minimal assertions (e.g. smoke-test that the imported symbols are callable).-...
This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.