Skip to content

Commit 7d81eb3

Browse files
committed
.github/workflows/ci.yml:check free_space
1 parent 790bf20 commit 7d81eb3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ jobs:
140140
# Ensure the latest merged pull request state is used, even on re-runs.
141141
ref: &CHECKOUT_REF_TMPL ${{ github.event_name == 'pull_request' && github.ref || '' }}
142142

143+
- name: Create free_space.py
144+
# We'll write your function into a script file for execution
145+
run: |
146+
echo "import ctypes" > free_space.py
147+
echo "import os" >> free_space.py
148+
echo "import platform" >> free_space.py
149+
echo "import sys" >> free_space.py
150+
echo "def get_free_space_mb(dirname):" >> free_space.py
151+
echo " # [Your function content here]" >> free_space.py
152+
echo " if platform.system() == 'Windows':" >> free_space.py
153+
echo " free_bytes = ctypes.c_ulonglong(0)" >> free_space.py
154+
echo " ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(dirname), None, None, ctypes.pointer(free_bytes))" >> free_space.py
155+
echo " return free_bytes.value / 1024 / 1024" >> free_space.py
156+
echo " else:" >> free_space.py
157+
echo " st = os.statvfs(dirname)" >> free_space.py
158+
echo " return st.f_bavail * st.f_frsize / 1024 / 1024" >> free_space.py
159+
echo "" >> free_space.py
160+
echo "# Execute the function and print the result" >> free_space.py
161+
echo "dirname = 'C:\\\\' if platform.system() == 'Windows' else '/'" >> free_space.py
162+
echo "free_mb = get_free_space_mb(dirname)" >> free_space.py
163+
echo "print(f'Free space at {dirname}: {free_mb:.2f} MB')" >> free_space.py
164+
echo "assert free_mb > 100, 'Free space is unexpectedly low!'" >> free_space.py
165+
143166
- name: Clang version
144167
run: |
145168
# Use the earliest Xcode supported by the version of macOS denoted in
@@ -157,11 +180,17 @@ jobs:
157180
brew install --quiet python@3 || brew link --overwrite python@3
158181
brew install --quiet coreutils ninja pkgconf gnu-getopt ccache boost libevent zeromq qt@6 qrencode capnp
159182
183+
- name: run free_space.py
184+
run: python free_space.py
185+
160186
- name: Install Python packages
161187
run: |
162188
git clone -b v2.1.0 https://github.com/capnproto/pycapnp
163189
pip3 install ./pycapnp -C force-bundled-libcapnp=True --break-system-packages
164190
191+
- name: run free_space.py
192+
run: python free_space.py
193+
165194
- name: Set Ccache directory
166195
run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
167196

@@ -173,6 +202,9 @@ jobs:
173202
key: ${{ github.job }}-${{ matrix.job-type }}-ccache-${{ github.run_id }}
174203
restore-keys: ${{ github.job }}-${{ matrix.job-type }}-ccache-
175204

205+
- name: run free_space.py
206+
run: python free_space.py
207+
176208
- name: CI script
177209
run: ./ci/test_run_all.sh
178210
env:

0 commit comments

Comments
 (0)