Skip to content

Commit

Permalink
chore: add jobs for type-check-perf-monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
m-shaka committed Sep 13, 2024
1 parent eda7540 commit 3290558
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,54 @@ jobs:
with:
name: coverage-lambda-edge
path: coverage/

type-check-perf-monitoring-on-pr:
runs-on: ubuntu-latest
permissions:
contents: 'read'
pull-requests: 'write'
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- uses: actions/cache/restore@v4
with:
path: type-check-perf/previous-result.txt
restore-keys: |
type-check-perf-previous-result-
key: type-check-perf-previous-result-
- run: bun generate-app.ts
working-directory: type-check-perf
- run: bun tsc --diagnostics > result.txt
working-directory: type-check-perf
- run: |
{
echo 'COMPARISON<<EOF'
bun process-results.ts
echo 'EOF'
} >> "$GITHUB_ENV"
working-directory: type-check-perf
- run: echo "$COMPARISON"
# remove the comment out after we make sure that caching is working
# - uses: thollander/actions-comment-pull-request@v2
# with:
# comment_tag: type-check-perf
# message: ${{ env.COMPARISON }}


post-type-check-perf-on-main:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun generate-app.ts
working-directory: type-check-perf
- run: bun tsc --diagnostics > previous-result.txt
working-directory: type-check-perf
- uses: actions/cache/save@v4
with:
path: type-check-perf/previous-result.txt
key: type-check-perf-previous-result-${{ github.sha }}
19 changes: 19 additions & 0 deletions type-check-perf/process-results.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as fs from 'node:fs/promises'

Check warning on line 1 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L1

Added line #L1 was not covered by tests

async function main() {
const currentResult = (await fs.readFile('./result.txt')).toString().split('\n')
const previousResult = await fs.readFile('./previous-result.txt')
.then((data) => data.toString().split('\n'))
.catch(() => null)

Check warning on line 7 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L3-L7

Added lines #L3 - L7 were not covered by tests
// currentResultとpreviousResultを結合してmarkdownのテーブルを作る
const table = ['|| Current | Previous |', '|---|---|---|']
for (const [i, line] of currentResult.entries()) {
if (line === '') continue;
const [name, value] = line.split(':')
const mainValue = previousResult?.[i]?.split(':')?.[1]
table.push(`| ${name?.trim()} | ${value?.trim()} | ${mainValue ? mainValue.trim() : 'N/A'} |`)
}
console.log(table.join('\n'))
}

Check warning on line 17 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L9-L17

Added lines #L9 - L17 were not covered by tests

main()

Check warning on line 19 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L19

Added line #L19 was not covered by tests
3 changes: 2 additions & 1 deletion type-check-perf/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"module": "esnext",
"noEmit": true,
"rootDir": ".."
"rootDir": "..",
"strict": true
},
"include": [
"**/*.ts",
Expand Down

0 comments on commit 3290558

Please sign in to comment.