Skip to content

Update README.md - #54

Open
xiaunknown116-del wants to merge 1 commit into
cloudflare:mainfrom
xiaunknown116-del:patch-2
Open

Update README.md#54
xiaunknown116-del wants to merge 1 commit into
cloudflare:mainfrom
xiaunknown116-del:patch-2

Conversation

@xiaunknown116-del

Copy link
Copy Markdown

Here is your complete, production-ready ecosystem layout. It contains the unified workflow file alongside the structural configurations required to natively execute layout formatting and test evaluation processes inside your engineering pipelines.

🏛️ Complete Repository Update

apex-platform-engine/
├── .github/
│ └── workflows/
│ └── pr-gate.yml # Unified Status Gate Workflow (Live Multi-Channel Metrics)
├── .prettierrc # Prettier Layout Standards Engine Configuration
├── package.json # Project Manifest & Vitest Coverage Script Map
├── tsconfig.json # TypeScript Compiler Constraints
└── vitest.config.ts # Test Engine & JSON Summary Coverage Exporter


🚨 1. The Production Workflow (.github/workflows/pr-gate.yml)

Create this file to completely orchestrate file filtering, auto-formatting, type validation, coverage parsing, and multi-channel notification dispatches.

name: Pull Request Quality Gateon:
pull_request:
branches:
- main
paths-ignore:
- "README.md"
- ".gitignore"
- "docs/**"
jobs:
quality_check:
name: Code Quality & Testing Suite
runs-on: ubuntu-latest
permissions:
contents: write # Crucial requirement to allow auto-commits to the branch
steps:
- name: Checkout Code Base
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }} # Check out the actual head branch instead of the merge commit

  - name: Setup Node.js Environment
    uses: actions/setup-node@v4
    with:
      node-version: 20
      cache: 'npm'

  - name: Install Project Dependencies
    run: npm ci

  # ─── AUTO-FORMATTING PHASE ──────────────────────────────────────────
  - name: Identify Changed Files
    id: changed-files
    uses: tj-actions/changed-files@v45
    with:
      files: |
        src/**/*.ts
        website/**/*.html
        website/**/*.css
  - name: Run Prettier Auto-Fix
    if: steps.changed-files.outputs.any_changed == 'true'
    run: npx prettier --write ${{ steps.changed-files.outputs.all_changed_files }}

  - name: Auto-Commit Prettier Fixes
    uses: stefanzweifel/git-auto-commit-action@v5
    with:
      commit_message: "style: automated prettier code formatting updates"
      file_pattern: "src/**/* website/**/*"

  # ─── VALIDATION PHASE ───────────────────────────────────────────────
  - name: Verify TypeScript Compilation Errors
    run: npx tsc --noEmit

  - name: Execute Vitest with Code Coverage Summary
    run: npm run test -- --coverage

  # ─── PARSE COVERAGE METRICS FOR ALERTS ──────────────────────────────
  - name: Parse Coverage Summary JSON
    id: coverage_metrics
    if: success()
    run: |
      # Read total percentage metrics directly from vitest generated summary json
      LINES_PCT=$(node -p "require('./coverage/coverage-summary.json').total.lines.pct")
      FUNCTIONS_PCT=$(node -p "require('./coverage/coverage-summary.json').total.functions.pct")
      BRANCHES_PCT=$(node -p "require('./coverage/coverage-summary.json').total.branches.pct")
      
      echo "lines=${LINES_PCT}%" >> $GITHUB_OUTPUT
      echo "functions=${FUNCTIONS_PCT}%" >> $GITHUB_OUTPUT
      echo "branches=${BRANCHES_PCT}%" >> $GITHUB_OUTPUT
  # ─── SUCCESS NOTIFICATION DISPATCH (WITH METRICS) ───────────────────
  - name: Dispatch Slack Success Alert
    if: success()
    uses: slackapi/slack-github-action@v4.0.0
    with:
      webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
      webhook-type: incoming-webhook
      payload: |
        {
          "text": "✅ *PR Quality Gate Passed!*\n*Repository:* ${{ github.repository }}\n*Triggered By:* ${{ github.actor }}\n\n📊 *Vitest Code Coverage Summary:*\n• *Lines:* ${{ steps.coverage_metrics.outputs.lines }}\n• *Functions:* ${{ steps.coverage_metrics.outputs.functions }}\n• *Branches:* ${{ steps.coverage_metrics.outputs.branches }}\n\n*Action logs:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
        }
  - name: Dispatch Discord Success Alert
    if: success()
    uses: illoopp/discord-webhook-notify@v1
    with:
      webhookUrl: ${{ secrets.DISCORD_WEBHOOK_URL }}
      avatarUrl: https://githubassets.com
      username: GitHub Actions
      title: "✅ PR Quality Gate Passed"
      description: "All validation metrics successfully cleared.\n\n**📊 Code Coverage:**\n• **Lines:** ${{ steps.coverage_metrics.outputs.lines }}\n• **Functions:** ${{ steps.coverage_metrics.outputs.functions }}\n• **Branches:** ${{ steps.coverage_metrics.outputs.branches }}"
      color: 0x2ecc71
      url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

  # ─── FAILURE NOTIFICATION DISPATCH ──────────────────────────────────
  - name: Dispatch Slack Failure Alert
    if: failure()
    uses: slackapi/slack-github-action@v4.0.0
    with:
      webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
      webhook-type: incoming-webhook
      payload: |
        {
          "text": "🚨 *PR Quality Gate Failed!* \n*Repository:* ${{ github.repository }} \n*Triggered By:* ${{ github.actor }} \n*Action logs:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
        }
  - name: Dispatch Discord Failure Alert
    if: failure()
    uses: illoopp/discord-webhook-notify@v1
    with:
      webhookUrl: ${{ secrets.DISCORD_WEBHOOK_URL }}
      avatarUrl: https://githubassets.com
      username: GitHub Actions
      title: "🚨 PR Quality Gate Interrupted"
      description: "Validation failed on main branch tracking. Review run execution parameters immediately."
      color: 0xef7777
      url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

🎨 2. Code Style Configurations (.prettierrc)

Place this configuration file at the root level of your project directory to dictate structural formatting parameters natively:

{
"semi": true,
"trailingComma": "none",
"singleQuote": false,
"tabWidth": 2,
"printWidth": 100,
"bracketSpacing": true,
"arrowParens": "always"
}


🧪 3. Vitest Exporter Integration (vitest.config.ts)

Ensure your testing framework configures and exports the json-summary coverage metric database consumed by the step pipeline:

import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
provider: "v8", // or 'istanbul'
reporter: ["text", "json-summary"],
reportOnFailure: true,
thresholds: {
lines: 80, // Optional: Fails test execution if total coverage dips below 80%
functions: 80,
branches: 80
}
}
}
});


📦 4. Application Dependency Map (package.json)

Ensure your test target keys inside your manifest scripts are configured to enable coverage tracking correctly:

{
"name": "apex-platform-engine",
"version": "1.0.0",
"scripts": {
"test": "vitest run",
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"@vitest/coverage-v8": "^2.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0",
"vitest": "^2.0.0"
}
}

If you're ready to deploy, let me know:

  • Do you need help generating an empty mock test (src/index.test.ts) to verify that the pipeline runs successfully on your first push?
  • Should we set up GitHub branch protection rules to block developers from manually merging PRs before this quality gate turns green?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant