|
| 1 | +name: JavaScript Linting |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ master ] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + pull-requests: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + lint-changed-files: |
| 13 | + name: Lint Changed JavaScript Files (Blocking) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: '20.x' |
| 26 | + cache: 'npm' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Get changed JavaScript files |
| 32 | + id: changed-js-files |
| 33 | + uses: tj-actions/changed-files@v45 |
| 34 | + with: |
| 35 | + files: '**/*.js' |
| 36 | + files_ignore: | |
| 37 | + node_modules/** |
| 38 | + core/main/client/lib/** |
| 39 | + **/*.min.js |
| 40 | + extensions/admin_ui/media/javascript-min/** |
| 41 | + separator: ' ' |
| 42 | + |
| 43 | + - name: Lint changed JavaScript files |
| 44 | + if: steps.changed-js-files.outputs.any_changed == 'true' |
| 45 | + run: | |
| 46 | + echo "Linting ${{ steps.changed-js-files.outputs.all_changed_files_count }} changed JavaScript file(s)" |
| 47 | + npx eslint ${{ steps.changed-js-files.outputs.all_changed_files }} |
| 48 | +
|
| 49 | + - name: No JavaScript files changed |
| 50 | + if: steps.changed-js-files.outputs.any_changed == 'false' |
| 51 | + run: | |
| 52 | + echo "No JavaScript files were changed in this PR. Skipping ESLint." |
| 53 | +
|
| 54 | + lint-all-files: |
| 55 | + name: Lint All JavaScript Files (Non-blocking Report) |
| 56 | + runs-on: ubuntu-latest |
| 57 | + continue-on-error: true |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Setup Node.js |
| 64 | + uses: actions/setup-node@v4 |
| 65 | + with: |
| 66 | + node-version: '20.x' |
| 67 | + cache: 'npm' |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: npm ci |
| 71 | + |
| 72 | + - name: Lint all JavaScript files (report-only) |
| 73 | + run: | |
| 74 | + echo "Running ESLint on entire codebase" |
| 75 | + echo "This is a report-only job and will not block the PR." |
| 76 | + npx eslint "**/*.js" || true |
| 77 | +
|
| 78 | + - name: Summary |
| 79 | + if: always() |
| 80 | + run: | |
| 81 | + echo "Full codebase linting completed. Check the logs above for details." |
| 82 | + echo "This job does not affect PR merge status." |
0 commit comments