Make Html (VNode) cheap to clone #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Benchmark - core | |
on: | |
pull_request: | |
branches: [master] | |
paths: | |
- .github/workflows/benchmark-core.yml | |
- "packages/yew/**" | |
- "tools/benchmark-core/**" | |
jobs: | |
benchmark-core: | |
name: Benchmark - core | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@v3 | |
with: | |
repository: "yewstack/yew" | |
ref: master | |
path: yew-master | |
- name: Checkout pull request | |
uses: actions/checkout@v3 | |
with: | |
path: current-pr | |
- name: Setup toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Restore Rust cache for master | |
uses: Swatinem/rust-cache@v2 | |
with: | |
working-directory: yew-master | |
key: master | |
- name: Restore Rust cache for current pull request | |
uses: Swatinem/rust-cache@v2 | |
with: | |
working-directory: current-pr | |
key: pr | |
- name: Run pull request benchmark | |
run: cargo bench -q > ../output.log | |
working-directory: current-pr/tools/benchmark-core | |
- name: Run master benchmark | |
run: cargo bench -q > ../output.log | |
continue-on-error: true | |
working-directory: yew-master/tools/benchmark-core | |
- name: Make sure master's output log exists | |
run: touch yew-master/tools/output.log | |
- name: Write Pull Request ID | |
run: | | |
echo "${{ github.event.number }}" > .PR_NUMBER | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: benchmark-core | |
path: | | |
.PR_NUMBER | |
yew-master/tools/output.log | |
current-pr/tools/output.log | |
retention-days: 1 | |
post-benchmark-core: | |
name: Post Comment on Pull Request | |
runs-on: ubuntu-latest | |
needs: benchmark-core | |
steps: | |
- name: Download Repository | |
uses: actions/checkout@v3 | |
- name: Download Artifact | |
uses: Legit-Labs/action-download-artifact@v2 | |
with: | |
github_token: "${{ secrets.GITHUB_TOKEN }}" | |
name: benchmark-core | |
path: "benchmark-core/" | |
- name: Make pull request comment | |
run: | | |
cat - >>comment.txt <<EOF | |
### Benchmark - core | |
#### Yew Master | |
\`\`\` | |
EOF | |
cat benchmark-core/yew-master/tools/output.log >>comment.txt | |
cat - >>comment.txt <<EOF | |
\`\`\` | |
#### Pull Request" >> comment.txt | |
\`\`\` | |
EOF | |
cat benchmark-core/current-pr/tools/output.log >>comment.txt | |
cat - >>comment.txt <<EOF | |
\`\`\` | |
EOF | |
- name: Read Pull Request ID | |
run: | | |
PR_NUMBER=$(cat "benchmark-core/.PR_NUMBER") | |
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then | |
echo "pr number invalid" | |
exit 1 | |
fi | |
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | |
- name: Post Comment | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const commentInfo = { | |
...context.repo, | |
issue_number: ${{ env.PR_NUMBER }}, | |
}; | |
const comment = { | |
...commentInfo, | |
body: fs.readFileSync("comment.txt", 'utf-8'), | |
}; | |
function isCommentByBot(comment) { | |
return comment.user.type === "Bot" && comment.body.includes("### Benchmark - core"); | |
} | |
let commentId = null; | |
const comments = (await github.rest.issues.listComments(commentInfo)).data; | |
for (let i = comments.length; i--; ) { | |
const c = comments[i]; | |
if (isCommentByBot(c)) { | |
commentId = c.id; | |
break; | |
} | |
} | |
if (commentId) { | |
try { | |
await github.rest.issues.updateComment({ | |
...context.repo, | |
comment_id: commentId, | |
body: comment.body, | |
}); | |
} catch (e) { | |
commentId = null; | |
} | |
} | |
if (!commentId) { | |
await github.rest.issues.createComment(comment); | |
} |