Skip to content

increase major version #6

increase major version

increase major version #6

name: Scheduled Integration Tests

Check failure on line 1 in .github/workflows/scheduled-integration-tests.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/scheduled-integration-tests.yml

Invalid workflow file

(Line: 27, Col: 11): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.NUTRIENT_API_KEY != '', (Line: 38, Col: 11): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.NUTRIENT_API_KEY == ''
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: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
pip install ".[dev]"
- 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..."
python -m pytest tests/test_integration.py -v --tb=short
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: |
python -m pytest tests/test_integration.py -v --tb=short --junit-xml=scheduled-test-results.xml || 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.xml ]; then
echo "### Test Results" >> test-summary.md
python -c "
import xml.etree.ElementTree as ET
import os
if os.path.exists('scheduled-test-results.xml'):
tree = ET.parse('scheduled-test-results.xml')
root = tree.getroot()
tests = root.get('tests', '0')
failures = root.get('failures', '0')
errors = root.get('errors', '0')
skipped = root.get('skipped', '0')
passed = str(int(tests) - int(failures) - int(errors) - int(skipped))
print(f'- Total Tests: {tests}')
print(f'- Passed: {passed}')
print(f'- Failed: {failures}')
print(f'- Errors: {errors}')
print(f'- Skipped: {skipped}')
" >> 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.xml
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'
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: '✅ **Resolved**: Integration tests are now passing.'
});
}