Skip to content
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

Separate PR and master size collection #3101

Merged
merged 1 commit into from
Feb 1, 2023
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
16 changes: 13 additions & 3 deletions .github/workflows/post-size-cmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ jobs:
uses: actions/checkout@v2

- if: github.event.workflow_run.event == 'pull_request'
name: Download Artifact
name: Download Artifact (master)
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: size-cmp-master-info
path: "size-cmp-master-info/"

- if: github.event.workflow_run.event == 'pull_request'
name: Download Artifact (PR)
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-pr-info
path: "size-cmp-pr-info/"

- name: Make pull request comment
run: python3 ci/make_example_size_cmt.py
Expand Down
37 changes: 12 additions & 25 deletions .github/workflows/size-cmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ on:

jobs:
size-cmp:
name: Compare Size between master and current Pull Request
name: Collect ${{ matrix.target }} Size
runs-on: ubuntu-latest
strategy:
matrix:
target: ["master", "pr"]

steps:
- name: Checkout master
uses: actions/checkout@v3
if: ${{ matrix.target == 'master' }}
with:
repository: 'yewstack/yew'
repository: "yewstack/yew"
ref: master
path: yew-master

- name: Checkout pull request
uses: actions/checkout@v3
with:
path: current-pr
if: ${{ matrix.target == 'pr' }}

- name: Setup toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -38,42 +40,27 @@ jobs:

- 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: Setup Trunk
uses: jetli/[email protected]
with:
version: 'latest'

- name: Build master examples
run: find ./*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0
working-directory: yew-master/examples
env:
RUSTUP_TOOLCHAIN: nightly
version: "latest"

- name: Build pull request examples
- name: Build examples
run: find ./*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0
working-directory: current-pr/examples
working-directory: examples
env:
RUSTUP_TOOLCHAIN: nightly
RUSTFLAGS: --cfg nightly_yew

- name: Collect size information
run: python3 current-pr/ci/collect_sizes.py
run: python3 ci/collect_sizes.py
env:
ISSUE_NUMBER: ${{ github.event.number }}

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: size-cmp-info
name: size-cmp-${{ matrix.target }}-info
path: ".SIZE_CMP_INFO"
retention-days: 1
9 changes: 2 additions & 7 deletions ci/collect_sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ def find_example_sizes(parent_dir: Path) -> Dict[str, int]:


def main() -> None:
master_sizes = find_example_sizes(Path("yew-master"))
pr_sizes = find_example_sizes(Path("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]
sizes = find_example_sizes(Path.cwd())

size_cmp_info = {
"sizes": joined_sizes,
"sizes": sizes,
"issue_number": os.environ["ISSUE_NUMBER"],
}

Expand Down
19 changes: 15 additions & 4 deletions ci/make_example_size_cmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,22 @@ def format_diff_size(


def main() -> None:
with open("size-cmp-info/.SIZE_CMP_INFO") as f:
content = json.loads(f.read())
with open("size-cmp-pr-info/.SIZE_CMP_INFO") as f:
pr_content = json.loads(f.read())

joined_sizes = content["sizes"]
issue_number = content["issue_number"]
with open("size-cmp-master-info/.SIZE_CMP_INFO") as f:
master_content = json.loads(f.read())

master_sizes: dict[str, int] = master_content["sizes"]
pr_sizes: dict[str, int] = pr_content["sizes"]

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]

assert pr_content["issue_number"] == master_content["issue_number"], \
"Issue number differs between master and pr?"

issue_number = pr_content["issue_number"]

lines: List[str] = []
significant_lines: List[str] = []
Expand Down