Skip to content
Merged
120 changes: 120 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Integration Tests

on:
push:
branches:
- main
- heretto
paths:
- 'src/heretto*.js'
- '.github/workflows/integration-tests.yml'
pull_request:
branches:
- main
paths:
- 'src/heretto*.js'
- '.github/workflows/integration-tests.yml'
workflow_dispatch:
# Allow manual triggering for testing
schedule:
# Run daily at 6:00 AM UTC to catch any API changes
- cron: '0 6 * * *'

jobs:
heretto-integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
# Only run if secrets are available (not available on fork PRs)
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci

- name: Run integration tests
env:
CI: 'true'
HERETTO_ORGANIZATION_ID: ${{ secrets.HERETTO_ORGANIZATION_ID }}
HERETTO_USERNAME: ${{ secrets.HERETTO_USERNAME }}
HERETTO_API_TOKEN: ${{ secrets.HERETTO_API_TOKEN }}
# HERETTO_SCENARIO_NAME is optional - defaults to 'Doc Detective' in the application
HERETTO_SCENARIO_NAME: ${{ secrets.HERETTO_SCENARIO_NAME }}
run: npm run test:integration

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-results
path: |
test-results/
*.log
retention-days: 7

notify-on-failure:
runs-on: ubuntu-latest
needs: heretto-integration-tests
if: failure() && github.event_name == 'schedule'
steps:
- name: Create issue on failure
uses: actions/github-script@v7
with:
script: |
const title = '🚨 Heretto Integration Tests Failed';
const body = `
## Integration Test Failure

The scheduled Heretto integration tests have failed.

**Workflow Run:** [View Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
**Triggered:** ${{ github.event_name }}
**Branch:** ${{ github.ref_name }}

Please investigate and fix the issue.

### Possible Causes
- Heretto API changes
- Expired or invalid API credentials
- Network connectivity issues
- Changes in test scenario configuration

/cc @${{ github.repository_owner }}
`;

// Check if an open issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'integration-test-failure'
});

const existingIssue = issues.data.find(issue => issue.title === title);

if (!existingIssue) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['bug', 'integration-test-failure', 'automated']
});
} else {
// Add a comment to the existing issue
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `Another failure detected on ${new Date().toISOString()}\n\n[Workflow Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`
});
}
114 changes: 73 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "Detect and resolve docs into Doc Detective tests.",
"main": "src/index.js",
"scripts": {
"test": "mocha src/*.test.js",
"test": "mocha src/*.test.js --ignore src/*.integration.test.js",
"test:integration": "mocha src/*.integration.test.js --timeout 600000",
"test:all": "mocha src/*.test.js --timeout 600000",
"dev": "node dev"
},
"repository": {
Expand All @@ -28,19 +30,20 @@
"adm-zip": "^0.5.16",
"ajv": "^8.17.1",
"axios": "^1.13.2",
"doc-detective-common": "3.6.0-dev.1",
"doc-detective-common": "^3.6.0-dev.2",
"dotenv": "^17.2.3",
"fast-xml-parser": "^5.3.3",
"json-schema-faker": "^0.5.9",
"posthog-node": "^5.17.2"
"posthog-node": "^5.18.1"
},
"devDependencies": {
"body-parser": "^2.2.1",
"chai": "^6.2.1",
"chai": "^6.2.2",
"express": "^5.2.1",
"mocha": "^11.7.5",
"proxyquire": "^2.1.3",
"semver": "^7.7.3",
"sinon": "^21.0.0",
"sinon": "^21.0.1",
"yaml": "^2.8.2"
}
}
Loading
Loading