Skip to content

Maintenance

Maintenance #4

Workflow file for this run

name: Maintenance
on:
schedule:
# Run every Monday at 9:00 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
update-type:
description: 'Type of updates to perform'
required: true
default: 'all'
type: choice
options:
- all
- dependencies
- security
- documentation
- benchmarks
concurrency:
group: maintenance-${{ github.ref }}
cancel-in-progress: true
env:
JAVA_OPTS: -Xmx3G -XX:+UseG1GC
jobs:
dependency-updates:
name: Update Dependencies
if: github.event.inputs.update-type == 'all' || github.event.inputs.update-type == 'dependencies' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.DEPENDENCY_UPDATE_APP_ID }}
private_key: ${{ secrets.DEPENDENCY_UPDATE_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Cache SBT
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.coursier/cache
target
project/target
key: sbt-maintenance-cache-${{ runner.os }}-${{ hashFiles('**/*.sbt') }}
- name: Check for dependency updates
id: dependency-check
run: |
sbt dependencyUpdates | tee dependency-updates.log
# Parse updates and create summary
if grep -q "No dependencies to update" dependency-updates.log; then
echo "has-updates=false" >> $GITHUB_OUTPUT
echo "No dependency updates available"
else
echo "has-updates=true" >> $GITHUB_OUTPUT
echo "Dependency updates available"
fi
- name: Update dependencies
if: steps.dependency-check.outputs.has-updates == 'true'
run: |
# Update Scala Steward compatible dependencies
sbt "dependencyUpdates; reload"
# Commit changes if any
git config user.name "flowforge-maintenance[bot]"
git config user.email "maintenance@flowforge.io"
if git diff --quiet; then
echo "No dependency changes to commit"
else
git add -A
git commit -m "🔄 Update dependencies (automated)"
git push
fi
- name: Create dependency update PR
if: steps.dependency-check.outputs.has-updates == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: "🔄 Automated dependency updates"
title: "🔄 Dependency Updates - $(date +'%Y-%m-%d')"
body: |
## 🔄 Automated Dependency Updates
This PR contains automated dependency updates generated by the maintenance workflow.
### Updates Summary
```
$(cat dependency-updates.log | grep -A 20 "Found [0-9]* updates" || echo "See build logs for details")
```
### Testing
- [ ] All tests pass
- [ ] Integration tests pass
- [ ] Benchmarks show no regression
- [ ] Examples still work
### Notes
- This PR was automatically generated
- Please review carefully before merging
- Consider running additional tests for major version updates
branch: maintenance/dependency-updates
labels: |
dependencies
automated
maintenance
security-audit:
name: Security Audit
if: github.event.inputs.update-type == 'all' || github.event.inputs.update-type == 'security' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Run security audit
id: security-audit
run: |
# Dependency vulnerability check
sbt dependencyCheck
# Check for known vulnerabilities
if [ -f "target/scala-*/dependency-check-report.html" ]; then
VULN_COUNT=$(grep -o "vulnerabilities found" target/scala-*/dependency-check-report.html | wc -l)
echo "vulnerabilities=$VULN_COUNT" >> $GITHUB_OUTPUT
else
echo "vulnerabilities=0" >> $GITHUB_OUTPUT
fi
- name: Upload security report
uses: actions/upload-artifact@v3
with:
name: security-audit-report
path: target/scala-*/dependency-check-report.html
- name: Create security issue
if: steps.security-audit.outputs.vulnerabilities != '0'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "🔒 Security audit findings"
title: "🔒 Security Vulnerabilities Found - $(date +'%Y-%m-%d')"
body: |
## 🔒 Security Audit Results
**⚠️ Found ${{ steps.security-audit.outputs.vulnerabilities }} security vulnerabilities**
### Action Required
Please review the attached security report and update vulnerable dependencies.
### Report
See the security audit report in the artifacts of this workflow run.
### Priority
- **Critical/High**: Update immediately
- **Medium**: Update in next release
- **Low**: Consider updating when convenient
branch: security/audit-findings
labels: |
security
vulnerability
high-priority
benchmark-regression:
name: Benchmark Regression Check
if: github.event.inputs.update-type == 'all' || github.event.inputs.update-type == 'benchmarks' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Run performance benchmarks
run: |
sbt "benchmarks/Jmh/run -i 5 -wi 3 -f 1 -t 1"
- name: Upload benchmark results
uses: actions/upload-artifact@v3
with:
name: benchmark-results-maintenance
path: benchmarks/target/jmh-result.json
- name: Compare with baseline
id: benchmark-comparison
run: |
# Download baseline benchmarks (if available)
if [ -f "benchmarks/baseline-results.json" ]; then
# Compare current results with baseline
# This would need a custom script to parse and compare JMH results
echo "Comparing benchmarks with baseline..."
echo "regression-detected=false" >> $GITHUB_OUTPUT
else
echo "No baseline found, skipping comparison"
echo "regression-detected=false" >> $GITHUB_OUTPUT
fi
- name: Create performance issue
if: steps.benchmark-comparison.outputs.regression-detected == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "📊 Performance regression detected"
title: "📊 Performance Regression Alert - $(date +'%Y-%m-%d')"
body: |
## 📊 Performance Regression Detected
**⚠️ Benchmarks show performance degradation**
### Details
See the benchmark results in the artifacts of this workflow run.
### Action Required
1. Review recent changes that might impact performance
2. Investigate specific operations showing regression
3. Consider optimization or rollback if severe
### Benchmark Results
Latest benchmark results are attached to this workflow run.
branch: performance/regression-alert
labels: |
performance
regression
investigation-needed
documentation-maintenance:
name: Documentation Maintenance
if: github.event.inputs.update-type == 'all' || github.event.inputs.update-type == 'documentation' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: flowforge-docs/website/package-lock.json
- name: Check for broken links
id: link-check
run: |
# Generate documentation
sbt unidoc
cd flowforge-docs/website
npm ci
npm run build
# Check for broken links (would need additional tooling)
echo "broken-links=false" >> $GITHUB_OUTPUT
- name: Update API documentation
run: |
# Regenerate API docs
sbt unidoc
# Check if there are changes
git config user.name "flowforge-maintenance[bot]"
git config user.email "maintenance@flowforge.io"
if git diff --quiet target/scala-*/unidoc/; then
echo "No documentation changes"
else
echo "Documentation updated"
git add target/scala-*/unidoc/
git commit -m "📚 Update API documentation (automated)"
fi
- name: Create documentation PR
if: steps.link-check.outputs.broken-links == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "📚 Documentation maintenance"
title: "📚 Documentation Maintenance - $(date +'%Y-%m-%d')"
body: |
## 📚 Documentation Maintenance
This PR contains automated documentation updates and fixes.
### Changes
- Updated API documentation
- Fixed broken links (if any)
- Refreshed examples
### Notes
- This PR was automatically generated
- Please review before merging
branch: maintenance/documentation-updates
labels: |
documentation
maintenance
automated
code-quality-check:
name: Code Quality Check
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Run code quality analysis
run: |
# Compile with warnings as errors
sbt compile
# Run scalastyle checks
sbt scalastyle
# Run wartremover
sbt wartremoverErrors
# Check test coverage
sbt coverage test coverageReport
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report-maintenance
path: target/scala-*/scoverage-report/
- name: Analyze code metrics
run: |
# Lines of code
find . -name "*.scala" -not -path "./target/*" | xargs wc -l | tail -1
# Cyclomatic complexity (would need additional tooling)
echo "Code metrics analysis completed"
cleanup-old-artifacts:
name: Cleanup Old Artifacts
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Delete old workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 30
keep_minimum_runs: 10
- name: Cleanup old packages
uses: actions/delete-package-versions@v4
with:
package-name: flowforge
package-type: container
min-versions-to-keep: 10
delete-only-untagged-versions: true
dependency-graph-update:
name: Update Dependency Graph
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- name: Submit Dependency Graph
uses: scalacenter/sbt-dependency-submission@v2
with:
working-directory: .
modules-ignore: |
root
flowforge-docs
benchmarks
notify-maintenance-summary:
name: Maintenance Summary
needs: [dependency-updates, security-audit, benchmark-regression, documentation-maintenance, code-quality-check]
if: always() && github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Collect maintenance results
id: summary
run: |
echo "## 🔧 Weekly Maintenance Summary - $(date +'%Y-%m-%d')" > summary.md
echo "" >> summary.md
# Dependency updates
if [ "${{ needs.dependency-updates.result }}" = "success" ]; then
echo "✅ **Dependency Updates**: Completed successfully" >> summary.md
else
echo "❌ **Dependency Updates**: Failed or skipped" >> summary.md
fi
# Security audit
if [ "${{ needs.security-audit.result }}" = "success" ]; then
echo "✅ **Security Audit**: No critical vulnerabilities found" >> summary.md
else
echo "⚠️ **Security Audit**: Issues detected - review required" >> summary.md
fi
# Benchmarks
if [ "${{ needs.benchmark-regression.result }}" = "success" ]; then
echo "✅ **Performance**: No regressions detected" >> summary.md
else
echo "📊 **Performance**: Requires investigation" >> summary.md
fi
# Documentation
if [ "${{ needs.documentation-maintenance.result }}" = "success" ]; then
echo "✅ **Documentation**: Up to date" >> summary.md
else
echo "📚 **Documentation**: Updates needed" >> summary.md
fi
# Code quality
if [ "${{ needs.code-quality-check.result }}" = "success" ]; then
echo "✅ **Code Quality**: All checks passed" >> summary.md
else
echo "🔍 **Code Quality**: Issues detected" >> summary.md
fi
- name: Create maintenance issue
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "🔧 Weekly maintenance summary"
title: "🔧 Weekly Maintenance Summary - $(date +'%Y-%m-%d')"
bodyFile: summary.md
branch: maintenance/weekly-summary
labels: |
maintenance
weekly-summary
automated
- name: Notify team
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
text: "🔧 FlowForge Weekly Maintenance Completed",
attachments: [
{
color: "good",
fields: [
{
title: "Dependencies",
value: "${{ needs.dependency-updates.result == 'success' && '✅ Updated' || '❌ Issues' }}",
short: true
},
{
title: "Security",
value: "${{ needs.security-audit.result == 'success' && '✅ Clean' || '⚠️ Alerts' }}",
short: true
},
{
title: "Performance",
value: "${{ needs.benchmark-regression.result == 'success' && '✅ Good' || '📊 Check' }}",
short: true
},
{
title: "Documentation",
value: "${{ needs.documentation-maintenance.result == 'success' && '✅ Current' || '📚 Update' }}",
short: true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}