This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
forked from ionic-team/stencil
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (136 loc) · 6.88 KB
/
tech-debt-burndown.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: main
if: ${{ matrix.branch == 'main' }}
- name: Checkout PR branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: main
if: ${{ matrix.branch == 'main' }}
- name: Checkout PR branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
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@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.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