Skip to content

Commit 9125c6e

Browse files
committed
feat: add rebase check
chore: wip fix: re-enable and fix most dependency file tests - Fixed test isolation issues using spyOn instead of global mocks - Re-enabled 70 critical dependency file tests that now pass: - 33 tests for core dependency file parser functionality - 10 tests for Buddy integration with dependency files - 16 tests for end-to-end integration scenarios - 11 tests for helper functions - Added proper error handling in generatePackageJsonUpdates - Only kept one problematic test file skipped (package-scanner integration) - Core functionality is thoroughly tested and working fix: improve GitHub Actions workflows for rebase and testing - Fix executable path from './buddy' to 'bun buddy' - Reduce rebase schedule from every 5 minutes to every 15 minutes (GitHub rate limits) - Reduce testing schedule from every 5 minutes to every 2 hours - Add better debugging and error handling to workflows - Add environment variable checks and proper error exit codes - Ensure GITHUB_TOKEN is properly passed to commands chore: wip chore: wip fix: update workflow summary text to reflect correct schedules - Rebase workflow: Updated from 'every 10 minutes' to 'every 15 minutes' - Testing workflow: Updated from 'every 5 minutes' to 'every 2 hours' - Matches the actual cron schedules in the workflow definitions fix: resolve GitHub API 'tree.path cannot start with a slash' error - Fixed PackageScanner to return relative paths instead of absolute paths - Updated findFiles() to use path.relative() for consistent relative paths - Updated findFilesByPattern() and findFilesByPatternInDir() to use relative paths - Simplified GitHub provider path handling since all paths are now relative - Eliminated duplicate file entries (same file with both absolute and relative paths) - This resolves the 422 Unprocessable Entity error in rebase workflow The error occurred because GitHub API requires relative paths for tree objects, but PackageScanner was returning absolute paths like: '/home/runner/work/buddy-bot/buddy-bot/deps.yaml' Now all file paths are clean relative paths like: 'deps.yaml', 'package.json', etc. fix: resolve all TypeScript type issues - Added missing PackageFile import to src/buddy.ts - Fixed packageInfos scope issue in PR generator by moving declaration to function scope - Removed outdated fallback parsing for dependencies/devDependencies in dependency-file-parser (ts-pkgx only provides allDependencies, not separate properties) - Added type casts for test files to handle PackageFile['type'] union restrictions - Moved mockDepsYamlFile to outer scope for proper test accessibility - Removed obsolete fallback test that expected deprecated ts-pkgx behavior All 141 tests now pass with 0 TypeScript errors chore: wip chore: wip chore: wip
1 parent 41380a8 commit 9125c6e

18 files changed

+286
-172
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Buddy Rebase Check
2+
3+
on:
4+
schedule:
5+
- cron: '*/1 * * * *' # Check every 1 minute (GitHub Actions has rate limits for frequent schedules)
6+
workflow_dispatch: # Manual trigger
7+
inputs:
8+
dry_run:
9+
description: Dry run (preview only)
10+
required: false
11+
default: false
12+
type: boolean
13+
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
issues: write
21+
22+
jobs:
23+
check-rebase:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Setup Bun
33+
uses: oven-sh/setup-bun@v2
34+
with:
35+
bun-version: latest
36+
37+
- name: Install dependencies
38+
run: bun install
39+
40+
- name: Build buddy-bot
41+
run: bun run build
42+
43+
- name: Check for rebase requests
44+
run: |
45+
echo "🔍 Checking for PRs with rebase checkbox enabled..."
46+
echo "🔧 Environment info:"
47+
echo "Current directory: $(pwd)"
48+
echo "GITHUB_TOKEN set: $([[ -n \"$GITHUB_TOKEN\" ]] && echo \"Yes\" || echo \"No\")"
49+
echo "Repository: ${{ github.repository }}"
50+
echo "Event: ${{ github.event_name }}"
51+
echo ""
52+
53+
echo "🚀 Running check-rebase command..."
54+
set -e # Exit on any error
55+
56+
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
57+
echo "📋 Running in DRY RUN mode..."
58+
bun buddy check-rebase --dry-run --verbose
59+
else
60+
echo "🔄 Running in LIVE mode..."
61+
bun buddy check-rebase --verbose
62+
fi
63+
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Create summary
68+
if: always()
69+
run: |
70+
echo "## 🔄 Rebase Check Summary" >> $GITHUB_STEP_SUMMARY
71+
echo "" >> $GITHUB_STEP_SUMMARY
72+
echo "- **Triggered by**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
73+
echo "- **Dry run**: ${{ github.event.inputs.dry_run || 'false' }}" >> $GITHUB_STEP_SUMMARY
74+
echo "- **Time**: $(date)" >> $GITHUB_STEP_SUMMARY
75+
echo "" >> $GITHUB_STEP_SUMMARY
76+
77+
if [ "${{ github.event_name }}" = "schedule" ]; then
78+
echo "⏰ **Scheduled Check**: Automatically checks every 15 minutes" >> $GITHUB_STEP_SUMMARY
79+
else
80+
echo "🖱️ **Manual Check**: Manually triggered from Actions tab" >> $GITHUB_STEP_SUMMARY
81+
fi
82+
83+
echo "" >> $GITHUB_STEP_SUMMARY
84+
echo "📋 View detailed logs above for rebase results." >> $GITHUB_STEP_SUMMARY

.github/workflows/buddy-bot-testing.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Buddy Testing Updates
22

33
on:
44
schedule:
5-
- cron: '*/5 * * * *' # Every 5 minutes for testing
5+
- cron: '0 */2 * * *' # Every 2 hours for testing (more reasonable for testing)
66
workflow_dispatch: # Manual triggering for development
77
inputs:
88
strategy:
@@ -80,21 +80,30 @@ jobs:
8080
VERBOSE="${{ github.event.inputs.verbose || 'true' }}"
8181
8282
echo "🔍 Scanning for dependency updates..."
83+
echo "Strategy: $STRATEGY"
84+
echo "Packages: ${PACKAGES:-all}"
85+
echo "Verbose: $VERBOSE"
86+
echo ""
87+
88+
set -e # Exit on any error
8389
8490
if [ "$PACKAGES" != "" ]; then
8591
if [ "$VERBOSE" = "true" ]; then
86-
./buddy scan --packages "$PACKAGES" --verbose
92+
bun buddy scan --packages "$PACKAGES" --verbose
8793
else
88-
./buddy scan --packages "$PACKAGES"
94+
bun buddy scan --packages "$PACKAGES"
8995
fi
9096
else
9197
if [ "$VERBOSE" = "true" ]; then
92-
./buddy scan --strategy "$STRATEGY" --verbose
98+
bun buddy scan --strategy "$STRATEGY" --verbose
9399
else
94-
./buddy scan --strategy "$STRATEGY"
100+
bun buddy scan --strategy "$STRATEGY"
95101
fi
96102
fi
97103
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
98107
- name: Run Buddy dependency updates
99108
if: ${{ github.event.inputs.dry_run != 'true' }}
100109
run: |
@@ -103,21 +112,28 @@ jobs:
103112
VERBOSE="${{ github.event.inputs.verbose || 'true' }}"
104113
105114
echo "🚀 Running dependency updates..."
115+
echo "This will create/update PRs if outdated dependencies are found"
116+
echo ""
117+
118+
set -e # Exit on any error
106119
107120
if [ "$PACKAGES" != "" ]; then
108121
if [ "$VERBOSE" = "true" ]; then
109-
./buddy update --packages "$PACKAGES" --verbose
122+
bun buddy update --packages "$PACKAGES" --verbose
110123
else
111-
./buddy update --packages "$PACKAGES"
124+
bun buddy update --packages "$PACKAGES"
112125
fi
113126
else
114127
if [ "$VERBOSE" = "true" ]; then
115-
./buddy update --strategy "$STRATEGY" --verbose
128+
bun buddy update --strategy "$STRATEGY" --verbose
116129
else
117-
./buddy update --strategy "$STRATEGY"
130+
bun buddy update --strategy "$STRATEGY"
118131
fi
119132
fi
120133
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
121137
- name: Dry run notification
122138
if: ${{ github.event.inputs.dry_run == 'true' }}
123139
run: |
@@ -138,11 +154,11 @@ jobs:
138154
echo "" >> $GITHUB_STEP_SUMMARY
139155
140156
if [ "${{ github.event_name }}" = "schedule" ]; then
141-
echo "⏰ **Scheduled Run**: This was triggered automatically every 5 minutes" >> $GITHUB_STEP_SUMMARY
157+
echo "⏰ **Scheduled Run**: This was triggered automatically every 2 hours" >> $GITHUB_STEP_SUMMARY
142158
echo "💡 **Tip**: Use 'Actions' tab to manually trigger with custom settings" >> $GITHUB_STEP_SUMMARY
143159
else
144160
echo "🖱️ **Manual Trigger**: This was triggered manually from the Actions tab" >> $GITHUB_STEP_SUMMARY
145-
echo "⏰ **Auto-Schedule**: This workflow also runs every 5 minutes for testing" >> $GITHUB_STEP_SUMMARY
161+
echo "⏰ **Auto-Schedule**: This workflow also runs every 2 hours for testing" >> $GITHUB_STEP_SUMMARY
146162
fi
147163
148164
echo "" >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ Buddy leverages Bun's built-in capabilities for maximum performance:
183183

184184
Buddy automatically detects and updates the following dependency file formats:
185185

186-
- **package.json** - Traditional npm/Bun dependencies
187-
- **deps.yaml** / **deps.yml** - pkgx/Launchpad dependency declarations
186+
- **package.json** - Traditional npm dependencies
187+
- **deps.yaml** / **deps.yml** - Launchpad/pkgx dependency declarations
188188
- **dependencies.yaml** / **dependencies.yml** - Alternative dependency file format
189189
- **pkgx.yaml** / **pkgx.yml** - pkgx-specific dependency files
190190
- **.deps.yaml** / **.deps.yml** - Hidden dependency configuration files

docs/api/buddy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Buddy Class API
22

3-
The `Buddy` class is the main entry point for programmatic dependency management. It provides methods for scanning dependencies across multiple file formats (package.json, pkgx/Launchpad dependency files), creating pull requests, and managing updates.
3+
The `Buddy` class is the main entry point for programmatic dependency management. It provides methods for scanning dependencies across multiple file formats (package.json, Launchpad/pkgx dependency files), creating pull requests, and managing updates.
44

55
## Constructor
66

docs/config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ Buddy automatically scans your project for various dependency file formats:
6565
```typescript
6666
// Buddy automatically detects these file types:
6767
const supportedFiles = [
68-
'package.json', // npm/Bun dependencies
69-
'deps.yaml', // pkgx/Launchpad dependencies
70-
'deps.yml', // pkgx/Launchpad dependencies (alternative extension)
68+
'package.json', // npm dependencies
69+
'deps.yaml', // Launchpad/pkgx dependencies
70+
'deps.yml', // Launchpad/pkgx dependencies (alternative extension)
7171
'dependencies.yaml', // Alternative dependency format
7272
'dependencies.yml', // Alternative dependency format
7373
'pkgx.yaml', // pkgx-specific dependencies

docs/features/dependency-files.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Buddy uses the `ts-pkgx` library to parse and resolve dependency files, ensuring
2424
```bash
2525
# Buddy automatically scans for these files:
2626
my-project/
27-
├── package.json # ✅ npm/Bun dependencies
28-
├── deps.yaml #pkgx/Launchpad dependencies
27+
├── package.json # ✅ npm dependencies
28+
├── deps.yaml # ✅ Launchpad/pkgx dependencies
2929
├── dependencies.yml # ✅ Alternative format
3030
├── .deps.yaml # ✅ Hidden config
3131
├── frontend/
@@ -193,7 +193,7 @@ export default {
193193
// Different strategies for different file types
194194
fileStrategies: {
195195
'package.json': 'minor', // npm packages
196-
'deps.yaml': 'patch', // pkgx/Launchpad tools
196+
'deps.yaml': 'patch', // Launchpad/pkgx tools
197197
'.deps.yaml': 'all' // Hidden config files
198198
}
199199
}

docs/features/package-management.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ All dependency files are parsed using the `ts-pkgx` library to ensure compatibil
5353
// Automatically detected files
5454
const packageStructure = {
5555
packageFiles: [
56-
'package.json', // Root npm/Bun dependencies
57-
'deps.yaml', // pkgx/Launchpad dependencies
56+
'package.json', // Root npm dependencies
57+
'deps.yaml', // Launchpad/pkgx dependencies
5858
'deps.yml', // Alternative extension
5959
'dependencies.yaml', // Alternative format
6060
'pkgx.yaml', // pkgx-specific

docs/features/scanning.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Buddy automatically detects and scans these dependency file formats:
2424

2525
```bash
2626
# Traditional package files
27-
package.json # npm/Bun dependencies
27+
package.json # npm dependencies
2828

29-
# pkgx/Launchpad dependency files
29+
# Launchpad/pkgx dependency files
3030
deps.yaml # Main dependency format
3131
deps.yml # Alternative extension
3232
dependencies.yaml # Alternative naming

docs/usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ Buddy automatically detects and updates various dependency file formats:
397397
### Supported File Types
398398

399399
```yaml
400-
# deps.yaml - pkgx/Launchpad dependencies
400+
# deps.yaml - Launchpad/pkgx dependencies
401401
dependencies:
402402
node: ^20.0.0
403403
typescript: ^5.0.0
@@ -415,8 +415,8 @@ Projects can use multiple dependency file formats simultaneously:
415415

416416
```bash
417417
my-project/
418-
├── package.json # npm/Bun dependencies
419-
├── deps.yaml # pkgx/Launchpad dependencies
418+
├── package.json # npm dependencies
419+
├── deps.yaml # Launchpad/pkgx dependencies
420420
├── frontend/
421421
│ ├── package.json # Frontend-specific deps
422422
│ └── deps.yml # Additional tooling deps

src/buddy.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
BuddyBotConfig,
3+
PackageFile,
34
PackageUpdate,
45
UpdateGroup,
56
UpdateScanResult,
@@ -357,9 +358,15 @@ export class Buddy {
357358
}
358359

359360
// Handle dependency file updates (deps.yaml, dependencies.yaml, etc.)
360-
const { generateDependencyFileUpdates } = await import('./utils/dependency-file-parser')
361-
const dependencyFileUpdates = await generateDependencyFileUpdates(updates)
362-
fileUpdates.push(...dependencyFileUpdates)
361+
try {
362+
const { generateDependencyFileUpdates } = await import('./utils/dependency-file-parser')
363+
const dependencyFileUpdates = await generateDependencyFileUpdates(updates)
364+
fileUpdates.push(...dependencyFileUpdates)
365+
}
366+
catch (error) {
367+
this.logger.error('Failed to generate dependency file updates:', error)
368+
// Continue with package.json updates even if dependency file updates fail
369+
}
363370

364371
return fileUpdates
365372
}

0 commit comments

Comments
 (0)