Skip to content

Commit b098c4a

Browse files
committed
[FEATURE] set up tests to validate imports work for all app
1 parent e67dd18 commit b098c4a

File tree

4 files changed

+633
-15
lines changed

4 files changed

+633
-15
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Daily Package Validation Report
2+
3+
on:
4+
schedule:
5+
# Run daily at midnight UTC
6+
- cron: '0 0 * * *'
7+
workflow_dispatch: # Allow manual triggering for testing
8+
push:
9+
branches: [ fix-test-imports ] # Temporary: for testing only
10+
11+
jobs:
12+
validate-packages:
13+
name: Generate Package Validation Report
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4.1.7
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v4.0.0
22+
with:
23+
version: 9.14.2
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4.0.3
27+
with:
28+
node-version: 18
29+
cache: 'pnpm'
30+
31+
- name: Install dependencies
32+
run: pnpm install -r --no-frozen-lockfile
33+
34+
- name: Compile TypeScript
35+
run: pnpm run build
36+
37+
- name: Run Package Validation Report
38+
id: validation
39+
run: |
40+
node scripts/generate-package-report.js --report-only --verbose --output=validation-report.json > validation-report.txt 2>&1
41+
echo "validation_exit_code=$?" >> $GITHUB_OUTPUT
42+
continue-on-error: true
43+
44+
- name: Upload Validation Report
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: package-validation-report-${{ github.run_number }}
48+
path: |
49+
validation-report.txt
50+
validation-report.json
51+
retention-days: 30
52+
53+
- name: Create Issue on Failures
54+
if: steps.validation.outputs.validation_exit_code != '0'
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
const fs = require('fs');
59+
60+
// Read JSON report for structured data
61+
let reportData = null;
62+
let failedCount = 0;
63+
let summaryText = '';
64+
65+
try {
66+
const jsonReport = fs.readFileSync('validation-report.json', 'utf8');
67+
reportData = JSON.parse(jsonReport);
68+
failedCount = reportData.summary.failed;
69+
summaryText = `
70+
📊 **Summary:**
71+
- Total Components: ${reportData.summary.total}
72+
- ✅ Validated: ${reportData.summary.validated}
73+
- ❌ Failed: ${reportData.summary.failed}
74+
- ⏭️ Skipped: ${reportData.summary.skipped}
75+
- 📈 Publishable: ${reportData.summary.publishable}
76+
- 📉 Failure Rate: ${reportData.summary.failureRate}%
77+
`;
78+
} catch (error) {
79+
// Fallback to text report
80+
const report = fs.readFileSync('validation-report.txt', 'utf8');
81+
const failedPackages = report.match(/❌.*FAILED:/g) || [];
82+
failedCount = failedPackages.length;
83+
summaryText = `Failed to parse JSON report. Found ${failedCount} failures in text report.`;
84+
}
85+
86+
if (failedCount > 0) {
87+
// Generate failed packages list
88+
let failedPackagesList = '';
89+
if (reportData && reportData.failed) {
90+
const topFailures = reportData.failed.slice(0, 10);
91+
failedPackagesList = topFailures.map(pkg =>
92+
`- **${pkg.packageName}** (${pkg.app}): ${pkg.failures.map(f => f.check).join(', ')}`
93+
).join('\n');
94+
if (reportData.failed.length > 10) {
95+
failedPackagesList += `\n- ... and ${reportData.failed.length - 10} more packages`;
96+
}
97+
} else {
98+
failedPackagesList = 'See full report for details.';
99+
}
100+
101+
const issueBody = `
102+
# 📦 Daily Package Validation Report - ${new Date().toDateString()}
103+
104+
${summaryText}
105+
106+
## 🔗 Links
107+
- **Workflow Run**: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
108+
- **Download Reports**: Check the workflow artifacts for detailed JSON and text reports
109+
110+
## ❌ Failed Packages
111+
${failedPackagesList}
112+
113+
## Full Report
114+
The complete validation report is available as an artifact in the workflow run.
115+
116+
## Next Steps
117+
1. Review the failed packages listed above
118+
2. Check the full validation report artifact
119+
3. Fix import/dependency issues in failing packages
120+
4. Consider updating the validation criteria if needed
121+
122+
---
123+
*This issue was automatically created by the daily package validation workflow.*
124+
`;
125+
126+
// Check if there's already an open issue for today
127+
const { data: issues } = await github.rest.issues.listForRepo({
128+
owner: context.repo.owner,
129+
repo: context.repo.repo,
130+
labels: ['package-validation', 'automated'],
131+
state: 'open'
132+
});
133+
134+
const today = new Date().toDateString();
135+
const existingIssue = issues.find(issue =>
136+
issue.title.includes(today) &&
137+
issue.title.includes('Package Validation Report')
138+
);
139+
140+
if (existingIssue) {
141+
// Update existing issue
142+
await github.rest.issues.createComment({
143+
owner: context.repo.owner,
144+
repo: context.repo.repo,
145+
issue_number: existingIssue.number,
146+
body: `## Updated Report - Run #${{ github.run_number }}
147+
148+
${issueBody}`
149+
});
150+
} else {
151+
// Create new issue
152+
await github.rest.issues.create({
153+
owner: context.repo.owner,
154+
repo: context.repo.repo,
155+
title: `📦 Package Validation Report - ${today} - ${failedCount} failures`,
156+
body: issueBody,
157+
labels: ['package-validation', 'automated', 'bug']
158+
});
159+
}
160+
}
161+
162+
- name: Post Success Summary
163+
if: steps.validation.outputs.validation_exit_code == '0'
164+
run: |
165+
echo "🎉 All packages validated successfully!"
166+
echo "Daily validation completed with no issues."

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
"platform-test": "cd platform && npm test",
3737
"types-test": "cd types && npm test",
3838
"helpers-test": "cd helpers && npm test",
39-
"build:docs": "cd docs-v2 && pnpm install --ignore-engines && pnpm build"
39+
"build:docs": "cd docs-v2 && pnpm install --ignore-engines && pnpm build",
40+
"validate:packages": "node scripts/generate-package-report.js",
41+
"validate:packages:verbose": "node scripts/generate-package-report.js --verbose",
42+
"validate:packages:report": "node scripts/generate-package-report.js --report-only --output=package-validation-report.json",
43+
"validate:packages:dry-run": "node scripts/generate-package-report.js --dry-run",
44+
"validate:package": "node scripts/generate-package-report.js --package="
4045
},
4146
"devDependencies": {
4247
"@eslint/eslintrc": "^3.2.0",

pnpm-lock.yaml

Lines changed: 6 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)