diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4cf3034..dc4e4d0 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -35,39 +35,3 @@ jobs: uses: github/codeql-action/analyze@v2 with: category: "/language:${{matrix.language}}" - - name: Post failure comment - if: always() - # if: failure() - uses: actions/github-script@v6 - with: - script: | - const conclusion = '${{ steps.perform-codeql-analysis.conclusion }}'; - const outcome = '${{ steps.perform-codeql-analysis.outcome }}'; - const sarif = '${{ steps.perform-codeql-analysis.outputs.db-locations }}'; - const commentBody = ` - ## CodeQL Analysis - ${conclusion} - ${outcome} - ${sarif} - `; - const { data: comments } = await github.rest.issues.listComments({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo - }); - const comment = comments.find(comment => comment.body.includes('CodeQL Analysis')); - if (comment) { - await github.rest.issues.updateComment({ - comment_id: comment.id, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); - } else { - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); - } diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 650a55b..cd197b2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -75,81 +75,59 @@ jobs: git add -A git commit -m '[automated commit] lint format and import sort' git push - - name: Post coverage comment + - name: PR checks complete if: always() uses: actions/github-script@v6 with: script: | const fs = require('fs'); + const steps = [ + { name: 'Install dependencies', conclusion: '${{ steps.install-dependencies.outcome }}' }, + { name: 'Run custom elements manifest analyzer', conclusion: '${{ steps.run-custom-elements-manifest-analyzer.outcome }}' }, + { name: 'Run eslint', conclusion: '${{ steps.run-eslint.outcome }}' }, + { name: 'Run prettier', conclusion: '${{ steps.run-prettier.outcome }}' }, + { name: 'Run lit-analyzer', conclusion: '${{ steps.run-lit-analyzer.outcome }}' }, + { name: 'Run tests and generate coverage', conclusion: '${{ steps.run-tests-and-generate-coverage.outcome }}' }, + { name: 'Test tsdoc', conclusion: '${{ steps.test-tsdoc.outcome }}' }, + { name: 'Check for modified files', conclusion: '${{ steps.git-check.outcome }}' }, + { name: 'Update changes in GitHub repository', conclusion: '${{ steps.update-changes-in-github-repository.outcome }}' } + ] + const failedSteps = steps.filter(step => step.conclusion === 'failure'); + const skippedSteps = steps.filter(step => step.conclusion === 'skipped'); + const passedSteps = steps.filter(step => step.conclusion === 'success'); + + const failedStepsDetails = failedSteps.map(step => `- ❌ - ${step.name} failed`).join('\n'); + const skippedStepsDetails = skippedSteps.map(step => `- ⏭️ - ${step.name} skipped`).join('\n'); + const passedStepsDetails = passedSteps.map(step => `- ✅ - ${step.name} passed`).join('\n'); + const coverage = fs.readFileSync("coverage/lcov-report/index.html", "utf8"); const coverageData = coverage .split('') .pop() ?.split("
")[0] .replaceAll(/]*>([^<]*)<\/a>/g, "$1"); + const commentBody = ` - ## Test Coverage Report + ## PR Checks Complete + ${failedSteps.length > 0 ? `${failedStepsDetails}` : ''} + ${skippedSteps.length > 0 ? `${skippedStepsDetails}` : ''} + ${passedSteps.length > 0 ? `${passedStepsDetails}` : ''}
- Code Coverage Report + 📈 - Code Coverage Report ${coverageData}
- `; - const { data: comments } = await github.rest.issues.listComments({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo - }); - const comment = comments.find(comment => comment.body.includes('Test Coverage Report')); - if (comment) { - await github.rest.issues.updateComment({ - comment_id: comment.id, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); - } else { - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); - } - - name: Post failure comment - if: always() - uses: actions/github-script@v6 - with: - script: | - const failedSteps = [ - { name: 'Install dependencies', conclusion: '${{ steps.install-dependencies.outcome }}' }, - { name: 'Run custom elements manifest analyzer', conclusion: '${{ steps.run-custom-elements-manifest-analyzer.outcome }}' }, - { name: 'Run eslint', conclusion: '${{ steps.run-eslint.outcome }}' }, - { name: 'Run prettier', conclusion: '${{ steps.run-prettier.outcome }}' }, - { name: 'Run lit-analyzer', conclusion: '${{ steps.run-lit-analyzer.outcome }}' }, - { name: 'Run tests and generate coverage', conclusion: '${{ steps.run-tests-and-generate-coverage.outcome }}' }, - { name: 'Test tsdoc', conclusion: '${{ steps.test-tsdoc.outcome }}' }, - { name: 'Check for modified files', conclusion: '${{ steps.git-check.outcome }}' }, - { name: 'Update changes in GitHub repository', conclusion: '${{ steps.update-changes-in-github-repository.outcome }}' } - ].filter(step => step.conclusion === 'failure'); - const failedStepsDetails = failedSteps.map(step => `- ${step.name}`).join('\n'); - const commentBody = failedSteps.length > 0 ? ` - ## Code Quality Checks - The following checks failed: - ${failedStepsDetails} - ` : ` - ## Code Quality Checks - All code quality checks passed. `; + const { data: comments } = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo }); - const comment = comments.find(comment => comment.body.includes('Code Quality Checks')); + const comment = comments.find(comment => comment.body.includes('PR Checks Complete')); if (comment) { await github.rest.issues.updateComment({ comment_id: comment.id, @@ -165,6 +143,7 @@ jobs: body: commentBody }); } + generate-localizations: name: Generate localizations. needs: [code-quality]