Skip to content

fix(build): address dist bundle size issue #6376

fix(build): address dist bundle size issue

fix(build): address dist bundle size issue #6376

name: Tech Debt Burndown
# this workflow is for reporting on various metrics for the codebase that
# we want to pay attention to. Generally these are checks of some sort that we'll
# want to eventually 'graduate' to full CI checks (which cause builds to fail if
# there are any errors) once we've eliminated all the problems, but until that
# point we run them here, separate from the main build, and write a report on our
# progress on them to each PR.
on:
pull_request_target:
branches:
- '**'
jobs:
strict_null_check: # TODO(STENCIL-446): Remove this workflow once `strictNullChecks` is enabled
strategy:
matrix:
branch: ['main', 'pr']
name: 'Get strictNullChecks errors on ${{ matrix.branch }}'
runs-on: 'ubuntu-22.04'
steps:
- name: Checkout main
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
ref: main
if: ${{ matrix.branch == 'main' }}
- name: Checkout PR branch
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
# the pull_request_target event will consider the HEAD of `main` to be the SHA to use.
# attempt to use the SHA associated with a pull request and fallback to HEAD of `main`
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }}
persist-credentials: false
if: ${{ matrix.branch == 'pr' }}
- name: Get Core Dependencies
uses: ./.github/workflows/actions/get-core-dependencies
- name: Install tsc-output-parser
run: npm install @aivenio/tsc-output-parser@2.1.1
- name: Run Typescript compiler and generate JSON-formatted error file
run: npx tsc --strictNullChecks --noEmit --pretty false | npx tsc-output-parser > null_errors_${{ matrix.branch }}.json
- name: Upload null_errors_${{ matrix.branch }}.json
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
with:
name: null_errors_${{ matrix.branch }}
path: 'null_errors_${{ matrix.branch }}.json'
# TODO(STENCIL-454): Remove or change this up once we've eliminated unused exports
unused_exports_check:
strategy:
matrix:
branch: ['main', 'pr']
name: Find unused variables on ${{ matrix.branch }}
runs-on: 'ubuntu-22.04'
steps:
- name: Checkout main
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
ref: main
if: ${{ matrix.branch == 'main' }}
- name: Checkout PR branch
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
# the pull_request_target event will consider the HEAD of `main` to be the SHA to use.
# attempt to use the SHA associated with a pull request and fallback to HEAD of `main`
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }}
persist-credentials: false
if: ${{ matrix.branch == 'pr' }}
- name: Install ts-prune
run: npm install ts-prune@0.10.3
- name: Run ts-prune and write output to disk
run: npx ts-prune > unused-exports-${{ matrix.branch }}.txt
- name: Upload unused exports
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
with:
name: unused-exports-${{ matrix.branch }}
path: 'unused-exports-${{ matrix.branch }}.txt'
format_report:
needs: ['strict_null_check', 'unused_exports_check']
name: Download error files and report
runs-on: 'ubuntu-22.04'
steps:
- name: Checkout current branch
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
# the pull_request_target event will consider the HEAD of `main` to be the SHA to use.
# attempt to use the SHA associated with a pull request and fallback to HEAD of `main`
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }}
persist-credentials: false
- name: Get Core Dependencies
uses: ./.github/workflows/actions/get-core-dependencies
# TODO(STENCIL-446): Remove this workflow once `strictNullChecks` is enabled
- name: Download null errors file for main branch
uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5
with:
name: null_errors_main
# TODO(STENCIL-446): Remove this workflow once `strictNullChecks` is enabled
- name: Download null errors file for PR
uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5
with:
name: null_errors_pr
# TODO(STENCIL-454): Remove or change this up once we've eliminated unused exports
- name: Download unused exports for main
uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5
with:
name: unused-exports-main
# TODO(STENCIL-454): Remove or change this up once we've eliminated unused exports
- name: Download unused exports for PR
uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5
with:
name: unused-exports-pr
- name: Compile scripts
run: npm run tsc.scripts
- name: Set action output
run: node scripts/build/tech-debt-burndown-report.js > $GITHUB_STEP_SUMMARY
# for syntax information, see https://github.com/peter-evans/create-or-update-comment#setting-the-comment-body-from-a-file
- name: Set comment body
id: set-comment-body
# GitHub - "Warning: Make sure the delimiter you're using is randomly generated and unique for each run.
# For more information, see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections"
run: |
body=$(node scripts/build/tech-debt-burndown-report.js)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "body<<$EOF" >> $GITHUB_OUTPUT
echo "$body" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '### `--strictNullChecks` error report'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.set-comment-body.outputs.body }}
edit-mode: replace