Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
12 changes: 12 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Auto Assign
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
run:
uses: helpers4/.github/.github/workflows/reusable-auto-assign.yml@main
with:
assignees: baxyz
numOfAssignee: 1
2 changes: 1 addition & 1 deletion .github/workflows/job-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
node-version:
required: false
type: string
default: "lts"
default: "24"
artifact-name:
required: false
type: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/job-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
node-version:
required: false
type: string
default: "lts"
default: "24"
outputs:
status:
description: "Lint execution status"
Expand Down
138 changes: 138 additions & 0 deletions .github/workflows/job-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Job - PR Comment

on:
workflow_call:
inputs:
pr-number:
required: true
type: number
version-status:
required: true
type: string
build-status:
required: true
type: string
test-status:
required: true
type: string
lint-status:
required: true
type: string
typecheck-status:
required: true
type: string
commits-status:
required: true
type: string
verify-status:
required: true
type: string
coverage-lines:
required: true
type: string
coverage-branches:
required: true
type: string
coverage-functions:
required: true
type: string
coverage-statements:
required: true
type: string

jobs:
comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Post PR comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const jobs = [
['Version', '${{ inputs.version-status }}'],
['Build', '${{ inputs.build-status }}'],
['Tests', '${{ inputs.test-status }}'],
['Lint', '${{ inputs.lint-status }}'],
['TypeCheck', '${{ inputs.typecheck-status }}'],
['Commits', '${{ inputs.commits-status }}'],
['Verify', '${{ inputs.verify-status }}']
]

const coverage = {
lines: parseFloat('${{ inputs.coverage-lines }}') || 0,
branches: parseFloat('${{ inputs.coverage-branches }}') || 0,
functions: parseFloat('${{ inputs.coverage-functions }}') || 0,
statements: parseFloat('${{ inputs.coverage-statements }}') || 0
}

const icon = (status) => {
const icons = { success: '✅', failure: '❌', skipped: '⏭️' }
return icons[status] || '⚠️'
}

const badge = (status) => {
const badges = { success: 'passing', failure: 'failing', skipped: 'skipped' }
return badges[status] || 'unknown'
}

const jobRows = jobs.map(([name, status]) =>
'| ' + icon(status) + ' | **' + name + '** | ' + badge(status) + ' |'
).join('\n')

const covIcon = (val) => {
if (val >= 100) return '✅'
if (val >= 90) return '🟢'
if (val >= 80) return '🟡'
if (val >= 60) return '🟠'
return '🔴'
}

const covRows = [
'| ' + covIcon(coverage.lines) + ' | **Lines** | ' + coverage.lines + '% |',
'| ' + covIcon(coverage.branches) + ' | **Branches** | ' + coverage.branches + '% |',
'| ' + covIcon(coverage.functions) + ' | **Functions** | ' + coverage.functions + '% |',
'| ' + covIcon(coverage.statements) + ' | **Statements** | ' + coverage.statements + '% |'
].join('\n')

const passed = jobs.filter(([_, s]) => s === 'success').length
const total = jobs.length
const allPassed = passed === total
const avgCov = ((coverage.lines + coverage.branches + coverage.functions + coverage.statements) / 4).toFixed(1)
const covOk = parseFloat(avgCov) >= 100

const banner = allPassed && covOk
? '## ✅ PR Validation Passed'
: allPassed
? '## 🟡 PR Validation Passed • Coverage ' + avgCov + '% (target: 100%)'
: '## ❌ PR Validation Failed'

const comment = banner + '\n\n---\n\n### Pipeline Status\n\n| | Job | Status |\n|:---:|-----|:------:|\n' + jobRows + '\n\n---\n\n### Code Coverage\n\n| | Metric | Coverage |\n|:---:|--------|:--------:|\n' + covRows + '\n\n---\n\n*Generated by @helpers4 CI*'

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.pr-number }},
})

const bot = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Pipeline Status')
)

if (bot) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: bot.id,
body: comment
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.pr-number }},
body: comment
})
}
38 changes: 18 additions & 20 deletions .github/workflows/job-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
node-version:
required: false
type: string
default: "lts"
default: "24"
coverage:
required: false
type: boolean
Expand Down Expand Up @@ -76,22 +76,20 @@ jobs:
id: coverage
if: inputs.coverage == true
run: |
node -e "
const fs = require('fs');
const path = 'coverage/coverage-summary.json';
if (!fs.existsSync(path)) {
console.log('Coverage summary not found');
process.exit(1);
}
const summary = JSON.parse(fs.readFileSync(path, 'utf8'));
const total = summary.total || {};
const getPct = (key) => (total[key] && typeof total[key].pct === 'number') ? total[key].pct : 0;
const lines = getPct('lines');
const branches = getPct('branches');
const functions = getPct('functions');
const statements = getPct('statements');
fs.appendFileSync(process.env.GITHUB_OUTPUT, `lines=${lines}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `branches=${branches}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `functions=${functions}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `statements=${statements}\n`);
"
COVERAGE_FILE="coverage/coverage-summary.json"

if [ ! -f "$COVERAGE_FILE" ]; then
echo "Coverage summary not found"
exit 1
fi

TOTAL=$(jq '.total' "$COVERAGE_FILE")
LINES=$(echo "$TOTAL" | jq '.lines.pct // 0')
BRANCHES=$(echo "$TOTAL" | jq '.branches.pct // 0')
FUNCTIONS=$(echo "$TOTAL" | jq '.functions.pct // 0')
STATEMENTS=$(echo "$TOTAL" | jq '.statements.pct // 0')

echo "lines=$LINES" >> $GITHUB_OUTPUT
echo "branches=$BRANCHES" >> $GITHUB_OUTPUT
echo "functions=$FUNCTIONS" >> $GITHUB_OUTPUT
echo "statements=$STATEMENTS" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/workflows/job-typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
node-version:
required: false
type: string
default: "lts"
default: "24"
outputs:
status:
description: "TypeCheck execution status"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/job-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
node-version:
required: false
type: string
default: "lts"
default: "24"
build-artifact:
required: true
type: string
Expand Down
Loading