Skip to content

Commit bec5914

Browse files
authored
Fix dependency issues in documentation-review.yml
1 parent 37f4046 commit bec5914

File tree

1 file changed

+20
-62
lines changed

1 file changed

+20
-62
lines changed

.github/workflows/documentation-review.yml

Lines changed: 20 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ jobs:
1818
uses: actions/setup-node@v4
1919
with:
2020
node-version: '18'
21-
cache: 'npm'
22-
cache-dependency-path: 'docusaurus/package-lock.json'
2321

2422
- name: Install dependencies
2523
run: |
2624
cd docusaurus
27-
npm ci
25+
yarn add --dev js-yaml glob
2826
2927
- name: Run Strapi 12 Rules validation
3028
id: validation
@@ -38,101 +36,61 @@ jobs:
3836
with:
3937
script: |
4038
const fs = require('fs');
41-
const path = require('path');
4239
4340
try {
44-
// Read validation results
4541
const resultsPath = 'docusaurus/style-check-results.json';
42+
43+
if (!fs.existsSync(resultsPath)) {
44+
await github.rest.issues.createComment({
45+
issue_number: context.issue.number,
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: '## ❌ Documentation Style Review Failed\n\nValidation script could not run. Check the logs.'
49+
});
50+
return;
51+
}
52+
4653
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
4754
48-
// Generate comment
4955
let comment = '## 🎯 Strapi Documentation Style Review\n\n';
50-
comment += `*Based on Strapi's 12 Rules of Technical Writing*\n\n`;
51-
52-
// Summary
53-
comment += '### 📊 Summary\n';
56+
comment += `### 📊 Summary\n`;
5457
comment += `- **Files checked:** ${results.summary.filesProcessed}\n`;
55-
comment += `- **Total issues:** ${results.summary.totalIssues}\n`;
5658
comment += `- **Critical errors:** ${results.issues.errors.length} 🚨\n`;
5759
comment += `- **Warnings:** ${results.issues.warnings.length} ⚠️\n`;
5860
comment += `- **Suggestions:** ${results.issues.suggestions.length} 💡\n\n`;
5961
6062
if (results.summary.totalIssues === 0) {
61-
comment += '🎉 **Perfect!** Your documentation follows all 12 rules of technical writing.\n\n';
63+
comment += '🎉 **Perfect!** Your documentation follows all 12 rules.\n\n';
6264
} else {
63-
// Show critical errors
6465
if (results.issues.errors.length > 0) {
6566
comment += '### 🚨 Critical Issues (must fix)\n\n';
66-
results.issues.errors.slice(0, 5).forEach(error => {
67+
results.issues.errors.forEach(error => {
6768
const fileName = error.file.replace(/^.*\/docs\//, 'docs/');
68-
comment += `**${fileName}:${error.line}**\n`;
69-
comment += `- ${error.message}\n`;
70-
if (error.suggestion) {
71-
comment += `- 💡 *${error.suggestion}*\n`;
72-
}
69+
comment += `**${fileName}:${error.line}** - ${error.message}\n`;
70+
if (error.suggestion) comment += `💡 ${error.suggestion}\n`;
7371
comment += '\n';
7472
});
75-
76-
if (results.issues.errors.length > 5) {
77-
comment += `*... and ${results.issues.errors.length - 5} more critical issues*\n\n`;
78-
}
79-
}
80-
81-
// Show some warnings
82-
if (results.issues.warnings.length > 0) {
83-
comment += '### ⚠️ Warnings (should address)\n\n';
84-
results.issues.warnings.slice(0, 3).forEach(warning => {
85-
const fileName = warning.file.replace(/^.*\/docs\//, 'docs/');
86-
comment += `**${fileName}:${warning.line}** - ${warning.message}\n`;
87-
});
88-
89-
if (results.issues.warnings.length > 3) {
90-
comment += `\n*... and ${results.issues.warnings.length - 3} more warnings*\n`;
91-
}
92-
comment += '\n';
93-
}
94-
95-
// Show some suggestions
96-
if (results.issues.suggestions.length > 0) {
97-
comment += '### 💡 Suggestions (improvements)\n\n';
98-
results.issues.suggestions.slice(0, 2).forEach(suggestion => {
99-
const fileName = suggestion.file.replace(/^.*\/docs\//, 'docs/');
100-
comment += `**${fileName}:${suggestion.line}** - ${suggestion.message}\n`;
101-
});
102-
103-
if (results.issues.suggestions.length > 2) {
104-
comment += `\n*... and ${results.issues.suggestions.length - 2} more suggestions*\n`;
105-
}
106-
comment += '\n';
10773
}
10874
}
10975
110-
// Add footer
111-
comment += '---\n';
112-
comment += '*🤖 Automated review based on [Strapi\'s 12 Rules of Technical Writing](https://strapi.notion.site/12-Rules-of-Technical-Writing)*\n';
76+
comment += '---\n*🤖 Based on Strapi\'s 12 Rules of Technical Writing*';
11377
114-
// Post comment
11578
await github.rest.issues.createComment({
11679
issue_number: context.issue.number,
11780
owner: context.repo.owner,
11881
repo: context.repo.repo,
11982
body: comment
12083
});
12184
122-
// Set step output for potential failure
12385
if (results.issues.errors.length > 0) {
124-
core.setFailed(`Found ${results.issues.errors.length} critical errors that must be fixed.`);
86+
core.setFailed(`Found ${results.issues.errors.length} critical errors.`);
12587
}
12688
12789
} catch (error) {
128-
console.error('Error processing results:', error);
129-
13090
await github.rest.issues.createComment({
13191
issue_number: context.issue.number,
13292
owner: context.repo.owner,
13393
repo: context.repo.repo,
134-
body: '## ❌ Documentation Style Review Failed\n\n' +
135-
'There was an error running the style validation. Please check the GitHub Action logs.\n\n' +
136-
`Error: ${error.message}`
94+
body: `## ❌ Error\n\n${error.message}`
13795
});
13896
}

0 commit comments

Comments
 (0)