👷 Check gcsim scripts pr

This commit is contained in:
xtaodada 2023-12-02 18:43:03 +08:00
parent d067c5e1c2
commit 94df038aff
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 38 additions and 1 deletions

31
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: PR Check for gcsim scripts
on:
pull_request:
paths:
- 'gcsim/scripts/**'
types:
- opened
- synchronize
- reopened
jobs:
pr-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Dependencies
run: |
python -m pip install -r gcsim/requirements.txt
- name: Check GCSIM scripts
run: |
python gcsim/main.py pr

View File

@ -6,6 +6,7 @@ from pathlib import Path
import aiofiles import aiofiles
import re import re
import gcsim_pypi import gcsim_pypi
import sys
data_path = Path("gcsim.json") data_path = Path("gcsim.json")
gcsim_path = Path("gcsim") gcsim_path = Path("gcsim")
@ -41,9 +42,14 @@ async def run_gcsim(path: Path) -> bool:
_, stderr = await process.communicate() _, stderr = await process.communicate()
err = stderr.decode() err = stderr.decode()
if err: if err:
print(f"{path.name} 解析失败 {err}") text = f"{path.name} 解析失败 \n\n{err}"
if sys.argv[-1] == "pr":
raise ValueError(text)
print(text)
return False return False
return True return True
except ValueError as e:
raise e
except Exception: except Exception:
return False return False