Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "@azure-tools/specs-shared",
"private": "true",
Expand All @@ -9,6 +9,7 @@
"./equality": "./src/equality.js",
"./error-reporting": "./src/error-reporting.js",
"./exec": "./src/exec.js",
"./github": "./src/github.js",
"./logger": "./src/logger.js",
"./path": "./src/path.js",
"./readme": "./src/readme.js",
Expand Down
102 changes: 102 additions & 0 deletions .github/shared/src/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// @ts-check

export const PER_PAGE_MAX = 100;

/**
* https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks#check-statuses-and-conclusions
*
* @readonly
* @enum {"completed" | "expected" | "failure" | "in_progress" | "pending" | "queued" | "requested" | "startup_failure" | "waiting" }
*/
export const CheckStatus = Object.freeze({
/**
* @description The check run completed and has a conclusion.
*/
COMPLETED: "completed",
/**
* @description The check run is waiting for a status to be reported.
*/
EXPECTED: "expected",
/**
* @description The check run failed.
*/
FAILURE: "failure",
/**
* @description The check run is in progress.
*/
IN_PROGRESS: "in_progress",
/**
* @description The check run is at the front of the queue but the group-based concurrency limit has been reached.
*/
PENDING: "pending",
/**
* @description The check run has been queued.
*/
QUEUED: "queued",
/**
* @description The check run has been created but has not been queued.
*/
REQUESTED: "requested",
/**
* @description The check suite failed during startup. This status is not applicable to check runs.
*/
STARTUP_FAILURE: "startup_failure",
/**
* @description The check run is waiting for a deployment protection rule to be satisfied.
*/
WAITING: "waiting",
});

/**
* https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks#check-statuses-and-conclusions
*
* @readonly
* @enum {"action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" }
*/
export const CheckConclusion = Object.freeze({
/**
* @description The check run provided required actions upon its completion. For more information, see Using the REST API to interact with checks.
*/
ACTION_REQUIRED: "action_required",
/**
* @description The check run was cancelled before it completed.
*/
CANCELLED: "cancelled",
/**
* @description The check run failed.
*/
FAILURE: "failure",
/**
* @description The check run completed with a neutral result. This is treated as a success for dependent checks in GitHub Actions.
*/
NEUTRAL: "neutral",
/**
* @description The check run was skipped. This is treated as a success for dependent checks in GitHub Actions.
*/
SKIPPED: "skipped",
/**
* @description The check run was marked stale by GitHub because it took too long.
*/
STALE: "stale",
/**
* @description The check run completed successfully.
*/
SUCCESS: "success",
/**
* @description The check run timed out.
*/
TIMED_OUT: "timed_out",
});

/**
* https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status--parameters
*
* @readonly
* @enum {"error" | "failure" | "pending" | "success"}
*/
export const CommitStatusState = Object.freeze({
ERROR: "error",
FAILURE: "failure",
PENDING: "pending",
SUCCESS: "success",
});
2 changes: 1 addition & 1 deletion .github/workflows/src/arm-auto-signoff.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check

import { setEquals } from "../../shared/src/equality.js";
import { PER_PAGE_MAX } from "../../shared/src/github.js";
import { extractInputs } from "./context.js";
import { PER_PAGE_MAX } from "./github.js";
import { LabelAction } from "./label.js";

// TODO: Add tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/src/comment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PER_PAGE_MAX } from "./github.js";
import { PER_PAGE_MAX } from "../../shared/src/github.js";

/**
* @typedef {Object} IssueComment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/src/context.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import { PER_PAGE_MAX } from "./github.js";
import { PER_PAGE_MAX } from "../../shared/src/github.js";
import { getIssueNumber } from "./issues.js";

/**
Expand Down
102 changes: 1 addition & 101 deletions .github/workflows/src/github.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check

import { PER_PAGE_MAX } from "../../shared/src/github.js";
import { byDate, invert } from "../../shared/src/sort.js";

/**
Expand All @@ -9,107 +10,6 @@
* @typedef {RestEndpointMethodTypes["repos"]["listCommitStatusesForRef"]["response"]["data"]} CommitStatuses
*/

export const PER_PAGE_MAX = 100;

/**
* https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks#check-statuses-and-conclusions
*
* @readonly
* @enum {"completed" | "expected" | "failure" | "in_progress" | "pending" | "queued" | "requested" | "startup_failure" | "waiting" }
*/
export const CheckStatus = Object.freeze({
/**
* @description The check run completed and has a conclusion.
*/
COMPLETED: "completed",
/**
* @description The check run is waiting for a status to be reported.
*/
EXPECTED: "expected",
/**
* @description The check run failed.
*/
FAILURE: "failure",
/**
* @description The check run is in progress.
*/
IN_PROGRESS: "in_progress",
/**
* @description The check run is at the front of the queue but the group-based concurrency limit has been reached.
*/
PENDING: "pending",
/**
* @description The check run has been queued.
*/
QUEUED: "queued",
/**
* @description The check run has been created but has not been queued.
*/
REQUESTED: "requested",
/**
* @description The check suite failed during startup. This status is not applicable to check runs.
*/
STARTUP_FAILURE: "startup_failure",
/**
* @description The check run is waiting for a deployment protection rule to be satisfied.
*/
WAITING: "waiting",
});

/**
* https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks#check-statuses-and-conclusions
*
* @readonly
* @enum {"action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" }
*/
export const CheckConclusion = Object.freeze({
/**
* @description The check run provided required actions upon its completion. For more information, see Using the REST API to interact with checks.
*/
ACTION_REQUIRED: "action_required",
/**
* @description The check run was cancelled before it completed.
*/
CANCELLED: "cancelled",
/**
* @description The check run failed.
*/
FAILURE: "failure",
/**
* @description The check run completed with a neutral result. This is treated as a success for dependent checks in GitHub Actions.
*/
NEUTRAL: "neutral",
/**
* @description The check run was skipped. This is treated as a success for dependent checks in GitHub Actions.
*/
SKIPPED: "skipped",
/**
* @description The check run was marked stale by GitHub because it took too long.
*/
STALE: "stale",
/**
* @description The check run completed successfully.
*/
SUCCESS: "success",
/**
* @description The check run timed out.
*/
TIMED_OUT: "timed_out",
});

/**
* https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status--parameters
*
* @readonly
* @enum {"error" | "failure" | "pending" | "success"}
*/
export const CommitStatusState = Object.freeze({
ERROR: "error",
FAILURE: "failure",
PENDING: "pending",
SUCCESS: "success",
});

/**
* Writes content to the GitHub Actions summary
* @param {string} content - Markdown content to add to the summary
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/src/set-status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// @ts-check

import {
CheckConclusion,
CheckStatus,
CommitStatusState,
PER_PAGE_MAX,
} from "../../shared/src/github.js";
import { extractInputs } from "./context.js";
import { CheckConclusion, CheckStatus, CommitStatusState, PER_PAGE_MAX } from "./github.js";

// TODO: Add tests
/* v8 ignore start */
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/src/spec-gen-sdk-status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @ts-check
import { CheckStatus, CommitStatusState, PER_PAGE_MAX } from "../../shared/src/github.js";
import { getAdoBuildInfoFromUrl, getAzurePipelineArtifact } from "./artifacts.js";
import { extractInputs } from "./context.js";
import { CheckStatus, CommitStatusState, PER_PAGE_MAX, writeToActionsSummary } from "./github.js";
import { writeToActionsSummary } from "./github.js";

/**
* @param {import('@actions/github-script').AsyncFunctionArguments} AsyncFunctionArguments
Expand Down Expand Up @@ -123,10 +124,10 @@
* @param {Object} params
* @param {Array<any>} params.checkRuns
* @param {typeof import("@actions/core")} params.core
* @returns {Promise<{state: import("./github.js").CommitStatusState, description: string}>}
* @returns {Promise<{state: CommitStatusState, description: string}>}
*/
async function processResult({ checkRuns, core }) {
/** @type {import("./github.js").CommitStatusState} */
/** @type {CommitStatusState} */
let state = CommitStatusState.SUCCESS;
let specGenSdkFailedRequiredLanguages = "";
let description = "SDK Validation CI checks succeeded";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-check

/*
Expand All @@ -22,7 +22,7 @@
import { extractInputs } from "../context.js";
// import { commentOrUpdate } from "../comment.js";
import { execFile } from "../../../shared/src/exec.js";
import { PER_PAGE_MAX } from "../github.js";
import { PER_PAGE_MAX } from "../../../shared/src/github.js";
import {
brChRevApproval,
getViolatedRequiredLabelsRules,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/src/update-labels.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import { PER_PAGE_MAX } from "../../shared/src/github.js";
import { extractInputs } from "../src/context.js";
import { PER_PAGE_MAX } from "./github.js";

/**
* @param {import('@actions/github-script').AsyncFunctionArguments} AsyncFunctionArguments
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test/context.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { PER_PAGE_MAX } from "../../shared/src/github.js";
import { extractInputs } from "../src/context.js";
import { PER_PAGE_MAX } from "../src/github.js";
import { createMockCore, createMockGithub } from "./mocks.js";

describe("extractInputs", () => {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test/set-status.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { beforeEach, describe, expect, it } from "vitest";
import { setStatusImpl } from "../src/set-status.js";

import { CheckConclusion, CheckStatus, CommitStatusState } from "../src/github.js";
import { CheckConclusion, CheckStatus, CommitStatusState } from "../../shared/src/github.js";
import { createMockCore, createMockGithub } from "./mocks.js";

describe("setStatusImpl", () => {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test/update-labels.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { PER_PAGE_MAX } from "../src/github.js";
import { PER_PAGE_MAX } from "../../shared/src/github.js";
import updateLabels, { updateLabelsImpl } from "../src/update-labels.js";
import { createMockCore, createMockGithub, createMockRequestError } from "./mocks.js";

Expand Down