-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduled-integration-tests.yml
More file actions
137 lines (117 loc) · 4.88 KB
/
scheduled-integration-tests.yml
File metadata and controls
137 lines (117 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Scheduled Integration Tests
on:
schedule:
# Run every day at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual triggering
jobs:
scheduled-integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run all integration tests
if: secrets.NUTRIENT_API_KEY != ''
env:
NUTRIENT_API_KEY: ${{ secrets.NUTRIENT_API_KEY }}
run: |
echo "Running scheduled integration tests to detect API changes..."
npm test -- --testPathPatterns="integration\.test\.ts$" --verbose --passWithNoTests
timeout-minutes: 20
continue-on-error: true
id: test-run
- name: Skip scheduled tests (no API key)
if: secrets.NUTRIENT_API_KEY == ''
run: |
echo "⏭️ Skipping scheduled integration tests - NUTRIENT_API_KEY not available"
echo "Configure NUTRIENT_API_KEY secret to enable scheduled API validation"
- name: Generate detailed test report
if: always()
run: |
npm test -- --json --outputFile=scheduled-test-results.json --testPathPatterns="integration\.test\.ts$" --passWithNoTests || true
# Create summary
echo "## Integration Test Summary" > test-summary.md
echo "Date: $(date)" >> test-summary.md
echo "Status: ${{ steps.test-run.outcome }}" >> test-summary.md
# Extract test counts if possible
if [ -f scheduled-test-results.json ]; then
echo "### Test Results" >> test-summary.md
node -e "
const results = require('./scheduled-test-results.json');
console.log('- Total Tests:', results.numTotalTests || 0);
console.log('- Passed:', results.numPassedTests || 0);
console.log('- Failed:', results.numFailedTests || 0);
console.log('- Skipped:', results.numPendingTests || 0);
" >> test-summary.md
fi
- name: Create issue if tests fail
if: failure() && steps.test-run.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const date = new Date().toISOString().split('T')[0];
const title = `🚨 Integration Tests Failed - ${date}`;
// Check if issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['integration-failure', 'automated'],
state: 'open'
});
const existingIssue = issues.data.find(issue => issue.title.includes(date));
if (!existingIssue) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: `## Scheduled Integration tests failed
The scheduled integration test run has detected failures. This could indicate:
- API changes that need to be addressed
- Service degradation
- Test flakiness
### Action Required
1. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details
2. Investigate any API changes
3. Update tests if needed
4. Close this issue once resolved
### Test Summary
See the workflow artifacts for detailed test results.`,
labels: ['integration-failure', 'automated', 'high-priority']
});
}
- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: scheduled-integration-results-${{ github.run_number }}
path: |
scheduled-test-results.json
test-summary.md
retention-days: 30
- name: Notify on success after previous failure
if: success() && steps.test-run.outcome == 'success'
uses: actions/github-script@v7
with:
script: |
// Close any open integration failure issues
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['integration-failure', 'automated'],
state: 'open'
});
for (const issue of issues.data) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
body: issue.body + '\n\n---\n\n✅ **Resolved**: Integration tests are now passing.'
});
}