Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: 通过 CI 自动检查 Pipeline 资源正确性 #31

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -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: windows-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/ ./assets/resource/bilibili/
39 changes: 39 additions & 0 deletions check_resource.py
Original file line number Diff line number Diff line change
@@ -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_bundle(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 <directory>")
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()
Loading