Skip to content

Commit f2573b6

Browse files
author
Aman Jain
committed
Merge branch 'main' of https://github.com/Azure/azure-rest-api-specs into dev/Aman-Jain-14/StorageCache_AutoImport_2025-05-01_API_spec
2 parents 469363a + 7d694e7 commit f2573b6

File tree

1,914 files changed

+271345
-5524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,914 files changed

+271345
-5524
lines changed

.github/package-lock.json

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Prefix with "~" to sort last in Actions list
2+
name: ~Templates - Verify Run Status
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
check_run_name:
8+
description: Name of the check run to verify
9+
required: true
10+
type: string
11+
workflow_name:
12+
description: Name of the workflow to verify
13+
required: true
14+
type: string
15+
16+
permissions:
17+
checks: read
18+
contents: read
19+
20+
jobs:
21+
check-run-status:
22+
if: |
23+
(github.event_name == 'workflow_run') ||
24+
(github.event_name == 'check_suite' && github.event.check_suite.app.name == 'openapi-pipeline-app') ||
25+
(github.event_name == 'check_run' && github.event.check_run.name == inputs.check_run_name)
26+
runs-on: ubuntu-24.04
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
sparse-checkout: |
32+
.github
33+
34+
- name: Verify matching status
35+
uses: actions/github-script@v7
36+
with:
37+
script: |
38+
const { verifyRunStatus } = await import('${{ github.workspace }}/.github/workflows/src/verify-run-status.js');
39+
return await verifyRunStatus({ github, context, core });
40+
env:
41+
CHECK_RUN_NAME: ${{ inputs.check_run_name }}
42+
WORKFLOW_NAME: ${{ inputs.workflow_name }}

.github/workflows/avocado.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "[TEST-IGNORE] Swagger Avocado"
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
avocado:
10+
name: "[TEST-IGNORE] Swagger Avocado"
11+
12+
runs-on: ubuntu-24.04
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
# Must include all branches, for git branch logic in Avocado to work correctly
18+
fetch-depth: 0
19+
20+
- name: Setup Node and install deps
21+
uses: ./.github/actions/setup-node-install-deps
22+
23+
- name: Run Avocado
24+
run: |
25+
npm exec --no avocado \
26+
--excludePaths \
27+
"/common-types/" \
28+
"/scenarios/" \
29+
"/package.json" \
30+
"/package-lock.json" \
31+
"/cadl/examples/" \
32+
--includePaths \
33+
"data-plane" \
34+
"resource-manager"
35+
env:
36+
# Tells Avocado to analyze the files changed between the PR head (default checkout)
37+
# and the PR base branch.
38+
SYSTEM_PULLREQUEST_TARGETBRANCH: ${{ github.event.pull_request.base.ref }}

.github/workflows/post-apiview.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: After APIView
2+
3+
on:
4+
check_run:
5+
types: [completed]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: read
10+
11+
jobs:
12+
post-apiview:
13+
name: After APIView
14+
runs-on: ubuntu-24.04
15+
if: |
16+
github.event.check_run.check_suite.app.name == 'Azure Pipelines' && (
17+
contains(github.event.check_run.name, 'APIView') ||
18+
contains(github.event.check_run.name, 'SDK Generation') ||
19+
contains(github.event.check_run.name, 'SDK azure-sdk-for-') )
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
sparse-checkout: 'eng/common'
25+
26+
- name: Create APIView Comment on PR
27+
run: |
28+
. "eng/common/scripts/Helpers/ApiView-Helpers.ps1"
29+
Set-ApiViewCommentForRelatedIssues -HeadCommitish ${{ github.event.check_run.head_sha }} -AuthToken ${{ secrets.GITHUB_TOKEN }}
30+
shell: pwsh

.github/workflows/sdk-breaking-change-labels.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ permissions:
99

1010
jobs:
1111
sdk-breaking-change-labels:
12-
if: ${{ contains(github.event.check_run.name, 'SDK Generation') && github.event.check_run.check_suite.app.name == 'Azure Pipelines'}}
12+
# Only run this job when the check run is from Azure Pipelines SDK Generation job in the azure-sdk/public(id: 29ec6040-b234-4e31-b139-33dc4287b756) project
13+
if: |
14+
github.event.check_run.check_suite.app.name == 'Azure Pipelines' &&
15+
contains(github.event.check_run.name, 'SDK Generation') &&
16+
endsWith(github.event.check_run.external_id, '29ec6040-b234-4e31-b139-33dc4287b756')
1317
name: SDK Breaking Change Labels (Preview)
1418
runs-on: ubuntu-24.04
1519
steps:

.github/workflows/src/context.js

+65-19
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,22 @@ export async function extractInputs(github, context, core) {
130130
core.info(
131131
`listPullRequestsAssociatedWithCommit(${head_owner}, ${head_repo}, ${head_sha})`,
132132
);
133-
const pullRequests = await github.paginate(
134-
github.rest.repos.listPullRequestsAssociatedWithCommit,
135-
{
136-
owner: head_owner,
137-
repo: head_repo,
138-
commit_sha: head_sha,
139-
per_page: PER_PAGE_MAX,
140-
},
133+
const pullRequests = (
134+
await github.paginate(
135+
github.rest.repos.listPullRequestsAssociatedWithCommit,
136+
{
137+
owner: head_owner,
138+
repo: head_repo,
139+
commit_sha: head_sha,
140+
per_page: PER_PAGE_MAX,
141+
},
142+
)
143+
).filter(
144+
// Only include PRs to the same repo as the triggering workflow.
145+
//
146+
// Other unique keys like "full_name" should also work, but "id" is the safest since it's
147+
// supposed to be guaranteed unique and never change (repos can be renamed or change owners).
148+
(pr) => pr.base.repo.id === payload.workflow_run.repository.id,
141149
);
142150

143151
if (pullRequests.length === 0) {
@@ -238,25 +246,41 @@ export async function extractInputs(github, context, core) {
238246
`Could not extract build ID or project URL from check run details URL: ${checkRun.details_url}`,
239247
);
240248
}
241-
if (
242-
!context.payload.repository ||
243-
!context.payload.repository.owner ||
244-
!context.payload.repository.owner.login ||
245-
!context.payload.repository.name
246-
) {
247-
throw new Error(
248-
`Could not extract repository owner or name from context payload: ${JSON.stringify(context.payload.repository)}`,
249+
250+
const payload =
251+
/** @type {import("@octokit/webhooks-types").CheckRunEvent} */ (
252+
context.payload
249253
);
250-
}
254+
const repositoryInfo = getRepositoryInfo(payload.repository);
251255
inputs = {
252-
owner: context.payload.repository.owner.login,
253-
repo: context.payload.repository.name,
256+
owner: repositoryInfo.owner,
257+
repo: repositoryInfo.repo,
254258
head_sha: checkRun.head_sha,
255259
ado_build_id: match[2],
256260
ado_project_url: match[1],
257261
issue_number: NaN,
258262
run_id: NaN,
259263
};
264+
} else if (
265+
context.eventName === "check_suite" &&
266+
context.payload.action === "completed"
267+
) {
268+
const payload =
269+
/** @type {import("@octokit/webhooks-types").CheckSuiteCompletedEvent} */ (
270+
context.payload
271+
);
272+
273+
const repositoryInfo = getRepositoryInfo(payload.repository);
274+
inputs = {
275+
owner: repositoryInfo.owner,
276+
repo: repositoryInfo.repo,
277+
head_sha: payload.check_suite.head_sha,
278+
279+
// These are NaN today because the only consumer of this event needs only
280+
// the head_sha
281+
issue_number: NaN,
282+
run_id: NaN,
283+
};
260284
} else {
261285
throw new Error(
262286
`Context '${context.eventName}:${context.payload.action}' is not yet supported.`,
@@ -266,3 +290,25 @@ export async function extractInputs(github, context, core) {
266290
core.info(`inputs: ${JSON.stringify(inputs)}`);
267291
return inputs;
268292
}
293+
294+
/**
295+
* @param {import("@octokit/webhooks-types").Repository | undefined} repository
296+
* @returns {{ owner: string, repo: string }}
297+
*/
298+
function getRepositoryInfo(repository) {
299+
if (
300+
!repository ||
301+
!repository.owner ||
302+
!repository.owner.login ||
303+
!repository.name
304+
) {
305+
throw new Error(
306+
`Could not extract repository owner or name from context payload: ${JSON.stringify(repository)}`,
307+
);
308+
}
309+
310+
return {
311+
owner: repository.owner.login,
312+
repo: repository.name,
313+
};
314+
}

.github/workflows/src/retries.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Retry a function with exponential backoff
3+
* @param {Function} fn - Function to retry
4+
* @param {Object} options - Retry options
5+
* @param {number} [options.maxRetries=3] - Maximum number of retries
6+
* @param {number} [options.initialDelayMs=1000] - Initial delay in milliseconds
7+
* @param {number} [options.maxDelayMs=10000] - Maximum delay in milliseconds
8+
* @param {Function} [options.logger] - Logger function
9+
* @returns {Promise<any>} - Result of the function
10+
*/
11+
export async function retry(
12+
fn,
13+
{
14+
maxRetries = 3,
15+
initialDelayMs = 1000,
16+
maxDelayMs = 10000,
17+
logger = console.log,
18+
} = {},
19+
) {
20+
let lastError;
21+
22+
for (let attempt = 0; attempt < maxRetries + 1; attempt++) {
23+
try {
24+
return await fn();
25+
} catch (error) {
26+
lastError = error;
27+
28+
if (attempt < maxRetries) {
29+
const delayMs = Math.min(
30+
initialDelayMs * Math.pow(2, attempt),
31+
maxDelayMs,
32+
);
33+
logger(
34+
`Request failed, retrying in ${delayMs}ms... (${attempt + 1}/${maxRetries})`,
35+
);
36+
if (error instanceof Error) {
37+
logger(`Error: ${error.message}`);
38+
}
39+
await new Promise((resolve) => setTimeout(resolve, delayMs));
40+
}
41+
}
42+
}
43+
44+
throw lastError;
45+
}
46+
47+
/**
48+
* Fetch with retry functionality
49+
* @param {string} url - URL to fetch
50+
* @param {Object} [options] - Fetch options
51+
* @param {Object} [retryOptions] - Retry options
52+
* @returns {Promise<Response>} - Fetch response
53+
*/
54+
export async function fetchWithRetry(url, options = {}, retryOptions = {}) {
55+
return retry(() => fetch(url, options), retryOptions);
56+
}

0 commit comments

Comments
 (0)