diff --git a/.github/workflows/ui-checkstyle.yml b/.github/workflows/ui-checkstyle.yml index 82835cfbd9da..f7a3863689bf 100644 --- a/.github/workflows/ui-checkstyle.yml +++ b/.github/workflows/ui-checkstyle.yml @@ -82,7 +82,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write + outputs: + changed_files: ${{ steps.lint.outputs.changed_files }} steps: - uses: actions/checkout@v4 with: @@ -140,51 +141,6 @@ jobs: exit 1 fi - - name: Find existing lint comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ Lint Check Failed — ESLint + Prettier + Organise Imports (src) - - The following files have style issues that need to be fixed: - ${{ steps.changed-files.outputs.all_changed_files }} - - **Fix locally (fast — only for changed files in the branch):** - ```bash - make ui-checkstyle-src-changed - ``` - Or to fix all files: - ```bash - make ui-checkstyle-src - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 2: Licence Header Check (all changed files) # ────────────────────────────────────────────────────────────────────────── @@ -193,7 +149,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write + outputs: + changed_files: ${{ steps.license.outputs.changed_files }} steps: - uses: actions/checkout@v4 with: @@ -242,47 +199,6 @@ jobs: exit 1 fi - - name: Find existing licence comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ Licence Header Check Failed - - The following files are missing or have outdated licence headers: - ${{ steps.changed-files.outputs.all_changed_files }} - - **Fix locally:** - ```bash - make license-header-fix - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 3: TypeScript Type Check (src) # ────────────────────────────────────────────────────────────────────────── @@ -292,7 +208,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write steps: - uses: actions/checkout@v4 with: @@ -323,53 +238,6 @@ jobs: exit 1 fi - - name: Find existing tsc comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ TypeScript Type Check Failed (src) - -
- View type errors (first 50 lines) - - ``` - ${{ steps.tsc.outputs.tsc_errors }} - ``` - -
- - **Run locally to get details about typescript errors:** - ```bash - make tsc-src-fix - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 4: I18n Sync # ────────────────────────────────────────────────────────────────────────── @@ -378,7 +246,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write + outputs: + changed_files: ${{ steps.i18n.outputs.changed_files }} steps: - uses: actions/checkout@v4 with: @@ -412,47 +281,6 @@ jobs: exit 1 fi - - name: Find existing i18n comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ I18n Sync Check Failed - - Translation files are out of sync. Changed files: - ${{ steps.i18n.outputs.changed_files }} - - **Fix locally:** - ```bash - make i18n-sync-fix - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 5: generate:app-docs # ────────────────────────────────────────────────────────────────────────── @@ -461,7 +289,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write + outputs: + changed_files: ${{ steps.docs.outputs.changed_files }} steps: - uses: actions/checkout@v4 with: @@ -495,47 +324,6 @@ jobs: exit 1 fi - - name: Find existing app-docs comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ App Docs Check Failed - - Generated app docs are stale. Changed files: - ${{ steps.docs.outputs.changed_files }} - - **Fix locally:** - ```bash - make generate-app-docs - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 6: Playwright — ESLint + Prettier + Organise Imports # ────────────────────────────────────────────────────────────────────────── @@ -544,7 +332,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write + outputs: + changed_files: ${{ steps.lint.outputs.changed_files }} steps: - uses: actions/checkout@v4 with: @@ -599,51 +388,6 @@ jobs: exit 1 fi - - name: Find existing playwright lint comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ Playwright Lint Check Failed — ESLint + Prettier + Organise Imports - - The following files have style issues that need to be fixed: - ${{ steps.changed-files.outputs.all_changed_files }} - - **Fix locally (fast — only for changed files in the branch):** - ```bash - make ui-checkstyle-playwright-changed - ``` - Or to fix all playwright files: - ```bash - make ui-checkstyle-playwright - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 7: Playwright — TypeScript Type Check # ────────────────────────────────────────────────────────────────────────── @@ -653,7 +397,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write steps: - uses: actions/checkout@v4 with: @@ -700,53 +443,6 @@ jobs: exit 1 fi - - name: Find existing playwright tsc comment - if: ${{ always() && github.event_name == 'pull_request_target' }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: github-actions[bot] - body-includes: '' - - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ TypeScript Type Check Failed (playwright) - -
- View type errors (first 50 lines) - - ``` - ${{ steps.tsc.outputs.tsc_errors }} - ``` - -
- - **Run locally to get details about typescript errors::** - ```bash - make tsc-playwright-fix - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} - uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} - with: - script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) - # ────────────────────────────────────────────────────────────────────────── # Job 8: Core Components — ESLint + Prettier # ────────────────────────────────────────────────────────────────────────── @@ -755,7 +451,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write + outputs: + changed_files: ${{ steps.lint.outputs.changed_files }} steps: - uses: actions/checkout@v4 with: @@ -805,47 +502,113 @@ jobs: exit 1 fi - - name: Find existing lint comment - if: ${{ always() && github.event_name == 'pull_request_target' }} + # ────────────────────────────────────────────────────────────────────────── + # Job 9: Report — Post single consolidated summary comment + # ────────────────────────────────────────────────────────────────────────── + report: + needs: [authorize, lint-src, license-header, i18n-sync, app-docs, lint-playwright, lint-core-components] + if: ${{ always() && needs.authorize.result == 'success' && github.event_name == 'pull_request_target' }} + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Find existing summary comment uses: peter-evans/find-comment@v3 id: fc with: issue-number: ${{ github.event.pull_request.number }} comment-author: github-actions[bot] - body-includes: '' + body-includes: '' - - name: Post failure comment - if: ${{ failure() && github.event_name == 'pull_request_target' }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - - ### ❌ Lint Check Failed — ESLint + Prettier (core-components) - - The following files have style issues that need to be fixed: - ${{ steps.changed-files.outputs.all_changed_files }} - - **Fix locally (fast — only for changed files in the branch):** - ```bash - make ui-checkstyle-core-components-changed - ``` - Or to fix all files: - ```bash - make ui-checkstyle-core-components - ``` - edit-mode: replace - - - name: Delete comment on success - if: ${{ success() && steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request_target' }} + - name: Post or update summary comment uses: actions/github-script@v7 - env: - COMMENT_ID: ${{ steps.fc.outputs.comment-id }} with: script: | - github.rest.issues.deleteComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: process.env.COMMENT_ID - }) + const checks = [ + { + name: 'ESLint + Prettier + Organise Imports (src)', + reason: 'One or more source files have linting or formatting issues.', + result: '${{ needs.lint-src.result }}', + files: ${{ toJSON(needs.lint-src.outputs.changed_files) }} || '', + }, + { + name: 'Licence Header', + reason: 'One or more files are missing or have an outdated Apache 2.0 licence header.', + result: '${{ needs.license-header.result }}', + files: ${{ toJSON(needs.license-header.outputs.changed_files) }} || '', + }, + { + name: 'I18n Sync', + reason: 'Translation locale files are out of sync with `en-us.json`.', + result: '${{ needs.i18n-sync.result }}', + files: ${{ toJSON(needs.i18n-sync.outputs.changed_files) }} || '', + }, + { + name: 'App Docs', + reason: 'Generated application docs are stale and need to be regenerated.', + result: '${{ needs.app-docs.result }}', + files: ${{ toJSON(needs.app-docs.outputs.changed_files) }} || '', + }, + { + name: 'Playwright — ESLint + Prettier + Organise Imports', + reason: 'One or more Playwright test files have linting or formatting issues.', + result: '${{ needs.lint-playwright.result }}', + files: ${{ toJSON(needs.lint-playwright.outputs.changed_files) }} || '', + }, + { + name: 'Core Components — ESLint + Prettier', + reason: 'One or more core-component files have linting or formatting issues.', + result: '${{ needs.lint-core-components.result }}', + files: ${{ toJSON(needs.lint-core-components.outputs.changed_files) }} || '', + }, + ]; + + const failures = checks.filter(c => c.result === 'failure'); + const commentId = '${{ steps.fc.outputs.comment-id }}'; + + if (failures.length === 0) { + if (commentId) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: parseInt(commentId, 10), + }); + } + return; + } + + const sections = failures.map(c => { + const lines = [`#### ❌ ${c.name}`, c.reason]; + if (c.files && c.files.trim()) { + lines.push('', '
Affected files', '', c.files.trim(), '', '
'); + } + return lines.join('\n'); + }); + + const body = [ + '', + '### ❌ UI Checkstyle Failed', + '', + ...sections.flatMap(s => [s, '']), + '---', + '**Fix locally (fast — only checks files changed in this branch):**', + '```bash', + 'make ui-checkstyle-changed', + '```', + ].join('\n'); + + if (commentId) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: parseInt(commentId, 10), + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } diff --git a/Makefile b/Makefile index 8dff33824274..6f9a9bb530cd 100644 --- a/Makefile +++ b/Makefile @@ -273,3 +273,15 @@ ui-checkstyle-playwright-changed: .PHONY: ui-checkstyle-core-components-changed ui-checkstyle-core-components-changed: cd openmetadata-ui-core-components/src/main/resources/ui && yarn install --frozen-lockfile && yarn ui-checkstyle:changed + +# Run all full UI checkstyle operations with one command. +.PHONY: ui-checkstyle-all +ui-checkstyle-all: + cd openmetadata-ui/src/main/resources/ui && yarn install --frozen-lockfile && yarn ui-checkstyle && yarn ui-checkstyle:playwright + cd openmetadata-ui-core-components/src/main/resources/ui && yarn install --frozen-lockfile && yarn lint:fix && yarn pretty + +# Run all changed-file UI checkstyle operations with one command. +.PHONY: ui-checkstyle-changed +ui-checkstyle-changed: + cd openmetadata-ui/src/main/resources/ui && yarn install --frozen-lockfile && yarn ui-checkstyle:changed && yarn ui-checkstyle:playwright:changed + cd openmetadata-ui-core-components/src/main/resources/ui && yarn install --frozen-lockfile && yarn ui-checkstyle:changed