GitHub Actions Issues and Proposed Fixes
π¨ Current Issues
1. Permission Denied Errors
Error: EACCES: permission denied, unlink '/home/alex/actions-runner-2/_work/terraphim-ai/terraphim-ai/target/.rustc_info.json'
Root Cause: GitHub Actions runner doesn't have permission to remove files from target directory between jobs.
Affected Workflows:
ci-native.yml(lint-and-format job)ci-optimized.yml(Earthly CI/CD)
2. Cache Key Generation Issues
Error: Cache key generation failing due to workspace structure complexity.
Root Cause: Complex workspace dependencies causing inconsistent cache keys.
π§ Proposed Fixes
Fix 1: Target Directory Permissions
File: .github/workflows/ci-native.yml
Current Problematic Code:
lint-and-format:
runs-on:
timeout-minutes: 15 # Reduced timeout with faster runnerProposed Solution:
lint-and-format:
runs-on:
timeout-minutes: 15
# Add cleanup step to prevent permission issues
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Clean target directory
run: |
rm -rf target || true
mkdir -p target
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ needs.setup.outputs.cache-key }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ needs.setup.outputs.cache-key }}-cargo-lint-Fix 2: Simplified Cache Key Strategy
File: .github/workflows/ci-native.yml
Current Problematic Code:
- name: Generate cache key
id: cache
run: |
echo "key=${{ env.CACHE_KEY }}" >> $GITHUB_OUTPUTProposed Solution:
- name: Generate cache key
id: cache
run: |
# Use workspace root Cargo.lock for consistent hashing
CACHE_KEY="v1-${{ hashFiles('Cargo.lock') }}"
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUTFix 3: Earthly CI/CD Improvements
File: .github/workflows/ci-optimized.yml
Current Issues:
- Complex target handling
- Permission errors with target directories
Proposed Solution:
build-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Build frontend
run: npm run build:ci
- name: Upload frontend artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: desktop/dist/π― Implementation Priority
High Priority (Immediate)
- Fix target directory cleanup - Add explicit cleanup steps
- Simplify cache key generation - Use consistent hashing strategy
- Add error handling - Graceful degradation for permission issues
Medium Priority (Next Sprint)
- Optimize Earthly workflows - Separate concerns, improve caching
- Add workflow status reporting - Better visibility into CI health
- Implement workflow dispatch - Manual trigger capabilities
π Testing Strategy
Before Deployment
- Test in fork - Create test branch to validate fixes
- Dry run validation - Use
gh workflow runfor testing - Incremental rollout - Merge fixes one at a time
Validation Steps
- Cache key consistency - Verify same inputs produce same outputs
- Permission handling - Test cleanup steps work correctly
- Cross-platform compatibility - Test on Linux runners
π Expected Outcomes
Immediate Improvements
- β Eliminate permission denied errors
- β Consistent cache behavior across runs
- β Faster CI times with better caching
- β More reliable build process
Long-term Benefits
- π Improved CI/CD reliability
- π§ Better debugging capabilities
- π Faster development feedback loops
- π° Reduced resource waste
π Rollback Plan
If issues arise:
- Revert to current working state - Use
git revert - Isolate problematic changes - Test fixes individually
- Gradual implementation - Deploy incrementally
- Monitor closely - Watch for regression patterns
π Success Metrics
Target KPIs
- CI Success Rate: Target >95% (currently ~70%)
- Build Time: Target <10 minutes (currently 15+ minutes)
- Cache Hit Rate: Target >80% (currently inconsistent)
- Permission Errors: Target 0 (currently 2-3 per run)
Measurement Plan
- Track workflow run times
- Monitor cache effectiveness
- Document error patterns
- Measure developer satisfaction
π― Next Steps
- Create fix branch:
fix/ci-permission-and-cache-issues - Implement changes: Apply proposed solutions
- Test thoroughly: Validate in isolated environment
- Deploy incrementally: Merge with careful monitoring
- Document learnings: Update CI/CD best practices
This comprehensive plan addresses the root causes of GitHub Actions failures and provides a clear path to reliable CI/CD infrastructure.