|
| 1 | +# This workflow measures the disk size of a virtual environment |
| 2 | +# after installing the Bittensor SDK across multiple Python versions. |
| 3 | +# It runs only when a new pull request targets the master branch, |
| 4 | +# and posts a comment with the results. |
| 5 | + |
| 6 | +name: Monitor SDK Requirements Size |
| 7 | + |
| 8 | +on: |
| 9 | + pull_request: |
| 10 | + types: [opened] |
| 11 | + branches: [master] |
| 12 | + |
| 13 | +jobs: |
| 14 | + measure-venv: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 19 | + |
| 20 | + name: Python ${{ matrix.python-version }} |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + |
| 30 | + - name: Create virtualenv and install Bittensor SDK |
| 31 | + run: | |
| 32 | + python -m venv venv |
| 33 | + source venv/bin/activate |
| 34 | + pip install --upgrade pip |
| 35 | + pip install . |
| 36 | +
|
| 37 | + - name: Measure venv folder size |
| 38 | + id: venv-size |
| 39 | + run: | |
| 40 | + du -sm venv | cut -f1 > venv_size_mb.txt |
| 41 | + echo "venv_size=$(cat venv_size_mb.txt)" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + - name: Save size for summary |
| 44 | + run: | |
| 45 | + echo "Python ${{ matrix.python-version }}: ${{ steps.venv-size.outputs.venv_size }} MB" >> $GITHUB_WORKSPACE/venv_sizes.txt |
| 46 | +
|
| 47 | + - name: Upload summary file as artifact |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: venv_sizes |
| 51 | + path: $GITHUB_WORKSPACE/venv_sizes.txt |
| 52 | + |
| 53 | + comment-on-pr: |
| 54 | + if: github.event_name == 'pull_request' && github.base_ref == 'master' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: measure-venv |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Download summary |
| 60 | + uses: actions/download-artifact@v4 |
| 61 | + with: |
| 62 | + name: venv_sizes |
| 63 | + path: . |
| 64 | + |
| 65 | + - name: Read summary and comment it |
| 66 | + uses: actions/github-script@v7 |
| 67 | + with: |
| 68 | + script: | |
| 69 | + const fs = require('fs'); |
| 70 | + const comment = fs.readFileSync('venv_sizes.txt', 'utf8'); |
| 71 | + github.rest.issues.createComment({ |
| 72 | + issue_number: context.payload.pull_request.number, |
| 73 | + owner: context.repo.owner, |
| 74 | + repo: context.repo.name, |
| 75 | + body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${comment}\n\`\`\`` |
| 76 | + }); |
0 commit comments