ENG-2213: Reorganize services, connectors, and shared modules #5399
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: Check PR Size | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| check-pr-size: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check PR size | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| // Fetch all files (handles pagination automatically) | |
| const files = await github.paginate(github.rest.pulls.listFiles, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: pr.number, | |
| }); | |
| const AUTOGENERATED_PATHS = [ | |
| 'clients/admin-ui/src/types/api/', | |
| 'clients/fides-js/docs/', | |
| ]; | |
| const nonExcludedFiles = files.filter(file => { | |
| if (file.status === 'renamed') return false; | |
| if (file.filename.endsWith('__init__.py') && file.additions === 0 && file.deletions === 0) return false; | |
| if (AUTOGENERATED_PATHS.some(p => file.filename.startsWith(p))) return false; | |
| return true; | |
| }); | |
| const totalLinesChanged = nonExcludedFiles.reduce((sum, file) => sum + file.additions, 0); | |
| const changedFiles = nonExcludedFiles.length; | |
| const linesLimit = 500; | |
| const filesLimit = 15; | |
| let failMessage = ''; | |
| if (totalLinesChanged > linesLimit) { | |
| const lineWord = totalLinesChanged === 1 ? 'Line' : 'Lines'; | |
| failMessage += `${lineWord} changed: ${totalLinesChanged} (limit: ${linesLimit})\n`; | |
| } | |
| if (changedFiles > filesLimit) { | |
| const fileWord = changedFiles === 1 ? 'File' : 'Files'; | |
| failMessage += `${fileWord} changed: ${changedFiles} (limit: ${filesLimit})\n`; | |
| } | |
| if (failMessage) { | |
| const excludedCount = files.length - nonExcludedFiles.length; | |
| if (excludedCount > 0) { | |
| const excludedFileWord = excludedCount === 1 ? 'file' : 'files'; | |
| failMessage += `(${excludedCount} ${excludedFileWord} excluded: renamed files, empty __init__.py, and auto-generated API types, docs, etc.)\n`; | |
| } | |
| failMessage += '\nPlease consider splitting this PR into smaller, more focused changes.'; | |
| core.setFailed(failMessage); | |
| } else { | |
| const excludedCount = files.length - nonExcludedFiles.length; | |
| const lineWord = totalLinesChanged === 1 ? 'line' : 'lines'; | |
| const fileWord = changedFiles === 1 ? 'file' : 'files'; | |
| const excludedFileWord = excludedCount === 1 ? 'file' : 'files'; | |
| console.log(`PR size check passed (${totalLinesChanged} ${lineWord}, ${changedFiles} ${fileWord}${excludedCount > 0 ? `, ${excludedCount} ${excludedFileWord} excluded` : ''})`); | |
| } |