|
| 1 | +name: Tech Debt Burndown |
| 2 | +# this workflow is for reporting on various metrics for the codebase that |
| 3 | +# we want to pay attention to. Generally these are checks of some sort that we'll |
| 4 | +# want to eventually 'graduate' to full CI checks (which cause builds to fail if |
| 5 | +# there are any errors) once we've eliminated all the problems, but until that |
| 6 | +# point we run them here, separate from the main build, and write a report on our |
| 7 | +# progress on them to each PR. |
| 8 | + |
| 9 | +on: |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - '**' |
| 13 | + |
| 14 | +jobs: |
| 15 | + strict_null_check: # TODO(STENCIL-446): Remove this workflow once `strictNullChecks` is enabled |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + branch: [ 'main', 'pr' ] |
| 19 | + name: 'Get strictNullChecks errors on ${{ matrix.branch }}' |
| 20 | + runs-on: 'ubuntu-latest' |
| 21 | + steps: |
| 22 | + - name: Checkout main |
| 23 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
| 24 | + with: |
| 25 | + ref: main |
| 26 | + if: ${{ matrix.branch == 'main' }} |
| 27 | + |
| 28 | + - name: Checkout PR branch |
| 29 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
| 30 | + if: ${{ matrix.branch == 'pr' }} |
| 31 | + |
| 32 | + - name: Get Core Dependencies |
| 33 | + uses: ./.github/workflows/actions/get-core-dependencies |
| 34 | + |
| 35 | + - name: Install tsc-output-parser |
| 36 | + run: npm install @aivenio/[email protected] |
| 37 | + |
| 38 | + - name: Run Typescript compiler and generate JSON-formatted error file |
| 39 | + run: npx tsc --strictNullChecks --noEmit --pretty false | npx tsc-output-parser > null_errors_${{ matrix.branch }}.json |
| 40 | + |
| 41 | + - name: Upload null_errors_${{ matrix.branch }}.json |
| 42 | + uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0 |
| 43 | + with: |
| 44 | + name: null_errors_${{ matrix.branch }} |
| 45 | + path: 'null_errors_${{ matrix.branch }}.json' |
| 46 | + |
| 47 | + # TODO(STENCIL-454): Remove or change this up once we've eliminated unused exports |
| 48 | + unused_exports_check: |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + branch: [ 'main', 'pr' ] |
| 52 | + name: Find unused variables on ${{ matrix.branch }} |
| 53 | + runs-on: 'ubuntu-latest' |
| 54 | + steps: |
| 55 | + - name: Checkout main |
| 56 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
| 57 | + with: |
| 58 | + ref: main |
| 59 | + if: ${{ matrix.branch == 'main' }} |
| 60 | + |
| 61 | + - name: Checkout PR branch |
| 62 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
| 63 | + if: ${{ matrix.branch == 'pr' }} |
| 64 | + |
| 65 | + - name: Install ts-prune |
| 66 | + run: npm install [email protected] |
| 67 | + |
| 68 | + - name: Run ts-prune and write output to disk |
| 69 | + run: npx ts-prune > unused-exports-${{ matrix.branch }}.txt |
| 70 | + |
| 71 | + - name: Upload unused exports |
| 72 | + uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0 |
| 73 | + with: |
| 74 | + name: unused-exports-${{ matrix.branch }} |
| 75 | + path: 'unused-exports-${{ matrix.branch }}.txt' |
| 76 | + |
| 77 | + format_report: |
| 78 | + needs: [ "strict_null_check", "unused_exports_check" ] |
| 79 | + name: Download error files and report |
| 80 | + runs-on: 'ubuntu-latest' |
| 81 | + steps: |
| 82 | + - name: Checkout current branch |
| 83 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
| 84 | + |
| 85 | + - name: Get Core Dependencies |
| 86 | + uses: ./.github/workflows/actions/get-core-dependencies |
| 87 | + |
| 88 | + # TODO(STENCIL-446): Remove this workflow once `strictNullChecks` is enabled |
| 89 | + - name: Download null errors file for main branch |
| 90 | + uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0 |
| 91 | + with: |
| 92 | + name: null_errors_main |
| 93 | + |
| 94 | + # TODO(STENCIL-446): Remove this workflow once `strictNullChecks` is enabled |
| 95 | + - name: Download null errors file for PR |
| 96 | + uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0 |
| 97 | + with: |
| 98 | + name: null_errors_pr |
| 99 | + |
| 100 | + # TODO(STENCIL-454): Remove or change this up once we've eliminated unused exports |
| 101 | + - name: Download unused exports for main |
| 102 | + uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0 |
| 103 | + with: |
| 104 | + name: unused-exports-main |
| 105 | + |
| 106 | + # TODO(STENCIL-454): Remove or change this up once we've eliminated unused exports |
| 107 | + - name: Download unused exports for PR |
| 108 | + uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0 |
| 109 | + with: |
| 110 | + name: unused-exports-pr |
| 111 | + |
| 112 | + - name: Compile scripts |
| 113 | + run: node scripts --prepare |
| 114 | + |
| 115 | + - name: Set action output |
| 116 | + run: node scripts/build/tech-debt-burndown-report.js > $GITHUB_STEP_SUMMARY |
| 117 | + |
| 118 | + # for syntax information, see https://github.com/peter-evans/create-or-update-comment#setting-the-comment-body-from-a-file |
| 119 | + - name: Set comment body |
| 120 | + id: set-comment-body |
| 121 | + run: | |
| 122 | + body=$(node scripts/build/tech-debt-burndown-report.js) |
| 123 | + body="${body//'%'/'%25'}" |
| 124 | + body="${body//$'\n'/'%0A'}" |
| 125 | + body="${body//$'\r'/'%0D'}" |
| 126 | + echo ::set-output name=body::$body |
| 127 | +
|
| 128 | + - name: Find Comment |
| 129 | + uses: peter-evans/find-comment@1769778a0c5bd330272d749d12c036d65e70d39d # v2.0.0 |
| 130 | + id: fc |
| 131 | + with: |
| 132 | + issue-number: ${{ github.event.pull_request.number }} |
| 133 | + comment-author: 'github-actions[bot]' |
| 134 | + body-includes: '### `--strictNullChecks` error report' |
| 135 | + |
| 136 | + - name: Create or update comment |
| 137 | + uses: peter-evans/create-or-update-comment@c9fcb64660bc90ec1cc535646af190c992007c32 # v2.0.0 |
| 138 | + with: |
| 139 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 140 | + issue-number: ${{ github.event.pull_request.number }} |
| 141 | + body: ${{ steps.set-comment-body.outputs.body }} |
| 142 | + edit-mode: replace |
0 commit comments