Skip to content

Commit

Permalink
Merge pull request #123 from mcmod-info-mirror/ci-test
Browse files Browse the repository at this point in the history
  • Loading branch information
z0z0r4 authored Jan 26, 2025
2 parents e593c3f + f6a1375 commit 0ced92d
Show file tree
Hide file tree
Showing 18 changed files with 2,120 additions and 8 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Unit Test

on:
push:
# branches: [main]
pull_request:
merge_group:
workflow_dispatch:

jobs:
unit-test:
runs-on: ubuntu-latest
name: Unit test
env:
MCIM_CONFIG: ${{ secrets.MCIM_CONFIG }} # 配置文件
REDIS_CONFIG: ${{ secrets.REDIS_CONFIG }} # 配置文件
MONGODB_CONFIG: ${{ secrets.MONGODB_CONFIG }} # 配置文件
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install just
uses: extractions/setup-just@v2

- name: Start Redis
uses: supercharge/[email protected]

- name: Start MongoDB
uses: supercharge/[email protected]

- name: Install dependencies
run: |
just mongodb-tool-install
just redis-tool-install
just ci-install
just import-data
just ci-config
- name: Run unit tests
run: |
just ci-test
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Python
__pycache__

/tests

# Logs
/logs
/webapi_logs
Expand All @@ -22,4 +20,4 @@ __pycache__
/data
test.py
/aria2c
.vscode/settings.json
.vscode/settings.json
5 changes: 3 additions & 2 deletions app/controller/curseforge/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class SearchResponse(BaseModel):
data: List[Mod]
pagination: Pagination


async def check_search_result(request: Request, res: dict):
modids = set()
for mod in res["data"]:
Expand Down Expand Up @@ -443,7 +444,7 @@ async def curseforge_fingerprints(item: fingerprints_item, request: Request):
exactMatches=result_fingerprints_models,
unmatchedFingerprints=not_match_fingerprints,
installedFingerprints=[],
).model_dump()
)
),
trustable=trustable,
)
Expand Down Expand Up @@ -495,7 +496,7 @@ async def curseforge_fingerprints_432(item: fingerprints_item, request: Request)
exactMatches=result_fingerprints_models,
unmatchedFingerprints=not_match_fingerprints,
installedFingerprints=[],
).model_dump()
)
),
trustable=trustable,
)
Expand Down
2 changes: 1 addition & 1 deletion app/controller/modrinth/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ async def modrinth_files(items: HashesQuery, request: Request):
(
version.files[0].hashes.sha1
if items.algorithm == Algorithm.sha1
else version.files[0].hashes.sha2
else version.files[0].hashes.sha512
): version.model_dump()
for version in version_models
}
Expand Down
4 changes: 2 additions & 2 deletions app/database/_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def close_aio_redis_engine():
"""
global aio_redis_engine
if aio_redis_engine is not None:
await aio_redis_engine.close()
await aio_redis_engine.aclose()
log.success("closed redis connection")
else:
log.warning("no redis connection to close")
Expand All @@ -73,7 +73,7 @@ async def close_sync_queue_redis_engine():
"""
global sync_queuq_redis_engine
if sync_queuq_redis_engine is not None:
await sync_queuq_redis_engine.close()
await sync_queuq_redis_engine.aclose()
log.success("closed redis connection")
else:
log.warning("no redis connection to close")
Expand Down
Loading

0 comments on commit 0ced92d

Please sign in to comment.