Skip to content

Commit

Permalink
feat: 修复了商店测试数据格式化的问题,修改了构建的工作流
Browse files Browse the repository at this point in the history
  • Loading branch information
BigOrangeQWQ committed Aug 29, 2024
1 parent 949be60 commit 39d6f46
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 48 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Plugin Test Contain Builder

on:
push:
paths:
- './docker/**'

job:
plugin-test-docker:
name: Docker
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

# needs: test
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Docker
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Tags
uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/bigorangeqwq/nonetest
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ matrix.python-version }}-{{branch}}
- name: Build and Publish
uses: docker/build-push-action@v5
with:
file: ./docker/Dockerfile
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: PYTHON_VERSION=${{ matrix.python-version }}
42 changes: 0 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,48 +68,6 @@ jobs:
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

plugin-test-docker:
name: Docker
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

# needs: test
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Docker
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Tags
uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/bigorangeqwq/nonetest
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ matrix.python-version }}-{{branch}}
- name: Build and Publish
uses: docker/build-push-action@v5
with:
file: ./docker/Dockerfile
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: PYTHON_VERSION=${{ matrix.python-version }}

github-relase:
name: GitHub release
Expand Down
1 change: 0 additions & 1 deletion src/utils/store_test/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import abc
from datetime import datetime
from typing import Any, Literal
from zoneinfo import ZoneInfo
Expand Down
11 changes: 8 additions & 3 deletions src/utils/store_test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@
from functools import cache
from pathlib import Path
from typing import Any
from collections.abc import Mapping

import httpx
from pydantic import BaseModel
from pydantic_core import to_jsonable_python


def load_json(url: str):
def load_json(url: str) -> Any:
"""从网络加载 JSON 文件"""
r = httpx.get(url)
if r.status_code != 200:
raise ValueError(f"下载文件失败:{r.text}")
return r.json()


def dump_json(path: Path, data: dict | list):
def dump_json(path: Path, data: Mapping[str, BaseModel] | list[BaseModel]):
"""保存 JSON 文件
为减少文件大小,还需手动设置 separators
"""
with open(path, "w", encoding="utf8") as f:
json.dump(data, f, ensure_ascii=False, separators=(",", ":"))
json.dump(
to_jsonable_python(data), f, ensure_ascii=False, separators=(",", ":")
)


@cache
Expand Down
2 changes: 0 additions & 2 deletions src/utils/validation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
Field,
ValidationInfo,
ValidatorFunctionWrapHandler,
field_serializer,
field_validator,
model_validator,
)
from pydantic_extra_types.color import Color
from pydantic_core import PydanticCustomError
from src.utils.store_test.models import Metadata, Tag

Expand Down

0 comments on commit 39d6f46

Please sign in to comment.