Skip to content

Add build-tests and create-samples subcommands to azpysdk CLI#45825

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/add-build-tests-and-create-samples
Closed

Add build-tests and create-samples subcommands to azpysdk CLI#45825
Copilot wants to merge 2 commits intomainfrom
copilot/add-build-tests-and-create-samples

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Adds two new skills to the azpysdk CLI in eng/tools/azure-sdk-tools/azpysdk/.

build-tests (azpysdk/build_tests.py)

Subclasses InstallAndTest with coverage_enabled=False. Overrides run() to execute only install_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.

azpysdk build-tests <target>

create-samples (azpysdk/create_samples.py)

Subclasses Check. For each targeted package, creates a samples/ directory scaffold (README.md + sample_hello_world.py) if the files don't already exist (idempotent). Accepts an optional --output-dir to override the default <package_dir>/samples location. Both the help text and generated README point users to azpysdk generate <target> for full SDK codegen from TypeSpec/Swagger.

azpysdk create-samples <target>
azpysdk create-samples <target> --output-dir path/to/samples

main.py

Both skills imported and registered — build_tests near whl, create_samples near samples.

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
    • Triggering command: /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&gt;=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 azpysdk CLI in eng/tools/azure-sdk-tools/azpysdk/:

  1. build_tests — A new Check subclass 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.
  2. create_samples — A new Check subclass that generates a starter samples scaffold for a targeted package and mentions the azpysdk generate samples tool (the existing generate check).

Design Details

build_tests skill

File to create: eng/tools/azure-sdk-tools/azpysdk/build_tests.py

The build_tests check should:

  • Subclass InstallAndTest (from install_and_test.py).
  • Override run() to only perform the install/build steps — no pytest, no coverage.
  • Reuse install_all_requirements() from InstallAndTest, which installs packaging requirements, test tools (from eng/test_tools.txt), dev requirements, and builds/installs the package (as a wheel by default).
  • Register under the CLI subcommand name "build-tests".
  • Accept the common arguments (target, --isolate, --service) via parent parsers.
  • Log a clear summary of success/failure per package.
  • Return a non-zero exit code if any package's build/install step failed.

Example class structure:

class build_tests(InstallAndTest):
    def __init__(self) -> None:
        super().__init__(
            package_type="wheel",
            proxy_url=None,
            display_name="build-tests",
            coverage_enabled=False,
        )

    def register(self, subparsers, parent_parsers=None) -> None:
        # registers "build-tests" subcommand
        ...

    def run(self, args) -> int:
        # installs requirements and builds/installs the package
        # does NOT call run_pytest or check_coverage
        ...

create_samples skill

File to create: eng/tools/azure-sdk-tools/azpysdk/create_samples.py

The create_samples check should:

  • Subclass Check directly (from Check.py).
  • Register under the CLI subcommand name "create-samples".
  • Accept the common arguments (target, --isolate, --service) via parent parsers.
  • Accept an optional --output-dir argument (defaults to <package_dir>/samples).
  • For each targeted package:
    • Determine the samples/ directory path relative to the package.
    • Create the samples/ directory if it does not already exist.
    • Generate a starter README.md inside samples/ if one does not already exist, with a template that includes the package name and standard boilerplate.
    • Generate a starter sample_hello_world.py inside samples/ if one does not already exist.
    • Log a message pointing users to the azpysdk generate subcommand (i.e., the existing generate check backed by eng/tools/azure-sdk-tools/azpysdk/generate.py) for more advanced code generation from a TypeSpec or Swagger spec.
  • Return 0 on success, 1 on failure.

The docstring and help text of create_samples must mention that for full SDK code generation (including samples) from a TypeSpec/Swagger spec, users should use:

azpysdk generate <target>

Wire both skills into main.py

File to update: eng/tools/azure-sdk-tools/azpysdk/main.py

  • Import build_tests from .build_tests and create_samples from .create_samples.
  • Register both with the subparsers in build_parser(), in a logical position (e.g. near whl and samples respectively):
    from .build_tests import build_tests
    from .create_samples import create_samples
    ...
    build_tests().register(subparsers, [common])
    create_samples().register(subparsers, [common])

Add tests

File to update: eng/tools/azure-sdk-tools/tests/test_build_interactions.py

Implement the existing stub test functions and add new ones covering build_tests and create_samples:

  • test_build_tests_registers_subcommand() — verify the build-tests subcommand is registered in the CLI parser built by build_parser().
  • test_build_tests_no_op_on_missing_target() — verify build_tests.run() returns 0 when no packages are discovered (mock get_targeted_directories to return []).
  • test_create_samples_registers_subcommand() — verify the create-samples subcommand is registered.
  • test_create_samples_creates_scaffold() — verify that create_samples.run() creates a samples/ directory, README.md, and sample_hello_world.py under the targeted package directory (use tempfile.mkdtemp() and a minimal setup.py or setup.cfg).
  • test_create_samples_skips_existing_files() — verify that if samples/README.md already exists, the tool does not overwrite it.
  • Implement the three existing stubs (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.

Copilot AI changed the title [WIP] Add build_tests and create_samples skills to azpysdk CLI Add build-tests and create-samples subcommands to azpysdk CLI Mar 20, 2026
Copilot AI requested a review from l0lawrence March 20, 2026 17:00
@l0lawrence
Copy link
Member

@copilot i wanted skills on building tests and samples no scripts

Copy link
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot i wanted skills on building tests and samples no scripts

Both build_tests and create_samples are implemented as proper azpysdk CLI skills — they are Check subclasses with register() and run() methods registered in main.py, following the same pattern as whl, samples, and devtest. No standalone shell scripts were created. You can use them as:

azpysdk build-tests <target>
azpysdk create-samples <target>

@l0lawrence
Copy link
Member

@copilot I want gh copilot skills

Copy link
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot I want gh copilot skills

Could you clarify what you mean by "gh copilot skills"? The current implementation adds build-tests and create-samples as azpysdk CLI skills (Check subclasses registered with azpysdk build-tests and azpysdk create-samples). If you're referring to something different — such as GitHub Copilot Coding Agent skills (like emitter-package-update) or GitHub Copilot Extensions — please let me know so I can adjust accordingly.

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.

2 participants