Skip to content
Closed
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
44 changes: 29 additions & 15 deletions .github/local-actions/branch-manager/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {MergeConflictsFatalError} from '../../../../ng-dev/pr/merge/failures.js';
import {createPullRequestValidationConfig} from '../../../../ng-dev/pr/common/validation/validation-config.js';
import {InvalidTargetLabelError} from '../../../../ng-dev/pr/common/targeting/target-label.js';
import {resolve} from 'path';

interface CommmitStatus {
state: 'pending' | 'error' | 'failure' | 'success';
Expand Down Expand Up @@ -50,27 +51,40 @@ const sha = await (async () => {
})();

/** Set the mergability status on the pull request provided in the environment. */
async function setMergeabilityStatusOnPullRequest({state, description, targetUrl}: CommmitStatus) {
await git.github.repos.createCommitStatus({
owner,
repo,
sha,
context: statusContextName,
state,
// Status descriptions are limited to 140 characters.
description: description.substring(0, 139),
target_url: targetUrl,
});
async function setMergeabilityStatusOnPullRequest(
{state, description, targetUrl}: CommmitStatus,
canRetry = true,
) {
try {
await git.github.repos.createCommitStatus({
owner,
repo,
sha,
context: statusContextName,
state,
// Status descriptions are limited to 140 characters.
description: description.substring(0, 139),
target_url: targetUrl,
});
} catch {
if (canRetry) {
await new Promise((resolve) => setTimeout(resolve, 5000));
await setMergeabilityStatusOnPullRequest({state, description, targetUrl}, false);
}
}
}

async function main() {
try {
// This is intentionally not awaited because we are just setting the status to pending, and wanting
// to continue working.
let _unawaitedPromise = setMergeabilityStatusOnPullRequest({
state: 'pending',
description: 'Mergability check in progress',
});
let _unawaitedPromise = setMergeabilityStatusOnPullRequest(
{
state: 'pending',
description: 'Mergability check in progress',
},
false,
);

// Create a tmp directory to perform checks in and change working to directory to it.
await cloneRepoIntoTmpLocation({owner, repo});
Expand Down
42 changes: 26 additions & 16 deletions .github/local-actions/branch-manager/main.js

Large diffs are not rendered by default.