diff --git a/.github/workflows/java.yml b/.github/workflows/ci-java.yml similarity index 84% rename from .github/workflows/java.yml rename to .github/workflows/ci-java.yml index 30bc3263..6c48a902 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/ci-java.yml @@ -2,20 +2,21 @@ name: Java CI with Coverage on: push: - # Run on pushes to any branch, but only when relevant paths change - paths: + branches: [ master ] + paths: - 'algorithms-java/**' - - '.github/workflows/java.yml' + - '.github/workflows/ci-java.yml' pull_request: - # Only run for PRs targeting master branches: [ master ] paths: - 'algorithms-java/**' - - '.github/workflows/java.yml' + - '.github/workflows/ci-java.yml' jobs: test: runs-on: ubuntu-latest + env: + IS_MASTER: ${{ github.ref == 'refs/heads/master' }} steps: - uses: actions/checkout@v4 @@ -45,7 +46,7 @@ jobs: ./gradlew clean test jacocoTestReport - name: Publish coverage to Coveralls - if: github.ref == 'refs/heads/master' + if: env.IS_MASTER == 'true' uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -55,7 +56,7 @@ jobs: flag-name: java - name: Upload coverage reports to Codecov (backup) - if: github.ref == 'refs/heads/master' + if: env.IS_MASTER == 'true' uses: codecov/codecov-action@v4 with: file: algorithms-java/build/reports/jacoco/test/jacocoTestReport.xml diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/ci-js-pages.yml similarity index 76% rename from .github/workflows/deploy-pages.yml rename to .github/workflows/ci-js-pages.yml index a3fc6a8a..184aa765 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/ci-js-pages.yml @@ -1,12 +1,19 @@ name: JavaScript CI with Pages on: - pull_request: push: branches: [ master ] paths: - 'algorithms-js/**' - - '.github/workflows/deploy-pages.yml' + - '.github/workflows/ci-js-pages.yml' + pull_request: + branches: [ master ] + paths: + - 'algorithms-js/**' + - '.github/workflows/ci-js-pages.yml' + +env: + IS_MASTER: ${{ github.ref == 'refs/heads/master' }} jobs: build: @@ -34,6 +41,7 @@ jobs: npm run build - name: Upload artifact + if: env.IS_MASTER == 'true' uses: actions/upload-pages-artifact@v3 with: path: algorithms-js @@ -43,6 +51,8 @@ jobs: needs: build if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest + env: + IS_MASTER: ${{ github.ref == 'refs/heads/master' }} permissions: contents: read pages: write @@ -52,7 +62,9 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: - name: Setup Pages + if: env.IS_MASTER == 'true' uses: actions/configure-pages@v4 - name: Deploy to GitHub Pages + if: env.IS_MASTER == 'true' id: deployment uses: actions/deploy-pages@v4 diff --git a/.github/workflows/ci-soft-review.yml b/.github/workflows/ci-soft-review.yml new file mode 100644 index 00000000..4befea34 --- /dev/null +++ b/.github/workflows/ci-soft-review.yml @@ -0,0 +1,89 @@ +name: Soft Review + +on: + pull_request: + +permissions: + contents: read + pull-requests: write + +jobs: + soft-review: + name: Soft Review Feedback + runs-on: ubuntu-latest + steps: + - name: Generate soft review and comment on PR + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const owner = context.repo.owner; + const repo = context.repo.repo; + const number = pr.number; + + // Fetch changed files in the PR + const files = await github.paginate(github.rest.pulls.listFiles, { + owner, + repo, + pull_number: number, + per_page: 100 + }); + + let todoFindings = []; + let largeFiles = []; + let summaryLines = []; + + for (const f of files) { + const filename = f.filename; + // Skip workflow files to avoid reviewing our own CI YAML + if (filename.startsWith('.github/workflows/')) { + continue; + } + const additions = f.additions; + const changes = f.changes; + const patch = f.patch || ''; + + // Detect TODO/FIXME in added lines only + const addedLines = patch.split('\n').filter(l => l.startsWith('+')); + const hasTodo = addedLines.some(l => /\b(TODO|FIXME|HACK|XXX)\b/i.test(l)); + if (hasTodo) { + todoFindings.push(`- ${filename}`); + } + + // Flag large file changes (heuristic: > 500 additions or > 1500 total changes) + if (additions > 500 || changes > 1500) { + largeFiles.push(`- ${filename} (additions: ${additions}, changes: ${changes})`); + } + } + + summaryLines.push(`PR Title: ${pr.title}`); + summaryLines.push(`Author: @${pr.user.login}`); + summaryLines.push(''); + + if (todoFindings.length > 0) { + summaryLines.push('Noticed TODO/FIXME markers in:'); + summaryLines.push(...todoFindings); + summaryLines.push(''); + } + + if (largeFiles.length > 0) { + summaryLines.push('Large file changes detected:'); + summaryLines.push(...largeFiles); + summaryLines.push(''); + } + + if (todoFindings.length === 0 && largeFiles.length === 0) { + summaryLines.push('No TODO/FIXME markers or large changes detected.'); + } + + summaryLines.push(''); + summaryLines.push('This is an automated soft review (no blocking).'); + + const body = summaryLines.join('\n'); + + await github.rest.issues.createComment({ + owner, + repo, + issue_number: number, + body + }); diff --git a/README.md b/README.md index 07e8cae8..7f96a4c0 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,14 @@ ![Open Issues](https://img.shields.io/github/issues/sachinlala/SimplifyLearning?label=Issues&color=006400&style=flat) [![Forks](https://img.shields.io/github/forks/sachinlala/SimplifyLearning.svg?color=darkgreen)](https://github.com/sachinlala/SimplifyLearning/network/members) [![Stars](https://img.shields.io/github/stars/sachinlala/SimplifyLearning.svg)](https://github.com/sachinlala/SimplifyLearning/stargazers) +[![Java CI with Coverage](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-java.yml/badge.svg?branch=master)](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-java.yml) +[![JavaScript CI with Pages](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-js-pages.yml/badge.svg?branch=master)](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-js-pages.yml) ### SL Simplify Learning -> **An anthology of foundational algorithms and data structures.** +**An anthology of foundational algorithms and data structures.** -> ✨ Featuring interactive visualizations and examples to minimize cognitive load and maximize learning. +✨ Featuring interactive visualizations and examples to minimize cognitive load and maximize learning. [![Live Demo](https://img.shields.io/badge/Live%20Demo-4A90E2?style=for-the-badge)](https://sachinlala.github.io/SimplifyLearning/algorithms-js/) diff --git a/algorithms-java/README.md b/algorithms-java/README.md index 375d0145..d57ae9b3 100644 --- a/algorithms-java/README.md +++ b/algorithms-java/README.md @@ -1,5 +1,6 @@ [![Java](https://img.shields.io/badge/Java-21-darkgreen.svg)](https://openjdk.org/) [![Coverage](https://img.shields.io/badge/Coverage-95%25-darkgreen.svg)](https://coveralls.io/github/sachinlala/SimplifyLearning?branch=master) +[![Java CI with Coverage](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-java.yml/badge.svg?branch=master)](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-java.yml) > Comprehensive Java implementations of algorithms with rigorous testing and high code coverage. diff --git a/algorithms-js/README.md b/algorithms-js/README.md index f749d3a1..f9e79b94 100644 --- a/algorithms-js/README.md +++ b/algorithms-js/README.md @@ -1,5 +1,6 @@ [![JavaScript](https://img.shields.io/badge/JavaScript-ES6+-yellow.svg)](https://developer.mozilla.org/en-US/docs/Web/JavaScript) [![Mobile Friendly](https://img.shields.io/badge/Mobile-Friendly-blue.svg)]() +[![JavaScript CI with Pages](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-js-pages.yml/badge.svg?branch=master)](https://github.com/sachinlala/SimplifyLearning/actions/workflows/ci-js-pages.yml) > An interactive collection of algorithms with visual explanations and hands-on examples written in plain JavaScript.