From b135e5a7f08318e3dbc994d15a2ab53d27b9399d Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 20 Sep 2024 16:13:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/check.yml | 36 ++++++++++++++++++++++++++++++++++ check_resource.py | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/check.yml create mode 100644 check_resource.py diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..b7a5220 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,36 @@ +name: check + +on: + push: + branches: + - "**" + paths: + - ".github/workflows/check.yml" + - "assets/**" + - "**.py" + pull_request: + branches: + - "**" + paths: + - ".github/workflows/check.yml" + - "assets/**" + - "**.py" + workflow_dispatch: + +jobs: + resource: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # pip install maafw + - name: Install maafw + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade maafw --pre + + - name: Check Resource + run: | + python ./check_resource.py ./assets/resource/base/ diff --git a/check_resource.py b/check_resource.py new file mode 100644 index 0000000..229daef --- /dev/null +++ b/check_resource.py @@ -0,0 +1,39 @@ +import sys + +from typing import List +from pathlib import Path + +from maa.resource import Resource +from maa.tasker import Tasker, LoggingLevelEnum + + +def check(dirs: List[Path]) -> bool: + resource = Resource() + + print(f"Checking {len(dirs)} directories...") + + for dir in dirs: + print(f"Checking {dir}...") + status = resource.post_path(dir).wait().status() + if not status.succeeded(): + print(f"Failed to check {dir}.") + return False + + print("All directories checked.") + return True + + +def main(): + if len(sys.argv) < 2: + print("Usage: python configure.py ") + sys.exit(1) + + Tasker.set_stdout_level(LoggingLevelEnum.All) + + dirs = [Path(arg) for arg in sys.argv[1:]] + if not check(dirs): + sys.exit(1) + + +if __name__ == "__main__": + main()