From 64ecd0db74cd87302c90cf5e2815cf2d81cb1531 Mon Sep 17 00:00:00 2001 From: sachinlala Date: Sat, 9 Aug 2025 05:43:13 +0530 Subject: [PATCH 1/4] CI: ensure Pages deploy runs on any push to master; add free 'Soft Review' workflow that comments on PRs --- .github/workflows/deploy-pages.yml | 3 -- .github/workflows/soft-review.yml | 85 ++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/soft-review.yml diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index a3fc6a8a..05ba1577 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -4,9 +4,6 @@ on: pull_request: push: branches: [ master ] - paths: - - 'algorithms-js/**' - - '.github/workflows/deploy-pages.yml' jobs: build: diff --git a/.github/workflows/soft-review.yml b/.github/workflows/soft-review.yml new file mode 100644 index 00000000..c5b421fa --- /dev/null +++ b/.github/workflows/soft-review.yml @@ -0,0 +1,85 @@ +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; + 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 + }); From 5c68a50ab293b5c320463e914e343954bce8451d Mon Sep 17 00:00:00 2001 From: sachinlala Date: Sat, 9 Aug 2025 05:48:42 +0530 Subject: [PATCH 2/4] ci: restrict publish/deploy steps to master only --- .github/workflows/deploy-pages.yml | 17 ++++++++++++++++- .github/workflows/java.yml | 11 ++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index 05ba1577..095ad432 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -1,9 +1,19 @@ name: JavaScript CI with Pages on: - pull_request: push: branches: [ master ] + paths: + - 'algorithms-js/**' + - '.github/workflows/deploy-pages.yml' + pull_request: + branches: [ master ] + paths: + - 'algorithms-js/**' + - '.github/workflows/deploy-pages.yml' + +env: + IS_MASTER: ${{ github.ref == 'refs/heads/master' }} jobs: build: @@ -31,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 @@ -40,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 @@ -49,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/java.yml b/.github/workflows/java.yml index 30bc3263..695a3b87 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -2,12 +2,11 @@ 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' pull_request: - # Only run for PRs targeting master branches: [ master ] paths: - 'algorithms-java/**' @@ -16,6 +15,8 @@ on: 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 From d5e3871d86b99da701fe23e9885b8bace82f4c62 Mon Sep 17 00:00:00 2001 From: sachinlala Date: Sat, 9 Aug 2025 05:51:13 +0530 Subject: [PATCH 3/4] CI: rename workflows to uniform ci-* names and update path filters --- .github/workflows/{java.yml => ci-java.yml} | 4 ++-- .github/workflows/{deploy-pages.yml => ci-js-pages.yml} | 4 ++-- .github/workflows/{soft-review.yml => ci-soft-review.yml} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{java.yml => ci-java.yml} (95%) rename .github/workflows/{deploy-pages.yml => ci-js-pages.yml} (94%) rename .github/workflows/{soft-review.yml => ci-soft-review.yml} (100%) diff --git a/.github/workflows/java.yml b/.github/workflows/ci-java.yml similarity index 95% rename from .github/workflows/java.yml rename to .github/workflows/ci-java.yml index 695a3b87..6c48a902 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/ci-java.yml @@ -5,12 +5,12 @@ on: branches: [ master ] paths: - 'algorithms-java/**' - - '.github/workflows/java.yml' + - '.github/workflows/ci-java.yml' pull_request: branches: [ master ] paths: - 'algorithms-java/**' - - '.github/workflows/java.yml' + - '.github/workflows/ci-java.yml' jobs: test: diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/ci-js-pages.yml similarity index 94% rename from .github/workflows/deploy-pages.yml rename to .github/workflows/ci-js-pages.yml index 095ad432..184aa765 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/ci-js-pages.yml @@ -5,12 +5,12 @@ on: 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/deploy-pages.yml' + - '.github/workflows/ci-js-pages.yml' env: IS_MASTER: ${{ github.ref == 'refs/heads/master' }} diff --git a/.github/workflows/soft-review.yml b/.github/workflows/ci-soft-review.yml similarity index 100% rename from .github/workflows/soft-review.yml rename to .github/workflows/ci-soft-review.yml From 8cbb86bd7ce80bf1fd28d3840f90f529348c3257 Mon Sep 17 00:00:00 2001 From: sachinlala Date: Sat, 9 Aug 2025 06:18:34 +0530 Subject: [PATCH 4/4] chore: exclude workflow files from soft-review; add CI badges to READMEs --- .github/workflows/ci-soft-review.yml | 4 ++++ README.md | 6 ++++-- algorithms-java/README.md | 1 + algorithms-js/README.md | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-soft-review.yml b/.github/workflows/ci-soft-review.yml index c5b421fa..4befea34 100644 --- a/.github/workflows/ci-soft-review.yml +++ b/.github/workflows/ci-soft-review.yml @@ -35,6 +35,10 @@ jobs: 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 || ''; 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.