@@ -7,7 +7,7 @@ name: Monitor SDK Requirements Size
7
7
8
8
on :
9
9
pull_request :
10
- types : [opened]
10
+ types : [opened, synchronize ]
11
11
branches : [master]
12
12
13
13
jobs :
@@ -16,61 +16,59 @@ jobs:
16
16
strategy :
17
17
matrix :
18
18
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 }}
21
25
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
27
28
with :
28
29
python-version : ${{ matrix.python-version }}
29
30
30
- - name : Create virtualenv and install Bittensor SDK
31
+ - name : Create virtualenv and install
31
32
run : |
32
33
python -m venv venv
33
34
source venv/bin/activate
34
35
pip install --upgrade pip
35
36
pip install .
36
37
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
44
40
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
52
51
53
52
comment-on-pr :
54
53
if : github.event_name == 'pull_request' && github.base_ref == 'master'
55
- runs-on : ubuntu-latest
56
54
needs : measure-venv
57
-
55
+ runs-on : ubuntu-latest
58
56
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
66
58
uses : actions/github-script@v7
67
59
with :
68
60
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`);
71
69
github.rest.issues.createComment({
72
70
issue_number: context.payload.pull_request.number,
73
71
owner: context.repo.owner,
74
72
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\`\`\``
76
74
});
0 commit comments