Skip to content

Commit

Permalink
Just check size directly
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Nov 27, 2024
1 parent 8a12dfa commit 7127eb2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 63 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,13 @@ jobs:
waiting_room:
name: Waiting Room
runs-on: ubuntu-latest
needs: [conda_build, pip_install, npm_build, cdn_build, verify_sizes]
needs: [conda_build, pip_install, npm_build, cdn_build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
environment:
name: publish
steps:
- run: echo "All builds have finished, have been approved, and ready to publish"

verify_sizes:
name: Verify sizes
runs-on: ubuntu-latest
needs: [conda_build, pip_build, npm_build, cdn_build]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}"
RUN_NUMBER: ${{ github.run_number }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "1"
- run: pipx run scripts/verify_build_sizes.py $RUN_NUMBER

pixi_lock:
name: Pixi lock
runs-on: ubuntu-latest
Expand All @@ -68,6 +55,8 @@ jobs:
name: conda
path: dist/*tar.bz2
if-no-files-found: error
- name: Verify size
run: python scripts/verify_build_size.py conda

conda_publish:
name: Publish Conda
Expand Down Expand Up @@ -119,6 +108,10 @@ jobs:
name: pip
path: dist/
if-no-files-found: error
- name: Verify sizes
run: |
python scripts/verify_build_size.py sdist
python scripts/verify_build_size.py whl
pip_install:
name: Install PyPI
Expand Down Expand Up @@ -178,6 +171,8 @@ jobs:
name: npm
if-no-files-found: error
path: ./${{ env.PACKAGE }}/${{ env.TARBALL }}
- name: Verify size
run: python scripts/verify_build_size.py npm

npm_publish:
name: Publish NPM
Expand Down
33 changes: 33 additions & 0 deletions scripts/verify_build_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys

from pathlib import Path

PACKAGE = "panel"

EXPECTED_SIZES_MB = {
"conda": 25,
"npm": 25,
"sdist": 30,
"whl": 30,
}

GLOB_PATH = {
"conda": "dist/*.tar.bz2",
"npm": "panel/*.tgz",
"sdist": "dist/*.tar.gz",
"whl": "dist/*.whl",
}

PATH = Path(__file__).parents[1]


def main(build):
files = list(PATH.rglob(GLOB_PATH[build]))
assert len(files) == 1, f"Expected one {build} file, got {len(files)}"

size = files[0].stat().st_size / 1024**2
assert size < EXPECTED_SIZES_MB[build], f"{build} file is too large: {size:.2f} MB"


if __name__ == "__main__":
main(sys.argv[1])
49 changes: 0 additions & 49 deletions scripts/verify_build_sizes.py

This file was deleted.

0 comments on commit 7127eb2

Please sign in to comment.