Skip to content
Open
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
80 changes: 80 additions & 0 deletions .github/hiero-automation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"maintainerTeam": "@hiero-ledger/hiero-website-maintainers",
"goodFirstIssueSupportTeam": "@hiero-ledger/hiero-website-good-first-issue-support",

"labels": {
"status": {
"awaitingTriage": "status: awaiting triage",
"readyForDev": "status: ready for dev",
"inProgress": "status: in progress",
"blocked": "status: blocked",
"needsReview": "status: needs review",
"needsRevision": "status: needs revision"
},
"skill": {
"goodFirstIssue": "skill: good first issue",
"beginner": "skill: beginner",
"intermediate": "skill: intermediate",
"advanced": "skill: advanced"
},
"priority": {
"critical": "priority: critical",
"high": "priority: high",
"medium": "priority: medium",
"low": "priority: low"
}
},

"skillHierarchy": [
"skill: good first issue",
"skill: beginner",
"skill: intermediate",
"skill: advanced"
],

"priorityHierarchy": [
"priority: critical",
"priority: high",
"priority: medium",
"priority: low"
],

"skillPrerequisites": {
"skill: good first issue": {
"requiredLabel": null,
"requiredCount": 0,
"displayName": "Good First Issue"
},
"skill: beginner": {
"requiredLabel": "skill: good first issue",
"requiredCount": 2,
"displayName": "Beginner",
"prerequisiteDisplayName": "Good First Issues"
},
"skill: intermediate": {
"requiredLabel": "skill: beginner",
"requiredCount": 3,
"displayName": "Intermediate",
"prerequisiteDisplayName": "Beginner Issues"
},
"skill: advanced": {
"requiredLabel": "skill: intermediate",
"requiredCount": 3,
"displayName": "Advanced",
"prerequisiteDisplayName": "Intermediate Issues"
}
},

"assignmentLimits": {
"maxOpenAssignments": 2,
"maxGfiCompletions": 5
},

"documentation": {
"workflowGuide": "https://github.com/hiero-ledger/hiero-website/blob/main/docs/training/workflow.md"
},

"community": {
"discordChannel": "https://discord.com/channels/905194001349627914/1458790070986215567"
}
}
75 changes: 75 additions & 0 deletions .github/scripts/bot-on-pr-open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: Apache-2.0
//
// bot-on-pr-open.js
//
// Runs when a PR is opened, reopened, or converted from draft (ready_for_review).
// Performs all 4 checks (DCO, GPG, merge conflict, issue link), posts/updates
// the unified dashboard comment, auto-assigns the author, and applies the
// appropriate status label.

import {
createLogger,
buildBotContext,
addAssignees,
requireSafeUsername,
runAllChecksAndComment,
swapStatusLabel,
} from './helpers.js';

const logger = createLogger('on-pr-open');

/**
* Auto-assigns the PR author if not already assigned.
* @param {object} botContext
*/
async function autoAssignAuthor(botContext) {
const prAuthor = botContext.pr?.user?.login;
if (!prAuthor) {
logger.log('Exit: missing pull request author');
return;
}
try {
requireSafeUsername(prAuthor, 'pr.author');
} catch (err) {
logger.log('Exit: invalid pr.author', err.message);
return;
}

const currentAssignees = botContext.pr?.assignees || [];
const isAlreadyAssigned = currentAssignees.some(
(a) => (a?.login || '').toLowerCase() === prAuthor.toLowerCase()
);
if (isAlreadyAssigned) {
logger.log(`Author ${prAuthor} is already assigned`);
return;
}
await addAssignees(botContext, [prAuthor]);
}

export default async ({ github, context }) => {

Check warning on line 49 in .github/scripts/bot-on-pr-open.js

View workflow job for this annotation

GitHub Actions / build-and-test

Assign arrow function to a variable before exporting as module default
try {
const botContext = buildBotContext({ github, context });

await autoAssignAuthor(botContext);

if (botContext.pr?.user?.type === 'Bot') {
logger.log('Skipping bot-authored PR');
return;
}

const { allPassed } = await runAllChecksAndComment(botContext);
const result = await swapStatusLabel(botContext, allPassed, { force: true });

if (!result.success) {
logger.error(`Failed to swap status label: ${result.errorDetails}`);
}

logger.log('On-PR-open bot completed');
} catch (error) {
logger.error('Error:', {
message: error.message,
number: context?.payload?.pull_request?.number,
});
throw error;
}
};
48 changes: 48 additions & 0 deletions .github/scripts/bot-on-pr-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: Apache-2.0
//
// bot-on-pr-update.js
//
// Runs on new commits (synchronize) and PR body edits (edited). Performs all
// 4 checks (DCO, GPG, merge conflict, issue link), posts/updates the unified
// dashboard comment, and conditionally swaps the status label.
// For edited events, exits early if only the title or base branch changed.

import {
createLogger,
buildBotContext,
swapStatusLabel,
runAllChecksAndComment,
} from './helpers.js';

const logger = createLogger('on-pr-update');

export default async ({ github, context }) => {

Check warning on line 19 in .github/scripts/bot-on-pr-update.js

View workflow job for this annotation

GitHub Actions / build-and-test

Assign arrow function to a variable before exporting as module default
try {
const botContext = buildBotContext({ github, context });

if (botContext.pr?.user?.type === 'Bot') {
logger.log('Skipping bot-authored PR');
return;
}

// Edits can be triggered by title changes, but we only care about body changes.
if (context.payload.action === 'edited' && !context.payload.changes?.body) {
logger.log('Body not changed, skipping');
return;
}

const { allPassed } = await runAllChecksAndComment(botContext);
const result = await swapStatusLabel(botContext, allPassed);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Force status-label reconciliation on update events.

Line 35 calls swapStatusLabel without force, so PRs missing both status labels won’t recover a status label on synchronize/edited events.

Suggested fix
-    const result = await swapStatusLabel(botContext, allPassed);
+    const result = await swapStatusLabel(botContext, allPassed, { force: true });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const result = await swapStatusLabel(botContext, allPassed);
const result = await swapStatusLabel(botContext, allPassed, { force: true });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/bot-on-pr-update.js at line 35, The PR update handler calls
swapStatusLabel(botContext, allPassed) without forcing reconciliation, so PRs
that lack both status labels won't get fixed on synchronize/edited events;
update the call in .github/scripts/bot-on-pr-update.js to pass the force flag
(e.g., swapStatusLabel(botContext, allPassed, true) or the equivalent third
argument expected by swapStatusLabel) so the function runs a forced
reconciliation of labels when handling update events.

if (!result.success) {
logger.error(`Failed to swap status label: ${result.errorDetails}`);
}

logger.log('On-PR-update bot completed');
} catch (error) {
logger.error('Error:', {
message: error.message,
number: context?.payload?.pull_request?.number,
});
throw error;
}
};
Loading