-
Notifications
You must be signed in to change notification settings - Fork 1
Ci benchmark workflows #28
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
Changes from all commits
1f35f2c
389fcd3
d3c6059
4886daa
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,104 @@ | ||
| name: Benchmark PR vs frameworks | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| benchmark: | ||
| name: Benchmark | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| npm_config_legacy_peer_deps: "true" | ||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "lts/*" | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
|
|
||
| - name: Install repository dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build repository | ||
| run: npm run build | ||
|
|
||
| - name: Clone benchmark suite | ||
| run: git clone --depth=1 https://github.com/milomg/js-reactivity-benchmark.git .tmp/js-reactivity-benchmark | ||
|
|
||
| - name: Install benchmark dependencies | ||
| working-directory: .tmp/js-reactivity-benchmark | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build benchmark core runtime bundle | ||
| working-directory: .tmp/js-reactivity-benchmark/packages/core | ||
| run: pnpm exec esbuild src/index.ts --bundle --format=esm --target=esnext --outdir=dist --sourcemap=external | ||
|
|
||
| - name: Run PR vs frameworks benchmark | ||
| run: node scripts/ci/benchmark-pr-vs-frameworks.mjs | ||
| env: | ||
| BENCH_CORE_DIST_DIR: .tmp/js-reactivity-benchmark/packages/core/dist | ||
| CURRENT_SIGNALS_DIR: packages/rescript-signals | ||
| BENCH_OUT_DIR: benchmark-results/ci/pr-vs-frameworks | ||
|
|
||
| - name: Upload benchmark artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: benchmark-pr-vs-frameworks | ||
| path: benchmark-results/ci/pr-vs-frameworks | ||
| if-no-files-found: error | ||
|
|
||
| - name: Add workflow summary | ||
| run: | | ||
| echo "## ReScript Signals benchmark: PR vs frameworks" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| cat benchmark-results/ci/pr-vs-frameworks/pr-comment-latest.md >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Upsert PR benchmark comment | ||
| if: github.event_name == 'pull_request' | ||
|
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.
This step runs for every Useful? React with 👍 / 👎. |
||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require("fs"); | ||
| const marker = "<!-- rescript-signals-benchmark-pr-vs-frameworks -->"; | ||
| const body = fs.readFileSync("benchmark-results/ci/pr-vs-frameworks/pr-comment-latest.md", "utf8"); | ||
| const commentBody = `${marker}\n${body}`; | ||
|
|
||
| const { owner, repo } = context.repo; | ||
| const issue_number = context.issue.number; | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| per_page: 100, | ||
| }); | ||
|
|
||
| const existing = comments.find((c) => c.body && c.body.includes(marker)); | ||
| if (existing) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, | ||
| repo, | ||
| comment_id: existing.id, | ||
| body: commentBody, | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| body: commentBody, | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| name: Benchmark PR vs main | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| benchmark: | ||
| name: Benchmark | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| npm_config_legacy_peer_deps: "true" | ||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Checkout main baseline | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: main | ||
| path: main-baseline | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "lts/*" | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
|
|
||
| - name: Install repository dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build repository | ||
| run: npm run build | ||
|
|
||
| - name: Install baseline dependencies | ||
| working-directory: main-baseline | ||
| run: npm ci | ||
|
|
||
| - name: Build baseline | ||
| working-directory: main-baseline | ||
| run: npm run build | ||
|
|
||
| - name: Clone benchmark suite | ||
| run: git clone --depth=1 https://github.com/milomg/js-reactivity-benchmark.git .tmp/js-reactivity-benchmark | ||
|
|
||
| - name: Install benchmark dependencies | ||
| working-directory: .tmp/js-reactivity-benchmark | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build benchmark core runtime bundle | ||
| working-directory: .tmp/js-reactivity-benchmark/packages/core | ||
| run: pnpm exec esbuild src/index.ts --bundle --format=esm --target=esnext --outdir=dist --sourcemap=external | ||
|
|
||
| - name: Run PR vs main benchmark | ||
| run: node scripts/ci/benchmark-pr-vs-main.mjs | ||
| env: | ||
| BENCH_CORE_DIST_DIR: .tmp/js-reactivity-benchmark/packages/core/dist | ||
| CURRENT_SIGNALS_DIR: packages/rescript-signals | ||
| MAIN_SIGNALS_DIR: main-baseline/packages/rescript-signals | ||
| BENCH_OUT_DIR: benchmark-results/ci/pr-vs-main | ||
|
|
||
| - name: Upload benchmark artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: benchmark-pr-vs-main | ||
| path: benchmark-results/ci/pr-vs-main | ||
| if-no-files-found: error | ||
|
|
||
| - name: Add workflow summary | ||
| run: | | ||
| echo "## ReScript Signals benchmark: PR vs main" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| cat benchmark-results/ci/pr-vs-main/pr-comment-latest.md >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Upsert PR benchmark comment | ||
| if: github.event_name == 'pull_request' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require("fs"); | ||
| const marker = "<!-- rescript-signals-benchmark-pr-vs-main -->"; | ||
| const body = fs.readFileSync("benchmark-results/ci/pr-vs-main/pr-comment-latest.md", "utf8"); | ||
| const commentBody = `${marker}\n${body}`; | ||
|
|
||
| const { owner, repo } = context.repo; | ||
| const issue_number = context.issue.number; | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| per_page: 100, | ||
| }); | ||
|
|
||
| const existing = comments.find((c) => c.body && c.body.includes(marker)); | ||
| if (existing) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, | ||
| repo, | ||
| comment_id: existing.id, | ||
| body: commentBody, | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| body: commentBody, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow clones
milomg/js-reactivity-benchmarkfrom its moving default branch, so upstream changes can break this repo’s PR checks without any change here. That risk is concrete in this commit becausescripts/ci/benchmark-pr-vs-frameworks.mjsexpects specific framework names and throws if they change. Cloning a fixed tag or commit SHA will make CI results reproducible and prevent flaky external breakages.Useful? React with 👍 / 👎.