Skip to content

fix(compiler): persist polyfills on build #4610

fix(compiler): persist polyfills on build

fix(compiler): persist polyfills on build #4610

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@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
ref: main
if: ${{ matrix.branch == 'main' }}
- name: Checkout PR branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
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/[email protected]
- 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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
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@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
ref: main
if: ${{ matrix.branch == 'main' }}
- name: Checkout PR branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
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 [email protected]
- 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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
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@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
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@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
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@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
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@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
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@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
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@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.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@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
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