Nightly Refactoring Mining (Eclipse Projects) #53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Refactoring Mining (Eclipse Projects) | |
| on: | |
| schedule: | |
| - cron: '0 2 * * 1-5' # Mon-Fri at 2 AM | |
| workflow_dispatch: | |
| inputs: | |
| repo_url: | |
| description: 'Single Eclipse repo to scan (overrides config)' | |
| required: false | |
| jobs: | |
| mine: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: write # Required: commit mining results | |
| pull-requests: write # Required: create PR with mining report | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| # Build only core + CLI (< 60s, no Tycho) | |
| - name: Build Mining CLI | |
| run: | | |
| mvn install -N -q | |
| mvn install -pl sandbox_common_core -DskipTests -q | |
| mvn package -pl sandbox_mining_cli -DskipTests -q | |
| # Run mining against Eclipse projects | |
| - name: Run Mining | |
| run: | | |
| ARGS="--config .github/refactoring-mining/repos.yml --output mining-results/ --format both" | |
| if [ -n "${{ github.event.inputs.repo_url }}" ]; then | |
| ARGS="--repo ${{ github.event.inputs.repo_url }} --output mining-results/ --format both" | |
| fi | |
| java -jar sandbox_mining_cli/target/sandbox-mining-cli.jar $ARGS | |
| # Upload report as artifact | |
| - name: Upload Report | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: mining-report-${{ github.run_number }} | |
| path: mining-results/ | |
| # Create PR if matches found (with deduplication) | |
| - name: Create PR | |
| if: hashFiles('mining-results/report.json') != '' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Compute hash of the report for dedup | |
| REPORT_HASH=$(sha256sum mining-results/report.json | cut -d' ' -f1) | |
| echo "Report hash: $REPORT_HASH" | |
| # Check for existing open mining PRs with the same report hash | |
| EXISTING_PRS=$(gh pr list --label "refactoring-mining" --state open --json number,body -q '.[].number' 2>/dev/null || true) | |
| for PR_NUM in $EXISTING_PRS; do | |
| PR_BODY=$(gh pr view "$PR_NUM" --json body -q '.body' 2>/dev/null || true) | |
| if echo "$PR_BODY" | grep -q "$REPORT_HASH"; then | |
| echo "Duplicate report detected (matches PR #$PR_NUM). Skipping PR creation." | |
| exit 0 | |
| fi | |
| done | |
| # Close stale open mining report PRs to avoid accumulation | |
| for PR_NUM in $EXISTING_PRS; do | |
| echo "Closing stale mining PR #$PR_NUM" | |
| gh pr close "$PR_NUM" --comment "Superseded by mining run #${{ github.run_number }}" 2>/dev/null || true | |
| done | |
| # Embed the report hash in the PR body markdown for future dedup checks | |
| echo "" >> mining-results/report.md | |
| echo "<!-- report-hash: $REPORT_HASH -->" >> mining-results/report.md | |
| - name: Open PR | |
| if: hashFiles('mining-results/report.json') != '' | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| title: "🔍 Refactoring Mining: Eclipse Projects (${{ github.run_number }})" | |
| body-path: mining-results/report.md | |
| branch: mining/report-${{ github.run_number }} | |
| commit-message: "mining: add report from run ${{ github.run_number }}" | |
| labels: refactoring-mining | |
| add-paths: | | |
| mining-results/report.json | |
| mining-results/report.md |