Skip to content

Commit 183b91a

Browse files
committed
Initial implementations.
1 parent 9cde269 commit 183b91a

8 files changed

Lines changed: 769 additions & 0 deletions

.github/workflows/api-consistency.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,10 @@ jobs:
5959
const { default: apiMdConsistency } =
6060
await import('${{ github.workspace }}/.github/workflows/src/api-md-consistency/api-md-consistency.js');
6161
return await apiMdConsistency({ github, context, core });
62+
63+
- name: Upload affected package list
64+
if: ${{ success() && steps.consistency.outputs.changed_count != '0' }}
65+
uses: actions/upload-artifact@v7
66+
with:
67+
name: api-md-affected-packages
68+
path: .artifacts/affected_package_dirs.txt
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: API.md Dispatch Review Syncs
2+
3+
on:
4+
workflow_run:
5+
workflows: ["API.md Consistency"]
6+
types: [completed]
7+
8+
permissions:
9+
actions: write
10+
contents: read
11+
pull-requests: read
12+
13+
concurrency:
14+
group: api-md-dispatch-review-syncs-${{ github.event.workflow_run.head_repository.owner.login }}-${{ github.event.workflow_run.head_branch }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
dispatch:
19+
if: >-
20+
github.event.workflow_run.conclusion == 'success' &&
21+
!startsWith(github.event.workflow_run.head_branch, 'apireview/')
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout trusted workflow scripts
25+
uses: actions/checkout@v6
26+
27+
- name: Checkout working SHA for package metadata
28+
uses: actions/checkout@v6
29+
with:
30+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
31+
ref: ${{ github.event.workflow_run.head_sha }}
32+
path: working
33+
fetch-depth: 1
34+
persist-credentials: false
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v6
38+
with:
39+
node-version: lts/*
40+
41+
- name: Download API.md consistency artifacts
42+
env:
43+
GH_TOKEN: ${{ github.token }}
44+
run: |
45+
gh run download "${{ github.event.workflow_run.id }}" --name api-md-affected-packages --dir .artifacts || true
46+
47+
- name: Dispatch matching review branch syncs
48+
if: ${{ hashFiles('.artifacts/affected_package_dirs.txt') != '' }}
49+
env:
50+
GITHUB_TOKEN: ${{ github.token }}
51+
run: >-
52+
node .github/workflows/src/api-md-review-sync/dispatch_review_branch_syncs.js
53+
--packages-file .artifacts/affected_package_dirs.txt
54+
--working-owner "${{ github.event.workflow_run.head_repository.owner.login }}"
55+
--working-branch "${{ github.event.workflow_run.head_branch }}"
56+
--working-sha "${{ github.event.workflow_run.head_sha }}"
57+
--repo-root working
58+
59+
- name: No affected packages
60+
if: ${{ hashFiles('.artifacts/affected_package_dirs.txt') == '' }}
61+
run: echo "No affected API.md packages were published by the consistency run."
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: API.md Sync Review Branch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
packageDir:
7+
description: Package directory containing api.md and api.metadata.yml.
8+
required: true
9+
reviewBranch:
10+
description: API review branch to update.
11+
required: true
12+
workingOwner:
13+
description: Owner of the working branch repository.
14+
required: true
15+
workingBranch:
16+
description: Working branch name.
17+
required: true
18+
workingSha:
19+
description: Consistency-verified working branch SHA.
20+
required: true
21+
22+
permissions:
23+
contents: write
24+
25+
concurrency:
26+
group: api-md-sync-review-branch-${{ inputs.reviewBranch }}
27+
cancel-in-progress: false
28+
29+
jobs:
30+
sync:
31+
if: ${{ startsWith(inputs.reviewBranch, 'apireview/review_') && !startsWith(inputs.workingBranch, 'apireview/') }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout trusted workflow scripts
35+
uses: actions/checkout@v6
36+
with:
37+
path: trusted
38+
39+
- name: Checkout working SHA
40+
uses: actions/checkout@v6
41+
with:
42+
repository: ${{ inputs.workingOwner }}/azure-sdk-for-python
43+
ref: ${{ inputs.workingSha }}
44+
path: working
45+
fetch-depth: 1
46+
persist-credentials: false
47+
48+
- name: Checkout review branch
49+
uses: actions/checkout@v6
50+
with:
51+
ref: ${{ inputs.reviewBranch }}
52+
path: review
53+
fetch-depth: 1
54+
55+
- name: Setup Node.js
56+
uses: actions/setup-node@v6
57+
with:
58+
node-version: lts/*
59+
60+
- name: Sync API.md artifacts
61+
working-directory: review
62+
env:
63+
GITHUB_TOKEN: ${{ github.token }}
64+
run: >-
65+
node ../trusted/.github/workflows/src/api-md-review-sync/sync_review_branch.js
66+
--working-root ../working
67+
--review-root .
68+
--package-dir "${{ inputs.packageDir }}"
69+
--review-branch "${{ inputs.reviewBranch }}"
70+
--working-owner "${{ inputs.workingOwner }}"
71+
--working-branch "${{ inputs.workingBranch }}"
72+
--working-sha "${{ inputs.workingSha }}"

.github/workflows/api-md-workflow-tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@ jobs:
2222
with:
2323
python-version: "3.12"
2424

25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: lts/*
29+
2530
- name: Run API.md workflow unit tests
2631
run: python -m unittest discover scripts/api_md_workflow "*_test.py"
32+
33+
- name: Run API.md workflow JavaScript unit tests
34+
run: node --test .github/workflows/src/api-md-review-sync/*.test.js

0 commit comments

Comments
 (0)