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
3 changes: 2 additions & 1 deletion actions/setup/js/create_discussion.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { resolveTargetRepoConfig, resolveAndValidateRepo } = require("./repo_help
const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs");
const { removeDuplicateTitleFromDescription } = require("./remove_duplicate_title.cjs");
const { getErrorMessage } = require("./error_helpers.cjs");
const { ERR_VALIDATION } = require("./error_codes.cjs");
const { createExpirationLine, generateFooterWithExpiration } = require("./ephemerals.cjs");
const { generateWorkflowIdMarker, generateWorkflowCallIdMarker, generateCloseKeyMarker, normalizeCloseOlderKey } = require("./generate_footer.cjs");
const { sanitizeLabelContent } = require("./sanitize_label_content.cjs");
Expand Down Expand Up @@ -310,7 +311,7 @@ async function main(config = {}) {
const rawCloseOlderKey = config.close_older_key ? String(config.close_older_key) : "";
const closeOlderKey = rawCloseOlderKey ? normalizeCloseOlderKey(rawCloseOlderKey) : "";
if (rawCloseOlderKey && !closeOlderKey) {
throw new Error(`close-older-key "${rawCloseOlderKey}" is invalid: it must contain at least one alphanumeric character after normalization`);
throw new Error(`${ERR_VALIDATION}: close-older-key "${rawCloseOlderKey}" is invalid: it must contain at least one alphanumeric character after normalization`);
}
const includeFooter = parseBoolTemplatable(config.footer, true);

Expand Down
3 changes: 2 additions & 1 deletion actions/setup/js/create_issue.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const { resolveTargetRepoConfig, resolveAndValidateRepo } = require("./repo_help
const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs");
const { removeDuplicateTitleFromDescription } = require("./remove_duplicate_title.cjs");
const { getErrorMessage } = require("./error_helpers.cjs");
const { ERR_VALIDATION } = require("./error_codes.cjs");
const { renderTemplateFromFile } = require("./messages_core.cjs");
const { createExpirationLine, addExpirationToFooter } = require("./ephemerals.cjs");
const { MAX_SUB_ISSUES, getSubIssueCount } = require("./sub_issue_helpers.cjs");
Expand Down Expand Up @@ -207,7 +208,7 @@ async function main(config = {}) {
const rawCloseOlderKey = config.close_older_key ? String(config.close_older_key) : "";
const closeOlderKey = rawCloseOlderKey ? normalizeCloseOlderKey(rawCloseOlderKey) : "";
if (rawCloseOlderKey && !closeOlderKey) {
throw new Error(`close-older-key "${rawCloseOlderKey}" is invalid: it must contain at least one alphanumeric character after normalization`);
throw new Error(`${ERR_VALIDATION}: close-older-key "${rawCloseOlderKey}" is invalid: it must contain at least one alphanumeric character after normalization`);
}
const includeFooter = parseBoolTemplatable(config.footer, true);

Expand Down
5 changes: 3 additions & 2 deletions actions/setup/js/push_signed_commits.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const fs = require("fs");
/** @type {typeof import("path")} */
const path = require("path");
const { ERR_API } = require("./error_codes.cjs");

/**
* @fileoverview Signed Commit Push Helper
Expand Down Expand Up @@ -73,7 +74,7 @@ async function pushSignedCommits({ githubClient, owner, repo, branch, baseRef, c
const { stdout: parentOut } = await exec.getExecOutput("git", ["rev-parse", `${sha}^`], { cwd });
expectedHeadOid = parentOut.trim();
if (!expectedHeadOid) {
throw new Error(`Could not resolve OID for new branch ${branch}`);
throw new Error(`${ERR_API}: Could not resolve OID for new branch ${branch}`);
}
core.info(`pushSignedCommits: creating remote branch ${branch} at parent OID ${expectedHeadOid}`);
try {
Expand Down Expand Up @@ -152,7 +153,7 @@ async function pushSignedCommits({ githubClient, owner, repo, branch, baseRef, c
);
const newOid = result && result.createCommitOnBranch && result.createCommitOnBranch.commit ? result.createCommitOnBranch.commit.oid : undefined;
if (typeof newOid !== "string" || newOid.length === 0) {
throw new Error("pushSignedCommits: GraphQL createCommitOnBranch did not return a valid commit OID");
throw new Error(`${ERR_API}: GraphQL createCommitOnBranch did not return a valid commit OID`);
}
lastOid = newOid;
core.info(`pushSignedCommits: signed commit created: ${lastOid}`);
Expand Down
9 changes: 5 additions & 4 deletions actions/setup/js/qmd_index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const fs = require("fs");
const path = require("path");
const { pathToFileURL } = require("url");
const { ERR_CONFIG, ERR_VALIDATION } = require("./error_codes.cjs");

/**
* @typedef {{ name: string, path: string, patterns?: string[], context?: string }} QmdCheckout
Expand Down Expand Up @@ -107,7 +108,7 @@ async function writeSummary(config, updateResult, embedResult) {
async function main() {
const configJson = process.env.QMD_CONFIG_JSON;
if (!configJson) {
core.setFailed("QMD_CONFIG_JSON environment variable not set");
core.setFailed(`${ERR_CONFIG}: QMD_CONFIG_JSON environment variable not set`);
return;
}

Expand All @@ -118,7 +119,7 @@ async function main() {
// The package is installed into the gh-aw actions directory by a prior npm-install step.
const qmdIndexPath = path.join(__dirname, "node_modules", "@tobilu", "qmd", "dist", "index.js");
if (!fs.existsSync(qmdIndexPath)) {
core.setFailed(`@tobilu/qmd not found at ${qmdIndexPath}. The 'Install @tobilu/qmd SDK' step must run first.`);
core.setFailed(`${ERR_CONFIG}: @tobilu/qmd not found at ${qmdIndexPath}. The 'Install @tobilu/qmd SDK' step must run first.`);
return;
}

Expand Down Expand Up @@ -156,7 +157,7 @@ async function main() {
const repoSlug = search.repo || process.env.GITHUB_REPOSITORY || "";
const slugParts = repoSlug.split("/");
if (slugParts.length < 2 || !slugParts[0] || !slugParts[1]) {
core.setFailed(`qmd search "${collectionName}": invalid repository slug "${repoSlug}" (expected "owner/repo")`);
core.setFailed(`${ERR_VALIDATION}: qmd search "${collectionName}": invalid repository slug "${repoSlug}" (expected "owner/repo")`);
return;
}
const [owner, repo] = slugParts;
Expand Down Expand Up @@ -218,7 +219,7 @@ async function main() {
if (minCount > 0) {
const fileCount = fs.readdirSync(searchDir).length;
if (fileCount < minCount) {
core.setFailed(`qmd search "${collectionName}" returned ${fileCount} results, minimum is ${minCount}`);
core.setFailed(`${ERR_VALIDATION}: qmd search "${collectionName}" returned ${fileCount} results, minimum is ${minCount}`);
return;
}
}
Expand Down