Skip to content

Python POC for GitHub-based API Reviews (Phase 1) - #47203

Merged
Mike Harder (mikeharder) merged 55 commits into
mainfrom
GenerateAPITextScript
Jun 12, 2026
Merged

Python POC for GitHub-based API Reviews (Phase 1)#47203
Mike Harder (mikeharder) merged 55 commits into
mainfrom
GenerateAPITextScript

Conversation

@tjprescott

@tjprescott Travis Prescott (tjprescott) commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

Adds tooling for GitHub-native API reviews for the Python SDK, enabling API surface tracking and review via GitHub PRs and CI. Based on this proposal: Proposal: API Reviews via GitHub (azure-sdk-tools#15789).

What's Included

1. CI Consistency Check (.github/workflows/api-consistency.yml)

A GitHub Actions workflow that enforces API.md consistency on every PR that touches sdk/**:

  1. find_affected.js — diffs the PR against the base branch to find changed packages
  2. regenerate.js — runs azpysdk apistub --md --extract-metadata for each affected package
  3. find_mismatches.js — compares the regenerated API.md to the committed version and validates select metadata fields
  4. Fails with actionable instructions if drift is detected

2. API Review PR Creator (create_api_review_pr.js)

A CLI tool to create dedicated API review PRs:

node scripts/api_md_workflow/create_api_review_pr.js \
  --package-name azure-foo-bar \
  --base azure-foo-bar_1.0.0 \
  --target owner:branch
  • Generates API.md for both the base tag and target branch
  • Pushes two branches and opens a draft PR where the diff is the API diff
  • Reviewers use GitHub's native review tools (comments, suggestions, approvals)

3. Language Adapter Pattern (scripts/api_md_workflow/)

Core orchestration is language-agnostic. A per-repo adapter (adapters/python.js) implements the language-specific logic (isPackageDir, findPackageDir, readVersion, generateApiForPackage). This allows the same framework to be ported to other Azure SDK language repos.

4. Shared Utility Layer (.github/shared/)

Common ESM modules for subprocess execution, logging, path manipulation, and GitHub API interactions — shared across workflow scripts.

Examples

Auto Reviews

PR Review

Copilot AI 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.

Pull request overview

Adds a new repo script (scripts/generate_api_text.py) to generate a package-level API.md by building a wheel, running apiview-stub-generator (apistub) to produce the token JSON, and converting that JSON to markdown via Export-APIViewMarkdown.ps1. This is repo tooling intended to streamline API review artifact generation.

Changes:

  • Introduces scripts/generate_api_text.py to locate a package under sdk/*/, build a wheel, run apistub, and emit API.md into the package directory.
  • Adds logic to install eng/apiview_reqs.txt and (optionally) upgrade apiview-stub-generator from the Azure SDK package index.
  • Uses eng/common/scripts/Export-APIViewMarkdown.ps1 to convert the generated *_python.json token file into markdown.

Comment thread scripts/generate_api_text.py Outdated
Comment thread scripts/generate_api_text.py Outdated
Comment thread scripts/generate_api_text.py Outdated
Comment thread scripts/generate_api_text.py Outdated
Comment thread scripts/generate_api_text.py Outdated
Comment thread scripts/generate_api_text.py Outdated
Comment thread scripts/generate_api_text.py Outdated
@tjprescott
Travis Prescott (tjprescott) force-pushed the GenerateAPITextScript branch 3 times, most recently from 7c45b15 to b9dc383 Compare May 29, 2026 19:55
@tjprescott Travis Prescott (tjprescott) changed the title Add generate_api_text.py script Python POC for GitHub-based API Reviews Jun 1, 2026
Comment thread .github/workflows/consistency.yml Outdated
Comment thread .github/workflows/consistency.yml Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 28 out of 30 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • .github/chronus/package-lock.json: Language not supported

Comment thread eng/tools/azure-sdk-tools/azpysdk/apistub.py Outdated
Comment thread .github/workflows/src/api-md-consistency/api-md-consistency.js
Comment thread scripts/api_md_workflow/create_api_review_pr.py Outdated
Comment thread scripts/api_md_workflow/create_api_review_pr.py Outdated
Comment thread .github/package.json Outdated
@tjprescott Travis Prescott (tjprescott) changed the title Python POC for GitHub-based API Reviews Python POC for GitHub-based API Reviews (Phase 1) Jun 12, 2026

@mikeharder Mike Harder (mikeharder) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I pruned down the shared code under .github to just the minimum you should currently need

@mikeharder
Mike Harder (mikeharder) merged commit b5aae50 into main Jun 12, 2026
20 checks passed
@mikeharder
Mike Harder (mikeharder) deleted the GenerateAPITextScript branch June 12, 2026 23:34
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.

6 participants