Separate PR and master size collection. (#3101)

This commit is contained in:
Kaede Hoshikawa 2023-02-02 02:11:43 +09:00 committed by GitHub
parent 65b930acb6
commit 8d308fb617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 39 deletions

View File

@ -17,14 +17,24 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- if: github.event.workflow_run.event == 'pull_request' - if: github.event.workflow_run.event == 'pull_request'
name: Download Artifact name: Download Artifact (master)
uses: Legit-Labs/action-download-artifact@v2 uses: Legit-Labs/action-download-artifact@v2
with: with:
github_token: "${{ secrets.GITHUB_TOKEN }}" github_token: "${{ secrets.GITHUB_TOKEN }}"
workflow: size-cmp.yml workflow: size-cmp.yml
run_id: ${{ github.event.workflow_run.id }} run_id: ${{ github.event.workflow_run.id }}
name: size-cmp-info name: size-cmp-master-info
path: "size-cmp-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 - name: Make pull request comment
run: python3 ci/make_example_size_cmt.py run: python3 ci/make_example_size_cmt.py

View File

@ -13,21 +13,23 @@ on:
jobs: jobs:
size-cmp: size-cmp:
name: Compare Size between master and current Pull Request name: Collect ${{ matrix.target }} Size
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
target: ["master", "pr"]
steps: steps:
- name: Checkout master - name: Checkout master
uses: actions/checkout@v3 uses: actions/checkout@v3
if: ${{ matrix.target == 'master' }}
with: with:
repository: 'yewstack/yew' repository: "yewstack/yew"
ref: master ref: master
path: yew-master
- name: Checkout pull request - name: Checkout pull request
uses: actions/checkout@v3 uses: actions/checkout@v3
with: if: ${{ matrix.target == 'pr' }}
path: current-pr
- name: Setup toolchain - name: Setup toolchain
uses: dtolnay/rust-toolchain@master uses: dtolnay/rust-toolchain@master
@ -38,42 +40,27 @@ jobs:
- name: Restore Rust cache for master - name: Restore Rust cache for master
uses: Swatinem/rust-cache@v2 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 - name: Setup Trunk
uses: jetli/trunk-action@v0.4.0 uses: jetli/trunk-action@v0.4.0
with: with:
version: 'latest' version: "latest"
- name: Build master examples - name: Build examples
run: find ./*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0 run: find ./*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0
working-directory: yew-master/examples working-directory: examples
env:
RUSTUP_TOOLCHAIN: nightly
- name: Build pull request examples
run: find ./*/index.html | xargs -I '{}' trunk build --release '{}' || exit 0
working-directory: current-pr/examples
env: env:
RUSTUP_TOOLCHAIN: nightly RUSTUP_TOOLCHAIN: nightly
RUSTFLAGS: --cfg nightly_yew RUSTFLAGS: --cfg nightly_yew
- name: Collect size information - name: Collect size information
run: python3 current-pr/ci/collect_sizes.py run: python3 ci/collect_sizes.py
env: env:
ISSUE_NUMBER: ${{ github.event.number }} ISSUE_NUMBER: ${{ github.event.number }}
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: size-cmp-info name: size-cmp-${{ matrix.target }}-info
path: ".SIZE_CMP_INFO" path: ".SIZE_CMP_INFO"
retention-days: 1 retention-days: 1

View File

@ -32,15 +32,10 @@ def find_example_sizes(parent_dir: Path) -> Dict[str, int]:
def main() -> None: def main() -> None:
master_sizes = find_example_sizes(Path("yew-master")) sizes = find_example_sizes(Path.cwd())
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]
size_cmp_info = { size_cmp_info = {
"sizes": joined_sizes, "sizes": sizes,
"issue_number": os.environ["ISSUE_NUMBER"], "issue_number": os.environ["ISSUE_NUMBER"],
} }

View File

@ -35,11 +35,22 @@ def format_diff_size(
def main() -> None: def main() -> None:
with open("size-cmp-info/.SIZE_CMP_INFO") as f: with open("size-cmp-pr-info/.SIZE_CMP_INFO") as f:
content = json.loads(f.read()) pr_content = json.loads(f.read())
joined_sizes = content["sizes"] with open("size-cmp-master-info/.SIZE_CMP_INFO") as f:
issue_number = content["issue_number"] 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] = [] lines: List[str] = []
significant_lines: List[str] = [] significant_lines: List[str] = []