Skip to content

Commit b33b87d

Browse files
author
Roman
committed
update
1 parent 384efe5 commit b33b87d

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

.github/workflows/monitor_requirements_size_master.yml

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Monitor SDK Requirements Size
77

88
on:
99
pull_request:
10-
types: [opened]
10+
types: [opened, synchronize]
1111
branches: [master]
1212

1313
jobs:
@@ -16,61 +16,59 @@ jobs:
1616
strategy:
1717
matrix:
1818
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
19-
20-
name: Python ${{ matrix.python-version }}
19+
outputs:
20+
py39: ${{ steps.set-output.outputs.py39 }}
21+
py310: ${{ steps.set-output.outputs.py310 }}
22+
py311: ${{ steps.set-output.outputs.py311 }}
23+
py312: ${{ steps.set-output.outputs.py312 }}
24+
py313: ${{ steps.set-output.outputs.py313 }}
2125
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
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
2728
with:
2829
python-version: ${{ matrix.python-version }}
2930

30-
- name: Create virtualenv and install Bittensor SDK
31+
- name: Create virtualenv and install
3132
run: |
3233
python -m venv venv
3334
source venv/bin/activate
3435
pip install --upgrade pip
3536
pip install .
3637
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
38+
- name: Measure venv size
39+
id: set-output
4440
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
41+
SIZE=$(du -sm venv | cut -f1)
42+
VERSION=${{ matrix.python-version }}
43+
echo "Detected size: $SIZE MB for Python $VERSION"
44+
case "$VERSION" in
45+
3.9) echo "py39=$SIZE" >> $GITHUB_OUTPUT ;;
46+
3.10) echo "py310=$SIZE" >> $GITHUB_OUTPUT ;;
47+
3.11) echo "py311=$SIZE" >> $GITHUB_OUTPUT ;;
48+
3.12) echo "py312=$SIZE" >> $GITHUB_OUTPUT ;;
49+
3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;;
50+
esac
5251
5352
comment-on-pr:
5453
if: github.event_name == 'pull_request' && github.base_ref == 'master'
55-
runs-on: ubuntu-latest
5654
needs: measure-venv
57-
55+
runs-on: ubuntu-latest
5856
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
57+
- name: Comment on PR
6658
uses: actions/github-script@v7
6759
with:
6860
script: |
69-
const fs = require('fs');
70-
const comment = fs.readFileSync('venv_sizes.txt', 'utf8');
61+
const sizes = {
62+
"3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}",
63+
"3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}",
64+
"3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}",
65+
"3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}",
66+
"3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}"
67+
};
68+
const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`);
7169
github.rest.issues.createComment({
7270
issue_number: context.payload.pull_request.number,
7371
owner: context.repo.owner,
7472
repo: context.repo.name,
75-
body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${comment}\n\`\`\``
73+
body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\``
7674
});

0 commit comments

Comments
 (0)