|
1 | | -# Charter Governance Check |
2 | | -# |
3 | | -# Drop this workflow into any repo with a .charter/ directory. |
4 | | -# It runs governance checks on every PR and posts results as annotations. |
5 | | -# |
6 | | -# Prerequisites: |
7 | | -# 1. Run `npx @stackbilt/cli setup --ci github` in your repo |
8 | | -# 2. Or copy this file to .github/workflows/governance.yml |
9 | | -# |
10 | | -# Configuration: |
11 | | -# Edit .charter/config.json to adjust thresholds and behavior. |
12 | | - |
13 | | -name: Governance Check |
14 | | - |
15 | | -on: |
16 | | - pull_request: |
17 | | - branches: [main, master] |
18 | | - |
19 | | -permissions: |
20 | | - contents: read |
21 | | - pull-requests: write |
22 | | - |
23 | | -jobs: |
24 | | - governance: |
25 | | - name: Charter |
26 | | - runs-on: ubuntu-latest |
27 | | - |
28 | | - steps: |
29 | | - - uses: actions/checkout@v4 |
30 | | - with: |
31 | | - fetch-depth: 0 # Full history needed for commit analysis |
32 | | - |
33 | | - - uses: pnpm/action-setup@v4 |
34 | | - if: hashFiles('pnpm-lock.yaml') != '' |
35 | | - |
36 | | - - uses: actions/setup-node@v4 |
37 | | - with: |
38 | | - node-version: '20' |
39 | | - cache: ${{ hashFiles('pnpm-lock.yaml') != '' && 'pnpm' || hashFiles('package-lock.json') != '' && 'npm' || '' }} |
40 | | - |
41 | | - - name: Install dependencies |
42 | | - run: | |
43 | | - if [ -f pnpm-lock.yaml ]; then |
44 | | - pnpm install --frozen-lockfile |
45 | | - elif [ -f package-lock.json ]; then |
46 | | - npm ci |
47 | | - else |
48 | | - npm install |
49 | | - fi |
50 | | -
|
51 | | - - name: Validate Commits |
52 | | - run: npx charter validate --ci --format text |
53 | | - |
54 | | - - name: Drift Scan |
55 | | - run: npx charter drift --ci --format text |
56 | | - if: hashFiles('.charter/patterns/*.json') != '' |
57 | | - |
58 | | - - name: ADF Evidence |
59 | | - run: npx charter adf evidence --auto-measure --ci --format text |
60 | | - if: hashFiles('.ai/manifest.adf') != '' |
61 | | - |
62 | | - - name: Audit Report |
63 | | - run: npx charter audit --format json > /tmp/audit.json |
64 | | - if: always() |
65 | | - |
66 | | - - name: Post Summary |
67 | | - if: always() |
68 | | - run: | |
69 | | - echo "## Charter Governance Report" >> $GITHUB_STEP_SUMMARY |
70 | | - echo "" >> $GITHUB_STEP_SUMMARY |
71 | | - if [ -f /tmp/audit.json ]; then |
72 | | - SCORE=$(cat /tmp/audit.json | jq -r '.score.overall') |
73 | | - echo "**Governance Score:** ${SCORE}/100" >> $GITHUB_STEP_SUMMARY |
74 | | - fi |
| 1 | +# Charter Governance |
| 2 | +# |
| 3 | +# Consolidated governance workflow for the Charter repo. |
| 4 | +# Replaces the former charter-governance.yml, governance.yml, and |
| 5 | +# governance-scorecard.yml to cut redundant CI runs. |
| 6 | +# |
| 7 | +# For consumer repos, `charter setup --ci github` generates |
| 8 | +# .github/workflows/charter-governance.yml (a lighter single-job variant). |
| 9 | + |
| 10 | +name: Governance |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + branches: [main, master] |
| 15 | + push: |
| 16 | + branches: [main] |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + pull-requests: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + governance: |
| 25 | + name: Charter Governance |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + |
| 33 | + - uses: pnpm/action-setup@v4 |
| 34 | + |
| 35 | + - uses: actions/setup-node@v4 |
| 36 | + with: |
| 37 | + node-version: '20' |
| 38 | + cache: 'pnpm' |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + run: pnpm install --frozen-lockfile |
| 42 | + |
| 43 | + - name: Validate Commits |
| 44 | + run: npx charter validate --ci --format text |
| 45 | + |
| 46 | + - name: Drift Scan |
| 47 | + run: npx charter drift --ci --format text |
| 48 | + if: hashFiles('.charter/patterns/*.json') != '' |
| 49 | + |
| 50 | + - name: ADF Wiring & Pointer Integrity |
| 51 | + run: npx charter doctor --adf-only --ci --format text |
| 52 | + if: hashFiles('.ai/manifest.adf') != '' |
| 53 | + |
| 54 | + - name: ADF Evidence |
| 55 | + run: npx charter adf evidence --auto-measure --ci --format text |
| 56 | + if: hashFiles('.ai/manifest.adf') != '' |
| 57 | + |
| 58 | + - name: Audit Report |
| 59 | + run: npx charter audit --format json > /tmp/audit.json |
| 60 | + if: always() |
| 61 | + |
| 62 | + - name: Post Summary |
| 63 | + if: always() |
| 64 | + run: | |
| 65 | + echo "## Charter Governance Report" >> $GITHUB_STEP_SUMMARY |
| 66 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 67 | + if [ -f /tmp/audit.json ]; then |
| 68 | + SCORE=$(cat /tmp/audit.json | jq -r '.score.overall') |
| 69 | + echo "**Governance Score:** ${SCORE}/100" >> $GITHUB_STEP_SUMMARY |
| 70 | + fi |
| 71 | +
|
| 72 | + scorecard: |
| 73 | + name: Governance Scorecard |
| 74 | + runs-on: ubuntu-latest |
| 75 | + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + |
| 80 | + - uses: pnpm/action-setup@v4 |
| 81 | + |
| 82 | + - uses: actions/setup-node@v4 |
| 83 | + with: |
| 84 | + node-version: '20' |
| 85 | + cache: 'pnpm' |
| 86 | + |
| 87 | + - run: pnpm install --frozen-lockfile |
| 88 | + |
| 89 | + - run: pnpm run build |
| 90 | + |
| 91 | + - name: Generate Charter JSON outputs |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + mkdir -p governance |
| 95 | + node packages/cli/dist/bin.js validate --ci --format json > governance/validate.json || true |
| 96 | + node packages/cli/dist/bin.js drift --ci --format json > governance/drift.json || true |
| 97 | + node packages/cli/dist/bin.js adf evidence --auto-measure --ci --format json > governance/evidence.json || true |
| 98 | +
|
| 99 | + - name: Build governance scorecard |
| 100 | + run: node scripts/generate-scorecard.mjs --repo digitalcsa-kit --source https://github.com/Stackbilt-dev/charter |
| 101 | + |
| 102 | + - name: Validate governance scorecard shape |
| 103 | + run: node scripts/validate-scorecard.mjs --file governance/scorecard.json |
| 104 | + |
| 105 | + - name: Upload scorecard artifact |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: governance-scorecard |
| 109 | + path: governance/scorecard.json |
0 commit comments