-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Python POC for GitHub-based API Reviews #47203
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
Open
tjprescott
wants to merge
32
commits into
main
Choose a base branch
from
GenerateAPITextScript
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
fd2ab3d
Add generate_api_text.py script.
tjprescott ebb3870
Add PR creation script.
tjprescott 2d24fa9
Review feedback.
tjprescott e4b2876
Add scripts for syncing api.md
tjprescott dd1b565
Refactor create_api_review_pr from Python to JS in a module way.
tjprescott 688e16f
Remove update process and just have a consistency check.
tjprescott 323d4f3
Add minor change to azure-template to test pipeline.
tjprescott 93184af
Add API.md to test mismatch.
tjprescott 7680ff6
Apply actual api.md
tjprescott 33c39cf
Update GitHub Actions to latest major versions
Copilot 15534d7
Add shared JS scripts from rest-api-specs repo.
tjprescott 19f65ac
Refactor scripts to use shared code and simplify.
tjprescott 9d0946e
Code review feedback.
tjprescott ec760b0
Add generated API.md for azure-template
Copilot d04b5db
Refactor to use `azpysdk apistub --md` command.
tjprescott 825c684
Merge branch 'GenerateAPITextScript' of https://github.com/Azure/azur…
tjprescott 7f8eeb5
Remove Python 3.10 limit on apistub.py.
tjprescott c75faac
Refactor `azpysdk apistub` command. Extract metadata from API.md.
tjprescott dfe985c
Add validation for select metadata fields.
tjprescott 9d8137c
CI fixes.
tjprescott 760fc63
Add skill for generating review PR.
tjprescott 1517d58
Update review generation logic.
tjprescott 258a36a
fix(python adapter): add shell:true on Windows for spawnSync
tjprescott 89e6c98
fix(python adapter): pass --dest-dir so API.md lands in package dir
tjprescott 62f81e3
fix(python adapter): skip _generated dirs in readVersion to avoid sta…
tjprescott 92e0c92
Make script idempotent and reuse branches with the same API hash.
tjprescott bb253fa
Code review feedback.
tjprescott 317bd4c
Updates.
tjprescott a82a7ee
Make review PR creation only work for updates, not new packages.
tjprescott 8d07492
CI fixes.
tjprescott da6a96e
Use shared helper method.
tjprescott 8fdfca0
Add metadata to review PRs.
tjprescott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| { | ||
| "name": "@azure-tools/specs-shared", | ||
| "private": true, | ||
| "type": "module", | ||
| "exports": { | ||
| "./array": "./src/array.js", | ||
| "./breaking-change": "./src/breaking-change.js", | ||
| "./changed-files": "./src/changed-files.js", | ||
| "./console": "./src/console.js", | ||
| "./eslint-base-config": "./eslint.base.config.js", | ||
| "./exec": "./src/exec.js", | ||
| "./git": "./src/git.js", | ||
| "./github": "./src/github.js", | ||
| "./logger": "./src/logger.js", | ||
| "./math": "./src/math.js", | ||
| "./path": "./src/path.js", | ||
| "./readme": "./src/readme.js", | ||
| "./sdk-types": "./src/sdk-types.js", | ||
| "./set": "./src/set.js", | ||
| "./simple-git": "./src/simple-git.js", | ||
| "./sleep": "./src/sleep.js", | ||
| "./sort": "./src/sort.js", | ||
| "./spec-model-error": "./src/spec-model-error.js", | ||
| "./spec-model": "./src/spec-model.js", | ||
| "./swagger": "./src/swagger.js", | ||
| "./tag": "./src/tag.js", | ||
| "./time": "./src/time.js", | ||
| "./test/examples": "./test/examples.js" | ||
| }, | ||
| "bin": { | ||
| "spec-model": "./cmd/spec-model.js" | ||
| }, | ||
| "_comments": { | ||
| "dependencies": "Runtime dependencies must be kept to an absolute minimum for performance, ideally with no transitive dependencies", | ||
| "dependencies2": "All runtime and dev dependencies in this file, must be a subset of ../package.json" | ||
| }, | ||
| "dependencies": { | ||
| "@apidevtools/json-schema-ref-parser": "^15.1.3", | ||
| "debug": "^4.4.3", | ||
| "js-yaml": "^4.1.0", | ||
| "marked": "^18.0.0", | ||
| "simple-git": "^3.36.0", | ||
| "zod": "^4.3.5" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^10.0.0", | ||
| "@tsconfig/node20": "^20.1.4", | ||
| "@types/debug": "^4.1.12", | ||
| "@types/js-yaml": "^4.0.9", | ||
| "@types/node": "^20.0.0", | ||
| "@types/semver": "^7.7.1", | ||
| "@vitest/coverage-v8": "^4.1.0", | ||
| "cross-env": "^10.1.0", | ||
| "eslint": "^10.0.0", | ||
| "globals": "^17.0.0", | ||
| "prettier": "3.8.3", | ||
| "prettier-plugin-organize-imports": "^4.2.0", | ||
| "semver": "^7.7.1", | ||
| "tinybench": "^6.0.0", | ||
| "typescript": "~6.0.2", | ||
| "typescript-eslint": "^8.58.0", | ||
| "vitest": "^4.1.0" | ||
| }, | ||
| "scripts": { | ||
| "check": "npm run test:ci && npm run lint && npm run format:check", | ||
| "lint": "npm run lint:eslint && npm run lint:tsc", | ||
| "lint:eslint": "cross-env DEBUG=eslint:eslint,eslint:linter eslint", | ||
| "lint:tsc": "tsc --build --verbose", | ||
| "format": "prettier . --ignore-path ../.prettierignore --write", | ||
| "format:check": "prettier . --ignore-path ../.prettierignore --check", | ||
| "format:check:ci": "prettier . --ignore-path ../.prettierignore --check --log-level debug", | ||
| "perf": "node perf/perf.js", | ||
| "test": "vitest", | ||
| "test:ci": "vitest run --coverage --reporter=verbose" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /** | ||
| * Caches values in memory with a single key of any type. | ||
| * | ||
| * @template K, V | ||
| */ | ||
| export class KeyedCache { | ||
| /** @type {Map<K, V>} */ | ||
| #map = new Map(); | ||
|
|
||
| /** | ||
| * Returns cached value, initializing if necessary | ||
| * | ||
| * @param {K} key | ||
| * @param {() => V} factory | ||
| * @returns {V} cached value | ||
| * | ||
| * @example | ||
| * const result = cache.getOrCreate(42, async () => await doWork(42)); | ||
| */ | ||
| getOrCreate(key, factory) { | ||
| let value = this.#map.get(key); | ||
|
|
||
| if (value === undefined) { | ||
| value = factory(); | ||
| this.#map.set(key, value); | ||
| } | ||
|
|
||
| return value; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Caches values in memory with an ordered pair of keys of any types. | ||
| * | ||
| * @template K1, K2, V | ||
| */ | ||
| export class KeyedPairCache { | ||
| // Two-layer nested cache | ||
| /** @type {KeyedCache<K1, KeyedCache<K2, V>>} */ | ||
| #cache1 = new KeyedCache(); | ||
|
|
||
| /** | ||
| * Returns cached value, initializing if necessary. | ||
| * Keys are ordered, so (key1, key2) != (key2, key1). | ||
| * | ||
| * @param {K1} key1 | ||
| * @param {K2} key2 | ||
| * @param {() => V} factory | ||
| * @returns {V} cached value | ||
| * | ||
| * @example | ||
| * const result = cache.getOrCreate(42, 7, async () => await doWork(42, 7)); | ||
| */ | ||
|
tjprescott marked this conversation as resolved.
|
||
| getOrCreate(key1, key2, factory) { | ||
| // key1 => cache for the next layer | ||
| const cache2 = this.#cache1.getOrCreate(key1, () => new KeyedCache()); | ||
|
|
||
| // key2 => final value | ||
| return cache2.getOrCreate(key2, factory); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we will need to either add a package-lock.json file, or add the necessary deps to another package.json already in the repo