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
93 changes: 93 additions & 0 deletions .github/workflows/test-hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Hook Tests

on:
pull_request:
paths:
- 'scripts/hooks/**'
- 'tests/hooks/**'
- '.github/workflows/test-hooks.yml'
push:
branches:
- main
paths:
- 'scripts/hooks/**'
- 'tests/hooks/**'

jobs:
test-hooks:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Pester
shell: pwsh
run: |
Write-Host "Installing Pester module..." -ForegroundColor Cyan
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 5.0
Write-Host "Pester installed successfully" -ForegroundColor Green

- name: Run Hook Tests
shell: pwsh
run: |
Write-Host "=== Running V12 Hook Tests ===" -ForegroundColor Cyan
powershell -File tests/hooks/Run-HookTests.ps1 -Detailed

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: hook-test-results
path: tests/hooks/TestResults.xml
retention-days: 30

- name: Verify Hook Compliance
shell: pwsh
run: |
Write-Host "=== Verifying V12 DNA Compliance ===" -ForegroundColor Cyan
powershell -File scripts/verify_hooks.ps1

- name: Comment Test Results on PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const testResultsPath = 'tests/hooks/TestResults.xml';

let comment = '## 🔗 Hook Test Results\n\n';

if (fs.existsSync(testResultsPath)) {
const testResults = fs.readFileSync(testResultsPath, 'utf8');
const passedMatch = testResults.match(/passed="(\d+)"/);
const failedMatch = testResults.match(/failed="(\d+)"/);
const skippedMatch = testResults.match(/skipped="(\d+)"/);

const passed = passedMatch ? passedMatch[1] : '0';
const failed = failedMatch ? failedMatch[1] : '0';
const skipped = skippedMatch ? skippedMatch[1] : '0';

comment += `- ✅ Passed: ${passed}\n`;
comment += `- ❌ Failed: ${failed}\n`;
comment += `- ⏭️ Skipped: ${skipped}\n\n`;

if (failed === '0') {
comment += '**Status:** All hook tests passed! ✅\n';
} else {
comment += '**Status:** Some hook tests failed. Please review the test results. ❌\n';
}
} else {
comment += '⚠️ Test results file not found.\n';
}

comment += '\n📊 [View detailed test results in artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})';

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});

# Made with Bob
Loading
Loading