mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 01:36:29 +08:00
Fix automating build workflow for Python
This commit is contained in:
parent
b7c110e5ec
commit
d27890d98d
2 changed files with 15 additions and 13 deletions
1
.github/workflows/python.yml
vendored
1
.github/workflows/python.yml
vendored
|
@ -32,7 +32,6 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install black
|
pip install black
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
||||||
- name: Lint with black
|
- name: Lint with black
|
||||||
run: |
|
run: |
|
||||||
black codes/python
|
black codes/python
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import glob
|
import glob
|
||||||
import py_compile as pyc
|
import py_compile as pyc
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# find source code files
|
||||||
src_paths = sorted(glob.glob("codes/python/**/*.py"))
|
src_paths = sorted(glob.glob("codes/python/**/*.py"))
|
||||||
num_src = len(src_paths)
|
num_src = len(src_paths)
|
||||||
num_src_error = 0
|
num_src_error = 0
|
||||||
|
|
||||||
|
# compile python code
|
||||||
for src_path in src_paths:
|
for src_path in src_paths:
|
||||||
try:
|
try:
|
||||||
pyc.compile(src_path, doraise=True)
|
pyc.compile(src_path, doraise=True)
|
||||||
|
@ -12,6 +15,6 @@ for src_path in src_paths:
|
||||||
num_src_error += 1
|
num_src_error += 1
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
print(f"===== Build Summary =====")
|
print(f"===== Build Complete =====")
|
||||||
print(f"Total: {num_src}")
|
print(f"Total: {num_src}")
|
||||||
print(f"Error: {num_src - num_src_error}")
|
print(f"Error: {num_src_error}")
|
||||||
|
|
Loading…
Reference in a new issue