Commit ·
fdc9b46
1
Parent(s): 22e6c02
more tests
Browse files- .github/workflows/test.yml +85 -2
- GITHUB_ACTIONS_TESTS.md +124 -0
.github/workflows/test.yml
CHANGED
|
@@ -58,6 +58,13 @@ jobs:
|
|
| 58 |
python test_deviations.py
|
| 59 |
echo "status=$?" >> $GITHUB_OUTPUT
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
- name: Run AlignmentCheck dual dimensions test (optional)
|
| 62 |
id: test_alignment_dual_dimensions
|
| 63 |
continue-on-error: true
|
|
@@ -122,6 +129,49 @@ jobs:
|
|
| 122 |
exit $TEST_RESULT
|
| 123 |
fi
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
- name: Collect test results
|
| 126 |
id: results
|
| 127 |
if: always()
|
|
@@ -129,7 +179,7 @@ jobs:
|
|
| 129 |
FAILED=0
|
| 130 |
PASSED=0
|
| 131 |
SKIPPED=0
|
| 132 |
-
TOTAL=
|
| 133 |
FAILED_TESTS=""
|
| 134 |
|
| 135 |
# Core tests (always run)
|
|
@@ -161,6 +211,13 @@ jobs:
|
|
| 161 |
PASSED=$((PASSED + 1))
|
| 162 |
fi
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
# Optional tests (AlignmentCheck - requires API key)
|
| 165 |
# Test 1: AlignmentCheck dual dimensions
|
| 166 |
ALIGNMENT_DUAL_OUTCOME="${{ steps.test_alignment_dual_dimensions.outputs.outcome }}"
|
|
@@ -201,6 +258,32 @@ jobs:
|
|
| 201 |
FAILED_TESTS="${FAILED_TESTS}• test_alignment_check.py\n"
|
| 202 |
fi
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
# If no tests failed, set a default message
|
| 205 |
if [ -z "$FAILED_TESTS" ]; then
|
| 206 |
FAILED_TESTS="None"
|
|
@@ -282,7 +365,7 @@ jobs:
|
|
| 282 |
"type": "section",
|
| 283 |
"text": {
|
| 284 |
"type": "mrkdwn",
|
| 285 |
-
"text": "*Core Tests:*\n• test_data_disclosure_fix.py: ${{ steps.test_disclosure_fix.outcome }}\n• test_alignment_fix.py: ${{ steps.test_alignment_fix.outcome }}\n• test_user_provided_notification_contact.py: ${{ steps.test_notification_contact.outcome }}\n• test_deviations.py: ${{ steps.test_deviations.outcome }}\n\n*Optional Tests (require
|
| 286 |
}
|
| 287 |
},
|
| 288 |
{
|
|
|
|
| 58 |
python test_deviations.py
|
| 59 |
echo "status=$?" >> $GITHUB_OUTPUT
|
| 60 |
|
| 61 |
+
- name: Run PromptGuard scanner test
|
| 62 |
+
id: test_prompt_guard
|
| 63 |
+
continue-on-error: true
|
| 64 |
+
run: |
|
| 65 |
+
python test_prompt_guard_scanner.py
|
| 66 |
+
echo "status=$?" >> $GITHUB_OUTPUT
|
| 67 |
+
|
| 68 |
- name: Run AlignmentCheck dual dimensions test (optional)
|
| 69 |
id: test_alignment_dual_dimensions
|
| 70 |
continue-on-error: true
|
|
|
|
| 129 |
exit $TEST_RESULT
|
| 130 |
fi
|
| 131 |
|
| 132 |
+
- name: Run Native LlamaFirewall scanner test (optional)
|
| 133 |
+
id: test_native_llamafirewall
|
| 134 |
+
continue-on-error: true
|
| 135 |
+
env:
|
| 136 |
+
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
|
| 137 |
+
run: |
|
| 138 |
+
if [ -z "$TOGETHER_API_KEY" ]; then
|
| 139 |
+
echo "⏭️ Skipping Native LlamaFirewall test (TOGETHER_API_KEY not configured)"
|
| 140 |
+
echo "outcome=skipped" >> $GITHUB_OUTPUT
|
| 141 |
+
exit 0
|
| 142 |
+
fi
|
| 143 |
+
echo "Running Native LlamaFirewall scanner test..."
|
| 144 |
+
python test_native_llamafirewall_scanner.py
|
| 145 |
+
TEST_RESULT=$?
|
| 146 |
+
if [ $TEST_RESULT -eq 0 ]; then
|
| 147 |
+
echo "outcome=success" >> $GITHUB_OUTPUT
|
| 148 |
+
else
|
| 149 |
+
echo "outcome=failure" >> $GITHUB_OUTPUT
|
| 150 |
+
exit $TEST_RESULT
|
| 151 |
+
fi
|
| 152 |
+
|
| 153 |
+
- name: Run FactsChecker scanner test (optional)
|
| 154 |
+
id: test_facts_checker
|
| 155 |
+
continue-on-error: true
|
| 156 |
+
env:
|
| 157 |
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
| 158 |
+
run: |
|
| 159 |
+
if [ -z "$OPENAI_API_KEY" ]; then
|
| 160 |
+
echo "⏭️ Skipping FactsChecker test (OPENAI_API_KEY not configured)"
|
| 161 |
+
echo " To enable: Add OPENAI_API_KEY to GitHub repository secrets"
|
| 162 |
+
echo "outcome=skipped" >> $GITHUB_OUTPUT
|
| 163 |
+
exit 0
|
| 164 |
+
fi
|
| 165 |
+
echo "Running FactsChecker scanner test (7 tests including temporal awareness)..."
|
| 166 |
+
python test_facts_checker_scanner.py
|
| 167 |
+
TEST_RESULT=$?
|
| 168 |
+
if [ $TEST_RESULT -eq 0 ]; then
|
| 169 |
+
echo "outcome=success" >> $GITHUB_OUTPUT
|
| 170 |
+
else
|
| 171 |
+
echo "outcome=failure" >> $GITHUB_OUTPUT
|
| 172 |
+
exit $TEST_RESULT
|
| 173 |
+
fi
|
| 174 |
+
|
| 175 |
- name: Collect test results
|
| 176 |
id: results
|
| 177 |
if: always()
|
|
|
|
| 179 |
FAILED=0
|
| 180 |
PASSED=0
|
| 181 |
SKIPPED=0
|
| 182 |
+
TOTAL=5
|
| 183 |
FAILED_TESTS=""
|
| 184 |
|
| 185 |
# Core tests (always run)
|
|
|
|
| 211 |
PASSED=$((PASSED + 1))
|
| 212 |
fi
|
| 213 |
|
| 214 |
+
if [ "${{ steps.test_prompt_guard.outcome }}" != "success" ]; then
|
| 215 |
+
FAILED=$((FAILED + 1))
|
| 216 |
+
FAILED_TESTS="${FAILED_TESTS}• test_prompt_guard_scanner.py\n"
|
| 217 |
+
else
|
| 218 |
+
PASSED=$((PASSED + 1))
|
| 219 |
+
fi
|
| 220 |
+
|
| 221 |
# Optional tests (AlignmentCheck - requires API key)
|
| 222 |
# Test 1: AlignmentCheck dual dimensions
|
| 223 |
ALIGNMENT_DUAL_OUTCOME="${{ steps.test_alignment_dual_dimensions.outputs.outcome }}"
|
|
|
|
| 258 |
FAILED_TESTS="${FAILED_TESTS}• test_alignment_check.py\n"
|
| 259 |
fi
|
| 260 |
|
| 261 |
+
# Test 4: Native LlamaFirewall scanner test
|
| 262 |
+
NATIVE_LLAMAFIREWALL_OUTCOME="${{ steps.test_native_llamafirewall.outputs.outcome }}"
|
| 263 |
+
if [ "$NATIVE_LLAMAFIREWALL_OUTCOME" == "skipped" ]; then
|
| 264 |
+
SKIPPED=$((SKIPPED + 1))
|
| 265 |
+
elif [ "$NATIVE_LLAMAFIREWALL_OUTCOME" == "success" ]; then
|
| 266 |
+
PASSED=$((PASSED + 1))
|
| 267 |
+
TOTAL=$((TOTAL + 1))
|
| 268 |
+
elif [ "$NATIVE_LLAMAFIREWALL_OUTCOME" == "failure" ]; then
|
| 269 |
+
FAILED=$((FAILED + 1))
|
| 270 |
+
TOTAL=$((TOTAL + 1))
|
| 271 |
+
FAILED_TESTS="${FAILED_TESTS}• test_native_llamafirewall_scanner.py\n"
|
| 272 |
+
fi
|
| 273 |
+
|
| 274 |
+
# Test 5: FactsChecker scanner test
|
| 275 |
+
FACTS_CHECKER_OUTCOME="${{ steps.test_facts_checker.outputs.outcome }}"
|
| 276 |
+
if [ "$FACTS_CHECKER_OUTCOME" == "skipped" ]; then
|
| 277 |
+
SKIPPED=$((SKIPPED + 1))
|
| 278 |
+
elif [ "$FACTS_CHECKER_OUTCOME" == "success" ]; then
|
| 279 |
+
PASSED=$((PASSED + 1))
|
| 280 |
+
TOTAL=$((TOTAL + 1))
|
| 281 |
+
elif [ "$FACTS_CHECKER_OUTCOME" == "failure" ]; then
|
| 282 |
+
FAILED=$((FAILED + 1))
|
| 283 |
+
TOTAL=$((TOTAL + 1))
|
| 284 |
+
FAILED_TESTS="${FAILED_TESTS}• test_facts_checker_scanner.py\n"
|
| 285 |
+
fi
|
| 286 |
+
|
| 287 |
# If no tests failed, set a default message
|
| 288 |
if [ -z "$FAILED_TESTS" ]; then
|
| 289 |
FAILED_TESTS="None"
|
|
|
|
| 365 |
"type": "section",
|
| 366 |
"text": {
|
| 367 |
"type": "mrkdwn",
|
| 368 |
+
"text": "*Core Tests (5):*\n• test_data_disclosure_fix.py: ${{ steps.test_disclosure_fix.outcome }}\n• test_alignment_fix.py: ${{ steps.test_alignment_fix.outcome }}\n• test_user_provided_notification_contact.py: ${{ steps.test_notification_contact.outcome }}\n• test_deviations.py: ${{ steps.test_deviations.outcome }}\n• test_prompt_guard_scanner.py: ${{ steps.test_prompt_guard.outcome }}\n\n*Optional Tests (require API keys):*\n• test_alignment_dual_dimensions.py: ${{ steps.test_alignment_dual_dimensions.outputs.outcome }} (TOGETHER_API_KEY)\n• test_alignment_vs_factchecker.py: ${{ steps.test_alignment_vs_factchecker.outputs.outcome }} (TOGETHER_API_KEY)\n• test_alignment_check.py: ${{ steps.test_alignment_check.outputs.outcome }} (TOGETHER_API_KEY)\n• test_native_llamafirewall_scanner.py: ${{ steps.test_native_llamafirewall.outputs.outcome }} (TOGETHER_API_KEY)\n• test_facts_checker_scanner.py: ${{ steps.test_facts_checker.outputs.outcome }} (OPENAI_API_KEY)"
|
| 369 |
}
|
| 370 |
},
|
| 371 |
{
|
GITHUB_ACTIONS_TESTS.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GitHub Actions Test Suite
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
The test suite runs automatically on every push to `main` and on pull requests.
|
| 5 |
+
|
| 6 |
+
## Test Count: 10 Tests Total
|
| 7 |
+
|
| 8 |
+
### Core Tests (5) - Always Run
|
| 9 |
+
These tests run without requiring API keys:
|
| 10 |
+
1. ✅ `test_data_disclosure_fix.py` - DataDisclosureGuard false positive test
|
| 11 |
+
2. ✅ `test_alignment_fix.py` - DataDisclosureGuard alignment test
|
| 12 |
+
3. ✅ `test_user_provided_notification_contact.py` - User-provided notification contact test
|
| 13 |
+
4. ✅ `test_deviations.py` - Deviation/bias detection test
|
| 14 |
+
5. ✅ `test_prompt_guard_scanner.py` - PromptGuard scanner pattern-based detection (no API key needed)
|
| 15 |
+
|
| 16 |
+
### Optional Tests (5) - Require API Keys
|
| 17 |
+
These tests only run when the required API keys are configured in GitHub Secrets:
|
| 18 |
+
|
| 19 |
+
**Requires TOGETHER_API_KEY:**
|
| 20 |
+
6. ⚙️ `test_alignment_dual_dimensions.py` - AlignmentCheck dual dimensions test
|
| 21 |
+
7. ⚙️ `test_alignment_vs_factchecker.py` - AlignmentCheck vs FactChecker separation test
|
| 22 |
+
8. ⚙️ `test_alignment_check.py` - AlignmentCheck scanner test
|
| 23 |
+
9. ⚙️ `test_native_llamafirewall_scanner.py` - Native LlamaFirewall scanner test
|
| 24 |
+
|
| 25 |
+
**Requires OPENAI_API_KEY:**
|
| 26 |
+
10. ⚙️ `test_facts_checker_scanner.py` - FactsChecker scanner test (7 subtests including temporal awareness)
|
| 27 |
+
|
| 28 |
+
## Required GitHub Secrets
|
| 29 |
+
|
| 30 |
+
To run all 10 tests, configure these secrets in your repository:
|
| 31 |
+
|
| 32 |
+
### 1. TOGETHER_API_KEY ⚠️ REQUIRED FOR 4 TESTS
|
| 33 |
+
- Used by: AlignmentCheck tests (6, 7, 8) and Native LlamaFirewall test (9)
|
| 34 |
+
- Provider: [Together AI](https://api.together.xyz/)
|
| 35 |
+
- Purpose: Powers the AlignmentCheck scanner for behavioral drift detection
|
| 36 |
+
|
| 37 |
+
### 2. OPENAI_API_KEY ⚠️ REQUIRED FOR 1 TEST
|
| 38 |
+
- Used by: FactsChecker test (10)
|
| 39 |
+
- Provider: [OpenAI](https://platform.openai.com/)
|
| 40 |
+
- Purpose: Powers NeMo GuardRails fact-checking with GPT-4o-mini
|
| 41 |
+
|
| 42 |
+
## How to Add Secrets
|
| 43 |
+
|
| 44 |
+
1. Go to your GitHub repository
|
| 45 |
+
2. Navigate to: **Settings → Secrets and variables → Actions**
|
| 46 |
+
3. Click **"New repository secret"**
|
| 47 |
+
4. Add each secret:
|
| 48 |
+
- Name: `TOGETHER_API_KEY`
|
| 49 |
+
- Value: Your Together AI API key
|
| 50 |
+
- Click "Add secret"
|
| 51 |
+
|
| 52 |
+
- Name: `OPENAI_API_KEY`
|
| 53 |
+
- Value: Your OpenAI API key
|
| 54 |
+
- Click "Add secret"
|
| 55 |
+
|
| 56 |
+
## Test Results
|
| 57 |
+
|
| 58 |
+
The workflow will:
|
| 59 |
+
- ✅ **Pass**: If all running tests succeed (skipped tests don't cause failure)
|
| 60 |
+
- ❌ **Fail**: If any running test fails
|
| 61 |
+
- ⏭️ **Skip**: Optional tests without required API keys
|
| 62 |
+
|
| 63 |
+
### Slack Notifications
|
| 64 |
+
|
| 65 |
+
Both success and failure notifications are sent to Slack with:
|
| 66 |
+
- Total tests: X/10
|
| 67 |
+
- Tests passed, failed, and skipped
|
| 68 |
+
- Detailed per-test status with outcomes
|
| 69 |
+
- Links to workflow run and commit
|
| 70 |
+
|
| 71 |
+
## Adding New Tests
|
| 72 |
+
|
| 73 |
+
When adding a new test file, follow these steps:
|
| 74 |
+
|
| 75 |
+
1. **Create the test file** (e.g., `test_new_scanner.py`)
|
| 76 |
+
|
| 77 |
+
2. **Update `.github/workflows/test.yml`:**
|
| 78 |
+
- Add test execution step (with or without API key check)
|
| 79 |
+
- Update "Collect test results" section to count the new test
|
| 80 |
+
- Update Slack notification to list the new test
|
| 81 |
+
- Update `TOTAL=X` count if it's a core test
|
| 82 |
+
|
| 83 |
+
3. **Update this document:**
|
| 84 |
+
- Add test to the appropriate section (Core or Optional)
|
| 85 |
+
- Document any new required secrets
|
| 86 |
+
- Update the test count in the title
|
| 87 |
+
|
| 88 |
+
4. **Notify the team:**
|
| 89 |
+
- If new secrets are required, inform repository admins
|
| 90 |
+
- Document which provider and why the secret is needed
|
| 91 |
+
|
| 92 |
+
## Example: Adding a Test That Requires a New Secret
|
| 93 |
+
|
| 94 |
+
If you add a test requiring `ANTHROPIC_API_KEY`:
|
| 95 |
+
|
| 96 |
+
```yaml
|
| 97 |
+
- name: Run Claude scanner test (optional)
|
| 98 |
+
id: test_claude_scanner
|
| 99 |
+
continue-on-error: true
|
| 100 |
+
env:
|
| 101 |
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
| 102 |
+
run: |
|
| 103 |
+
if [ -z "$ANTHROPIC_API_KEY" ]; then
|
| 104 |
+
echo "⏭️ Skipping Claude scanner test (ANTHROPIC_API_KEY not configured)"
|
| 105 |
+
echo "outcome=skipped" >> $GITHUB_OUTPUT
|
| 106 |
+
exit 0
|
| 107 |
+
fi
|
| 108 |
+
python test_claude_scanner.py
|
| 109 |
+
TEST_RESULT=$?
|
| 110 |
+
if [ $TEST_RESULT -eq 0 ]; then
|
| 111 |
+
echo "outcome=success" >> $GITHUB_OUTPUT
|
| 112 |
+
else
|
| 113 |
+
echo "outcome=failure" >> $GITHUB_OUTPUT
|
| 114 |
+
exit $TEST_RESULT
|
| 115 |
+
fi
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
Then notify: "⚠️ New test added requiring `ANTHROPIC_API_KEY` from Claude AI"
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
**Last Updated:** 2026-02-07
|
| 123 |
+
**Total Tests:** 10 (5 core + 5 optional)
|
| 124 |
+
**Required Secrets:** 2 (TOGETHER_API_KEY, OPENAI_API_KEY)
|