-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from jokester/upgrade-pytest
simplify config & tune logging & revive tests
- Loading branch information
Showing
39 changed files
with
712 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,14 +9,26 @@ SECRET_KEY=CHANGE_ME | |
# 【请修改】管理员邮箱,第一次启动会创建此账号,默认密码为 123123,请及时修改密码! | ||
# 之后每次程序启动时,会将此账号设置为管理员 | ||
ADMIN_EMAIL=[email protected] | ||
# initial password for auto-created admin user | ||
ADMIN_INITIAL_PASSWORD= | ||
|
||
# Database | ||
# MONGODB_URI="" # takes precedence over other MONGODB_* entries | ||
# MONGODB_DB_NAME=moeflow | ||
# MONGODB_USER=moeflow | ||
# MONGODB_PASS=CHANGE_ME | ||
|
||
# Job Queue | ||
# CELERY_BROKER_URL="" # takes precedence over other RABBITMQ_* entries | ||
# RABBITMQ_USER=moeflow | ||
# RABBITMQ_PASS=CHANGE_ME | ||
# RABBITMQ_VHOST_NAME=moeflow | ||
|
||
# APP 专用的 MongoDB 数据库名称 | ||
MONGODB_DB_NAME=moeflow | ||
|
||
# ----------- | ||
# Storage 配置 | ||
# ----------- | ||
# 目前支持 LOCAL_STORAGE 和 OSS 和 OPENDAL | ||
# 目前支持 LOCAL_STORAGE 和 OSS | ||
STORAGE_TYPE=LOCAL_STORAGE | ||
# STORAGE_DOMAIN: 返回给客户端的图片URL前缀 | ||
# 1. 如果STORAGE_TYPE为OSS | ||
|
@@ -41,7 +53,7 @@ OSS_PROCESS_COVER_NAME=cover | |
OSS_PROCESS_SAFE_CHECK_NAME=safe-check | ||
|
||
# ----------- | ||
# CDN 配置 | ||
# CDN 配置 | ||
# ----------- | ||
# 如果绑定了 CDN 来加速 OSS,且开启了 CDN 的[阿里云 OSS 私有 Bucket 回源]和[URL 鉴权], | ||
# 此时需要设置 OSS_VIA_CDN = True,并设置 CDN URL 鉴权主/备 KEY | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Env variables for tests | ||
TESTING=YES | ||
LOG_LEVEL=DEBUG | ||
SITE_NAME=萌翻TEST | ||
SECRET_KEY=SECRET | ||
[email protected] | ||
|
||
MONGODB_URI="mongodb://moeflow:[email protected]:27017/moeflow_test?authSource=admin" | ||
# MONGODB_DB_NAME=moeflow | ||
# MONGODB_USER=moeflow | ||
# MONGODB_PASS=CHANGE_ME | ||
CELERY_BROKER_URL="amqp://moeflow:[email protected]:5672/moeflow" # takes precedence over other RABBITMQ_* entries | ||
# RABBITMQ_USER=moeflow | ||
# RABBITMQ_PASS=CHANGE_ME | ||
# RABBITMQ_VHOST_NAME=moeflow_test | ||
|
||
# Storage | ||
STORAGE_TYPE=LOCAL_STORAGE | ||
# STORAGE_DOMAIN: 返回给客户端的图片URL前缀 | ||
# 1. 如果STORAGE_TYPE为OSS | ||
# - 未设置自定义域名则填写阿里云提供的 OSS 域名,格式如:https://<your-bucket-name>.<oss-region>.aliyuncs.com/ | ||
# - 如果绑定了 CDN 来加速 OSS,则填写绑定在 CDN 的域名 | ||
# 2. 如果STORAGE_TYPE为LOCAL_STORAGE | ||
# - 本地储存填写绑定到服务器的域名+"/storage/",格式如:http(s)://<your-domain>.com/storage/, | ||
# 3. 如果STORAGE_TYPE为OPENDAL: 不生效 (图片URL将由OPENDAL_STORAGE_PROVIDER决定) | ||
STORAGE_DOMAIN=http://127.0.0.1:5000/storage/ | ||
# (可不修改) 允许上传文件的最大大小(MB),默认 1GB | ||
MAX_CONTENT_LENGTH_MB=1024 | ||
|
||
## OSS_*: STORAGE_TYPE为OSS时的配置 | ||
OSS_ACCESS_KEY_ID= | ||
OSS_ACCESS_KEY_SECRET= | ||
# OSS Endpoint(地域节点) | ||
# 含协议名,形如 https://oss-cn-shanghai.aliyuncs.com/ | ||
OSS_ENDPOINT= | ||
OSS_BUCKET_NAME= | ||
# (可不修改) OSS 图片处理规则名称 | ||
OSS_PROCESS_COVER_NAME=cover | ||
OSS_PROCESS_SAFE_CHECK_NAME=safe-check | ||
|
||
# ----------- | ||
# CDN 配置 | ||
# ----------- | ||
# 如果绑定了 CDN 来加速 OSS,且开启了 CDN 的[阿里云 OSS 私有 Bucket 回源]和[URL 鉴权], | ||
# 此时需要设置 OSS_VIA_CDN = True,并设置 CDN URL 鉴权主/备 KEY | ||
OSS_VIA_CDN=True | ||
CDN_URL_KEY_A= | ||
CDN_URL_KEY_B= | ||
|
||
# ----------- | ||
# Email 配置 | ||
# ----------- | ||
# 是否发送用户邮件(验证码等) | ||
ENABLE_USER_EMAIL=False | ||
# 是否发送日志邮件 | ||
ENABLE_LOG_EMAIL=False | ||
# SMTP 服务器地址 | ||
EMAIL_SMTP_HOST= | ||
# SMTP 服务器端口 | ||
EMAIL_SMTP_PORT= | ||
# 是否使用 SSL 连接 SMTP 服务器 | ||
EMAIL_USE_SSL=True | ||
# 发件邮箱地址 | ||
EMAIL_ADDRESS= | ||
# SMTP 服务器登陆用户名,通常是邮箱全称 | ||
EMAIL_USERNAME= | ||
# SMTP 服务器登陆密码 | ||
EMAIL_PASSWORD= | ||
# 用户回信邮箱地址 | ||
EMAIL_REPLY_ADDRESS= | ||
# 网站错误报告邮箱地址 | ||
EMAIL_ERROR_ADDRESS= | ||
|
||
# Options for non default features. only enable if you know what you are doing. | ||
# CELERY_BROKER_URL="amqp://moeflow:PLEASE_CHANGE_THIS@moeflow-rabbitmq:5672/moeflow" | ||
# CELERY_BACKEND_URL='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin' | ||
# MIT_STORAGE_ROOT=/app/storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ on: | |
workflow_dispatch: | ||
|
||
jobs: | ||
check-pr: | ||
static-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -17,3 +17,31 @@ jobs: | |
- run: pip install -r requirements.txt | ||
- run: ruff check . | ||
- run: ruff format --diff . | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: docker-compose -f tests/deps.yaml up -d | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
cache: 'pip' | ||
- run: pip install -r requirements.txt | ||
- run: cp -rv .env.test.sample .env.test | ||
- uses: pavelzw/pytest-action@v2 | ||
with: | ||
emoji: false | ||
verbose: true | ||
job-summary: true | ||
- uses: codecov/[email protected] | ||
if: always() | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
# XXX: can't if (SECRET_DEFINED) for this step | ||
- name: save test report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: report.html | ||
path: report.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
PYTEST_COV_ARGS = | ||
|
||
FORCE: ; | ||
|
||
create-venv: | ||
python3.10 -mvenv venv | ||
|
||
deps: | ||
venv/bin/pip install -r requirements.txt | ||
|
||
remove-venv: FORCE | ||
rm -rf venv | ||
|
||
recreate-venv: remove-venv create-venv | ||
|
||
lint: | ||
venv/bin/ruff check | ||
|
||
lint-fix: | ||
venv/bin/ruff --fix | ||
|
||
format: | ||
venv/bin/ruff format | ||
|
||
requirements.txt: deps-top.txt recreate-venv | ||
venv/bin/pip install -r deps-top.txt | ||
echo '# GENERATED: run make requirements.txt to recreate lock file' > requirements.txt | ||
venv/bin/pipdeptree --freeze >> requirements.txt | ||
|
||
test: test_all | ||
|
||
test_all: | ||
venv/bin/pytest | ||
|
||
test_all_parallel: | ||
# TODO: fix this | ||
venv/bin/pytest -n 8 | ||
|
||
test_single: | ||
venv/bin/pytest tests/api/test_file_api.py | ||
|
||
test_logging: | ||
#--capture=no | ||
venv/bin/pytest --capture=sys --log-cli-level=DEBUG tests/base/test_logging.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.