-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into scoped-events
- Loading branch information
Showing
127 changed files
with
2,302 additions
and
1,970 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
name: Post Comment for Size Comparison | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Size Comparison"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
size-cmp: | ||
name: Post Comment on Pull Request | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- if: github.event.workflow_run.event == 'pull_request' | ||
name: Download Artifact | ||
uses: Legit-Labs/action-download-artifact@v2 | ||
with: | ||
github_token: "${{ secrets.GITHUB_TOKEN }}" | ||
workflow: size-cmp.yml | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: size-cmp-info | ||
path: "size-cmp-info/" | ||
|
||
- name: Make pull request comment | ||
run: | | ||
from typing import Dict, List, Optional | ||
import os | ||
import json | ||
with open("size-cmp-info/.SIZE_CMP_INFO") as f: | ||
content = json.loads(f.read()) | ||
joined_sizes = content["sizes"] | ||
issue_number = content["issue_number"] | ||
lines: List[str] = [] | ||
lines.append("### Size Comparison") | ||
lines.append("") | ||
lines.append("| examples | master (KB) | pull request (KB) | diff |") | ||
lines.append("| --- | --- | --- | --- | ") | ||
for (i, sizes) in joined_sizes: | ||
(master_size, pr_size) = sizes | ||
diff: Optional[int] = None | ||
if master_size is not None and pr_size is not None: | ||
diff = pr_size - master_size | ||
master_size_str = "N/A" if master_size is None else ( | ||
f"{master_size / 1024:.3f}" if master_size != 0 else "0" | ||
) | ||
pr_size_str = "N/A" if pr_size is None else ( | ||
f"{pr_size / 1024:.3f}" if pr_size != 0 else "0" | ||
) | ||
diff_str = "N/A" if diff is None else ( | ||
f"{diff / 1024:.3f}" if diff < 0 else ( | ||
f"+{diff / 1024:.3f}" if diff > 0 else "0" | ||
) | ||
) | ||
lines.append(f"| {i} | {master_size_str} | {pr_size_str} | {diff_str} |") | ||
output = "\n".join(lines) | ||
with open(os.environ["GITHUB_ENV"], "a+") as f: | ||
f.write(f"YEW_EXAMPLE_SIZES={json.dumps(output)}\n") | ||
f.write(f"PR_NUMBER={issue_number}\n") | ||
shell: python3 {0} | ||
|
||
- name: Post Comment | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const commentInfo = { | ||
...context.repo, | ||
issue_number: ${{ env.PR_NUMBER }}, | ||
}; | ||
const comment = { | ||
...commentInfo, | ||
body: JSON.parse(process.env.YEW_EXAMPLE_SIZES), | ||
}; | ||
function isCommentByBot(comment) { | ||
return comment.user.type === "Bot" && comment.body.includes("### Size Comparison"); | ||
} | ||
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); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--- | ||
name: Size Comparison | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
paths: | ||
- "packages/**" | ||
- "examples/**" | ||
- "Cargo.toml" | ||
|
||
jobs: | ||
size-cmp: | ||
name: Compare Size between master and current Pull Request | ||
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: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: wasm32-unknown-unknown | ||
override: true | ||
profile: minimal | ||
|
||
- name: Restore Rust cache for master | ||
uses: Swatinem/rust-cache@v1 | ||
with: | ||
working-directory: yew-master | ||
key: master | ||
|
||
- name: Restore Rust cache for current pull request | ||
uses: Swatinem/rust-cache@v1 | ||
with: | ||
working-directory: current-pr | ||
key: pr | ||
|
||
- name: Setup Trunk | ||
uses: jetli/[email protected] | ||
with: | ||
version: 'latest' | ||
|
||
- name: Write optimisation flags for master | ||
run: | | ||
cat >> Cargo.toml << EOF | ||
[profile.release] | ||
lto = true | ||
codegen-units = 1 | ||
panic = "abort" | ||
opt-level = "z" | ||
EOF | ||
working-directory: yew-master | ||
|
||
- name: Write optimisation flags for pull request | ||
run: | | ||
cat >> Cargo.toml << EOF | ||
[profile.release] | ||
lto = true | ||
codegen-units = 1 | ||
panic = "abort" | ||
opt-level = "z" | ||
EOF | ||
working-directory: current-pr | ||
|
||
- name: Build master examples | ||
run: find examples/*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0 | ||
working-directory: yew-master | ||
|
||
- name: Build pull request examples | ||
run: find examples/*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0 | ||
working-directory: current-pr | ||
|
||
- name: Collect size information | ||
run: | | ||
from typing import Dict, List, Optional | ||
import glob | ||
import os | ||
import json | ||
def find_example_sizes(parent_dir: str) -> Dict[str, int]: | ||
example_sizes: Dict[str, int] = {} | ||
for example_dir in os.listdir(f"{parent_dir}/examples"): | ||
path = f"{parent_dir}/examples/{example_dir}" | ||
if not os.path.isdir(path): | ||
continue | ||
matches = glob.glob(f"{parent_dir}/examples/{example_dir}/dist/index*.wasm") | ||
if not matches: | ||
continue | ||
path = matches[0] | ||
example_sizes[example_dir] = os.path.getsize(path) | ||
return example_sizes | ||
master_sizes = find_example_sizes("yew-master") | ||
pr_sizes = find_example_sizes("current-pr") | ||
example_names = sorted(set([*master_sizes.keys(), *pr_sizes.keys()])) | ||
joined_sizes = [(i, [master_sizes.get(i), pr_sizes.get(i)]) for i in example_names] | ||
size_cmp_info = { | ||
"sizes": joined_sizes, | ||
"issue_number": ${{ github.event.number }}, | ||
} | ||
with open(".SIZE_CMP_INFO", "w+") as f: | ||
f.write(json.dumps(size_cmp_info)) | ||
shell: python3 {0} | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: size-cmp-info | ||
path: ".SIZE_CMP_INFO" | ||
retention-days: 1 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
fn main() { | ||
wasm_logger::init(wasm_logger::Config::default()); | ||
yew::start_app::<agents::App>(); | ||
yew::Renderer::<agents::App>::new().render(); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,5 +162,5 @@ impl App { | |
} | ||
|
||
fn main() { | ||
yew::start_app::<App>(); | ||
yew::Renderer::<App>::new().render(); | ||
} |
Oops, something went wrong.