-
Notifications
You must be signed in to change notification settings - Fork 0
332 lines (279 loc) · 12.1 KB
/
Copy pathprocess-reading-queue.yml
File metadata and controls
332 lines (279 loc) · 12.1 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
name: Process Reading Queue
on:
schedule:
# Run every 4 hours
- cron: '0 */4 * * *'
workflow_dispatch: # Allow manual triggering
inputs:
run_tests:
description: 'Run full test suite'
required: false
default: 'true'
type: boolean
jobs:
process-reading-pipeline:
name: Process Reading Pipeline
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Verify input data exists
run: |
echo "🔍 Verifying input data files..."
# Check Twitter bookmarks
if [ -f "data/twitter-bookmarks.json" ]; then
echo "✅ Twitter bookmarks: $(jq '.bookmarks | length' data/twitter-bookmarks.json 2>/dev/null || echo 'unknown') items"
else
echo "⚠️ Twitter bookmarks not found, will be created if needed"
fi
# Check Journal Club data
if [ -f "data/journalclub.json" ]; then
echo "✅ Journal Club: $(jq '.papers | length' data/journalclub.json 2>/dev/null || echo 'unknown') papers"
else
echo "⚠️ Journal Club data not found"
fi
# Check inbox.md
if [ -f "inbox.md" ]; then
inbox_items=$(grep "^## " inbox.md | wc -l | tr -d ' ')
echo "✅ Inbox: $inbox_items items"
else
echo "⚠️ Inbox file not found"
fi
- name: Run Normalizer
run: |
echo "🔄 Running reading queue normalizer..."
node automation/normalize.js
if [ -f "data/reading-queue.json" ]; then
echo "✅ Normalization complete"
local total_items=$(jq '.meta.total_items // 0' data/reading-queue.json 2>/dev/null || echo '0')
echo "📊 Total items in queue: $total_items"
# Show breakdown
if command -v jq >/dev/null 2>&1; then
echo "📈 Source breakdown:"
jq -r '.meta.sources | to_entries[] | " - \(.key): \(.value)"' data/reading-queue.json 2>/dev/null || echo " (Unable to parse sources)"
echo "🎯 Priority breakdown:"
jq -r '.meta.priorities | to_entries[] | " - \(.key): \(.value)"' data/reading-queue.json 2>/dev/null || echo " (Unable to parse priorities)"
fi
else
echo "❌ Normalization failed - no output file"
exit 1
fi
- name: Run Issue Generator
run: |
echo "🏷️ Running issue generator..."
node automation/issue_generator.js
if [ -d "issues" ]; then
issue_count=$(find issues -name "*.md" ! -name "README.md" | wc -l | tr -d ' ')
echo "✅ Issue generation complete"
echo "📋 Created $issue_count issue files"
if [ -f "issues/README.md" ]; then
echo "📄 Generated index file"
fi
else
echo "❌ Issue generation failed"
exit 1
fi
- name: Run LLM Summarizer (Stub Mode)
run: |
echo "🤖 Running LLM summarizer in stub mode..."
node automation/llm_summarizer_stub.js --mode stub
if [ -f "data/reading-queue.json" ]; then
# Check if summaries were added
if command -v jq >/dev/null 2>&1; then
summary_count=$(jq '[.items[] | select(.summary and .summary != "")] | length' data/reading-queue.json 2>/dev/null || echo '0')
echo "✅ Summarization complete"
echo "📝 Added summaries to $summary_count items"
else
echo "✅ Summarization complete (jq not available for detailed count)"
fi
else
echo "❌ Summarization failed"
exit 1
fi
- name: Run Pipeline Tests
if: github.event.inputs.run_tests == 'true' || github.event_name == 'schedule'
run: |
echo "🧪 Running reading pipeline test suite..."
if [ -x "./tests/reading-pipeline.test.sh" ]; then
./tests/reading-pipeline.test.sh
echo "✅ All pipeline tests passed"
else
echo "⚠️ Test script not found or not executable"
# Try to make it executable and run
chmod +x ./tests/reading-pipeline.test.sh
./tests/reading-pipeline.test.sh || echo "⚠️ Some tests may have failed"
fi
- name: Generate Processing Report
run: |
echo "📊 Generating processing report..."
# Create report file
cat > pipeline-report.md << 'EOF'
# Reading Pipeline Processing Report
**Generated:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
**Workflow Run:** [#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
## Processing Steps
1. ✅ **Data Verification** - Checked input files
2. ✅ **Normalization** - Processed reading queue
3. ✅ **Issue Generation** - Created GitHub issues
4. ✅ **Summarization** - Added AI summaries
EOF
# Add statistics if available
if [ -f "data/reading-queue.json" ] && command -v jq >/dev/null 2>&1; then
cat >> pipeline-report.md << 'EOF'
## Statistics
EOF
echo "- **Total Items:** $(jq '.meta.total_items // 0' data/reading-queue.json)" >> pipeline-report.md
echo "- **Sources:** $(jq -r '.meta.sources | keys | join(", ")' data/reading-queue.json)" >> pipeline-report.md
echo "- **Priorities:** High: $(jq '.meta.priorities.high // 0' data/reading-queue.json), Medium: $(jq '.meta.priorities.medium // 0' data/reading-queue.json), Low: $(jq '.meta.priorities.low // 0' data/reading-queue.json)" >> pipeline-report.md
fi
# Add issue count
if [ -d "issues" ]; then
issue_count=$(find issues -name "*.md" ! -name "README.md" | wc -l | tr -d ' ')
echo "- **Issues Generated:** $issue_count" >> pipeline-report.md
fi
# Display report
echo ""
echo "## 📊 Processing Report"
echo ""
cat pipeline-report.md
- name: Check for changes
id: changes
run: |
git add data/reading-queue.json issues/ pipeline-report.md 2>/dev/null || true
if git diff --cached --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "📄 No changes to commit"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "📄 Changes detected, preparing commit..."
git diff --cached --stat
fi
- name: Commit and push changes
if: steps.changes.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "chore: process reading queue and update issues
🤖 Generated with [GitHub Actions](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- Updated reading queue with latest sources
- Generated GitHub issues for reading items
- Added AI-powered summaries
- Ran comprehensive test suite
- Timestamp: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
Processing Details:
$(cat pipeline-report.md | grep -E "^-|\*\*" | head -10)
Co-Authored-By: GitHub Action <action@users.noreply.github.com>"
git push
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: reading-pipeline-results
path: |
data/reading-queue.json
issues/
pipeline-report.md
retention-days: 7
- name: Summary
run: |
echo "## 📚 Reading Pipeline Processing Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ${{ steps.changes.outputs.changed == 'true' && '✅ Updated' || '✅ Processed' }}" >> $GITHUB_STEP_SUMMARY
echo "**Timestamp:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> $GITHUB_STEP_SUMMARY
echo "**Tests Run:** ${{ github.event.inputs.run_tests == 'true' && '✅ Yes' || '⏭️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f "data/reading-queue.json" ]; then
if command -v jq >/dev/null 2>&1; then
echo "**Reading Queue Statistics:**" >> $GITHUB_STEP_SUMMARY
echo "- Total Items: $(jq '.meta.total_items // 0' data/reading-queue.json)" >> $GITHUB_STEP_SUMMARY
echo "- High Priority: $(jq '.meta.priorities.high // 0' data/reading-queue.json)" >> $GITHUB_STEP_SUMMARY
echo "- Medium Priority: $(jq '.meta.priorities.medium // 0' data/reading-queue.json)" >> $GITHUB_STEP_SUMMARY
fi
fi
if [ -d "issues" ]; then
local issue_count=$(find issues -name "*.md" ! -name "README.md" | wc -l | tr -d ' ')
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Issues Generated:** $issue_count" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ steps.changes.outputs.changed }}" == "true" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📝 Changes Committed" >> $GITHUB_STEP_SUMMARY
echo "- Reading queue updated with latest processing" >> $GITHUB_STEP_SUMMARY
echo "- GitHub issues created for reading items" >> $GITHUB_STEP_SUMMARY
echo "- AI summaries added to queue items" >> $GITHUB_STEP_SUMMARY
fi
quality-check:
name: Quality Check
runs-on: ubuntu-latest
needs: process-reading-pipeline
if: always() && needs.process-reading-pipeline.result == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Validate JSON files
run: |
echo "🔍 Validating JSON files..."
# Check reading queue
if [ -f "data/reading-queue.json" ]; then
if jq empty data/reading-queue.json 2>/dev/null; then
echo "✅ reading-queue.json: Valid JSON"
else
echo "❌ reading-queue.json: Invalid JSON"
exit 1
fi
fi
# Check other JSON files
for json_file in data/twitter-bookmarks.json data/journalclub.json; do
if [ -f "$json_file" ]; then
if jq empty "$json_file" 2>/dev/null; then
echo "✅ $(basename "$json_file"): Valid JSON"
else
echo "❌ $(basename "$json_file"): Invalid JSON"
exit 1
fi
fi
done
- name: Check file integrity
run: |
echo "🔍 Checking file integrity..."
# Verify required directories exist
for dir in data issues automation fixtures; do
if [ -d "$dir" ]; then
echo "✅ Directory exists: $dir"
else
echo "⚠️ Directory missing: $dir"
fi
done
# Verify key files exist
for file in data/reading-queue.json automation/normalize.js; do
if [ -f "$file" ]; then
echo "✅ File exists: $file"
else
echo "❌ File missing: $file"
exit 1
fi
done
- name: Quality Summary
run: |
echo "## 🔍 Quality Check Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**JSON Validation:** ✅ Passed" >> $GITHUB_STEP_SUMMARY
echo "**File Integrity:** ✅ Passed" >> $GITHUB_STEP_SUMMARY
echo "**Dependencies:** ✅ Installed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All quality checks passed successfully!" >> $GITHUB_STEP_SUMMARY