Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Editor: CI & Dev"
name: "Editor: Dev & CI"

on:
push:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
repo: context.repo.repo,
});

const botComments = comments.filter(comment =>
const botComments = comments.filter((comment) =>
comment.user.type === 'Bot' && comment.body.includes('Clippy Warnings/Errors')
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Profiling
name: Profiling Changes

on:
pull_request:
Expand All @@ -23,8 +23,8 @@ jobs:

- name: Install Valgrind
run: |
sudo apt-get update
sudo apt-get install -y valgrind
sudo apt update
sudo apt install -y valgrind

- name: Cache dependencies
uses: actions/cache@v3
Expand Down Expand Up @@ -60,32 +60,57 @@ jobs:
echo "$BENCH_OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Make old comments collapsed by default
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const botComments = comments.filter((comment) =>
comment.user.type === 'Bot' && comment.body.includes('Performance Benchmark Results') && comment.body.includes('<details open>')
);

for (const comment of botComments) {
// Edit the comment to remove the "open" attribute from the <details> tag
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: comment.body.replace('<details open>', '<details>')
});
}

- name: Comment PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const benchmarkOutput = JSON.parse(`${{ steps.benchmark.outputs.BENCHMARK_OUTPUT }}`);
let significantChanges = false;
let commentBody = "#### Performance Benchmark Results\n\n";
let commentBody = "";

function formatNumber(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

function formatPercentage(pct) {
const sign = pct >= 0 ? '+' : '';
return `${sign}${pct.toFixed(2)}%`;
}

function padRight(str, len) {
return str.padEnd(len);
}

function padLeft(str, len) {
return str.padStart(len);
}

for (const benchmark of benchmarkOutput) {
if (benchmark.callgrind_summary && benchmark.callgrind_summary.summaries) {
const summary = benchmark.callgrind_summary.summaries[0];
Expand Down Expand Up @@ -119,15 +144,25 @@ jobs:
}
}
}


const output = `
<details open>

<summary>Performance Benchmark Results</summary>

${commentBody}

</details>
`;

if (significantChanges) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
body: output
});
} else {
console.log("No significant performance changes detected. Skipping comment.");
console.log(commentBody);
console.log(output);
}