Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/api-consistency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ jobs:
const { default: apiMdConsistency } =
await import('${{ github.workspace }}/.github/workflows/src/api-md-consistency/api-md-consistency.js');
return await apiMdConsistency({ github, context, core });

- name: Upload affected package list
if: ${{ success() && steps.consistency.outputs.changed_count != '0' }}
uses: actions/upload-artifact@v7
with:
name: api-md-affected-packages
path: .artifacts/affected_package_dirs.txt
61 changes: 61 additions & 0 deletions .github/workflows/api-md-dispatch-review-syncs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: API.md Dispatch Review Syncs

on:
workflow_run:
workflows: ["API.md Consistency"]
types: [completed]

permissions:
actions: write
contents: read
pull-requests: read

concurrency:
group: api-md-dispatch-review-syncs-${{ github.event.workflow_run.head_repository.owner.login }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true

jobs:
dispatch:
if: >-
github.event.workflow_run.conclusion == 'success' &&
!startsWith(github.event.workflow_run.head_branch, 'apireview/')
runs-on: ubuntu-latest
steps:
- name: Checkout trusted workflow scripts
uses: actions/checkout@v6

- name: Checkout working SHA for package metadata
uses: actions/checkout@v6
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_sha }}
path: working
fetch-depth: 1
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: lts/*

- name: Download API.md consistency artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
gh run download "${{ github.event.workflow_run.id }}" --name api-md-affected-packages --dir .artifacts || true

- name: Dispatch matching review branch syncs
if: ${{ hashFiles('.artifacts/affected_package_dirs.txt') != '' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
node .github/workflows/src/api-md-review-sync/dispatch_review_branch_syncs.js
--packages-file .artifacts/affected_package_dirs.txt
--working-owner "${{ github.event.workflow_run.head_repository.owner.login }}"
--working-branch "${{ github.event.workflow_run.head_branch }}"
--working-sha "${{ github.event.workflow_run.head_sha }}"
--repo-root working

- name: No affected packages
if: ${{ hashFiles('.artifacts/affected_package_dirs.txt') == '' }}
run: echo "No affected API.md packages were published by the consistency run."
72 changes: 72 additions & 0 deletions .github/workflows/api-md-sync-review-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: API.md Sync Review Branch

on:
workflow_dispatch:
inputs:
packageDir:
description: Package directory containing api.md and api.metadata.yml.
required: true
reviewBranch:
description: API review branch to update.
required: true
workingOwner:
description: Owner of the working branch repository.
required: true
workingBranch:
description: Working branch name.
required: true
workingSha:
description: Consistency-verified working branch SHA.
required: true

permissions:
contents: write

concurrency:
group: api-md-sync-review-branch-${{ inputs.reviewBranch }}
cancel-in-progress: false

jobs:
sync:
if: ${{ startsWith(inputs.reviewBranch, 'apireview/review_') && !startsWith(inputs.workingBranch, 'apireview/') }}
runs-on: ubuntu-latest
steps:
- name: Checkout trusted workflow scripts
uses: actions/checkout@v6
with:
path: trusted

- name: Checkout working SHA
uses: actions/checkout@v6
with:
repository: ${{ inputs.workingOwner }}/azure-sdk-for-python
ref: ${{ inputs.workingSha }}
path: working
fetch-depth: 1
persist-credentials: false

- name: Checkout review branch
uses: actions/checkout@v6
with:
ref: ${{ inputs.reviewBranch }}
path: review
fetch-depth: 1

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: lts/*

- name: Sync API.md artifacts
working-directory: review
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
node ../trusted/.github/workflows/src/api-md-review-sync/sync_review_branch.js
--working-root ../working
--review-root .
--package-dir "${{ inputs.packageDir }}"
--review-branch "${{ inputs.reviewBranch }}"
--working-owner "${{ inputs.workingOwner }}"
--working-branch "${{ inputs.workingBranch }}"
--working-sha "${{ inputs.workingSha }}"
8 changes: 8 additions & 0 deletions .github/workflows/api-md-workflow-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ jobs:
with:
python-version: "3.12"

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: lts/*

- name: Run API.md workflow unit tests
run: python -m unittest discover scripts/api_md_workflow "*_test.py"

- name: Run API.md workflow JavaScript unit tests
run: node --test .github/workflows/src/api-md-review-sync/*.test.js
Loading
Loading