-
-
Notifications
You must be signed in to change notification settings - Fork 61
feat: Resolution time benchmark github action #2239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
63227e3
79f8787
1aed4d2
b542027
b124f2b
e40fff6
21a5291
bc342fa
4ef79d2
2c6c86b
780872b
0e34944
861f182
49e7c52
f949f6d
e5954d5
42bfa9f
8129935
18c3673
71e1215
f14d6ae
eef307e
2786f9a
de0fdc2
2ba77a3
fc29929
3564492
6edf7ab
1528003
977432f
1ecac0e
b893cde
c7267eb
bee7952
44d8a49
a79e167
d5046e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| name: Resolution time benchmark | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| resolution-time: | ||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.27.0 | ||
| run_install: false | ||
|
|
||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: pr-branch | ||
|
|
||
| - name: Checkout target branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: target-branch | ||
| ref: ${{ github.base_ref }} | ||
|
|
||
| - name: Checkout latest release | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: release-branch | ||
| ref: release | ||
|
|
||
| - name: Copy resolution-time app to release checkout | ||
| run: | | ||
| if [ ! -d release-branch/apps/resolution-time ]; then | ||
| cp -r target-branch/apps/resolution-time release-branch/apps/resolution-time | ||
| echo "Copied resolution-time app from target branch to release checkout" | ||
| else | ||
| echo "resolution-time app already exists in release checkout" | ||
| fi | ||
|
Comment on lines
+37
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, we only copy the folder if it's missing, right? Will this step be removed after next release?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I included this |
||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'pnpm' | ||
| cache-dependency-path: | | ||
| pr-branch/pnpm-lock.yaml | ||
| target-branch/pnpm-lock.yaml | ||
| release-branch/pnpm-lock.yaml | ||
|
|
||
| - name: Install dependencies (PR branch) | ||
| working-directory: pr-branch | ||
| run: pnpm install --frozen-lockfile && cd apps/resolution-time/node_modules/bun && node install.js | ||
|
|
||
| - name: Install dependencies (target branch) | ||
| working-directory: target-branch | ||
| run: pnpm install --frozen-lockfile && cd apps/resolution-time/node_modules/bun && node install.js | ||
|
|
||
| - name: Install dependencies (release branch) | ||
| working-directory: release-branch | ||
| run: pnpm install --no-frozen-lockfile && cd apps/resolution-time/node_modules/bun && node install.js | ||
|
|
||
| - name: Run benchmark (PR branch) | ||
| working-directory: pr-branch | ||
| run: pnpm --filter resolution-time resolution-time | ||
|
|
||
| - name: Run benchmark (target branch) | ||
| working-directory: target-branch | ||
| run: pnpm --filter resolution-time resolution-time | ||
|
|
||
| - name: Run benchmark (release branch) | ||
| working-directory: release-branch | ||
| run: pnpm --filter resolution-time resolution-time | ||
|
|
||
| - name: Generate chart (random) | ||
| run: | | ||
| node pr-branch/apps/resolution-time/generateChart.ts \ | ||
| --input "PR:pr-branch/apps/resolution-time/results-random.json" \ | ||
| --input "main:target-branch/apps/resolution-time/results-random.json" \ | ||
| --input "release:release-branch/apps/resolution-time/results-random.json" \ | ||
| --title "Random Branching" \ | ||
| --xAxisTitle "max depth" \ | ||
| --yAxisTitle "time (ms)" \ | ||
| --output chart-random.md | ||
|
|
||
| - name: Generate chart (linear) | ||
| run: | | ||
| node pr-branch/apps/resolution-time/generateChart.ts \ | ||
| --input "PR:pr-branch/apps/resolution-time/results-linear-recursion.json" \ | ||
| --input "main:target-branch/apps/resolution-time/results-linear-recursion.json" \ | ||
| --input "release:release-branch/apps/resolution-time/results-linear-recursion.json" \ | ||
| --title "Linear Recursion" \ | ||
| --xAxisTitle "max depth" \ | ||
| --yAxisTitle "time (ms)" \ | ||
| --output chart-linear.md | ||
|
|
||
| - name: Generate chart (max depth) | ||
| run: | | ||
| node pr-branch/apps/resolution-time/generateChart.ts \ | ||
| --input "PR:pr-branch/apps/resolution-time/results-max-depth.json" \ | ||
| --input "main:target-branch/apps/resolution-time/results-max-depth.json" \ | ||
| --input "release:release-branch/apps/resolution-time/results-max-depth.json" \ | ||
| --title "Full Tree" \ | ||
| --xAxisTitle "max depth" \ | ||
| --yAxisTitle "time (ms)" \ | ||
| --output chart-max-depth.md | ||
|
|
||
| - name: Prepare comment | ||
| run: | | ||
| { | ||
| echo "## Resolution Time Benchmark" | ||
| echo "" | ||
| cat chart-random.md | ||
| echo "" | ||
| cat chart-linear.md | ||
| echo "" | ||
| cat chart-max-depth.md | ||
| } > comparison.md | ||
|
|
||
| - name: Comment PR with results | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const comparison = fs.readFileSync('comparison.md', 'utf8'); | ||
|
|
||
| const botCommentIdentifier = '<!-- resolution-time-bot-comment -->'; | ||
|
|
||
| async function findBotComment(issueNumber) { | ||
| if (!issueNumber) return null; | ||
| const comments = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issueNumber, | ||
| }); | ||
| return comments.data.find((comment) => | ||
| comment.body.includes(botCommentIdentifier) | ||
| ); | ||
cieplypolar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| async function createOrUpdateComment(issueNumber) { | ||
| if (!issueNumber) { | ||
| console.log('No issue number provided. Cannot post or update comment.'); | ||
| return; | ||
| } | ||
|
|
||
| const existingComment = await findBotComment(issueNumber); | ||
| if (existingComment) { | ||
| await github.rest.issues.updateComment({ | ||
| ...context.repo, | ||
| comment_id: existingComment.id, | ||
| body: botCommentIdentifier + '\n' + comparison, | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| ...context.repo, | ||
| issue_number: issueNumber, | ||
| body: botCommentIdentifier + '\n' + comparison, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const issueNumber = context.issue.number; | ||
| if (!issueNumber) { | ||
| console.log('No issue number found in context. Skipping comment.'); | ||
| } else { | ||
| await createOrUpdateComment(issueNumber); | ||
| } | ||
| await core.summary | ||
| .addRaw(comparison) | ||
| .write(); | ||
Uh oh!
There was an error while loading. Please reload this page.