Skip to content

Commit

Permalink
👷 添加数据库测试工作流
Browse files Browse the repository at this point in the history
  • Loading branch information
KomoriDev authored Aug 2, 2024
1 parent 07fc34c commit 5a384a0
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/database_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Database Test

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
db: ["sqlite+aiosqlite://"]
db-pool: ["StaticPool"]
include:
- os: ubuntu-latest
python-version: "3.10"
db: postgresql+asyncpg://postgres:postgres@localhost:5432/postgres
db-pool: NullPool

- os: ubuntu-latest
python-version: "3.10"
db: mysql+aiomysql://mysql:mysql@localhost:3306/mymysql
db-pool: NullPool
fail-fast: false

env:
OS: ${{ matrix.os }}
PYTHON_VERSION: ${{ matrix.python-version }}
SQLALCHEMY_DATABASE_URL: ${{ matrix.db }}
SQLALCHEMY_POOL_CLASS: ${{ matrix.db-pool }}

services:
postgresql:
image: ${{ startsWith(matrix.db, 'postgresql') && 'postgres' || '' }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432

mysql:
image: ${{ startsWith(matrix.db, 'mysql') && 'mysql' || '' }}
env:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_DATABASE: mymysql
ports:
- 3306:3306

steps:
- uses: actions/checkout@v4

- name: Setup Python environment
uses: ./.github/actions/setup-python

- name: Run migrations
run: pipx run nb-cli orm upgrade

- name: Run tests
run: pytest

0 comments on commit 5a384a0

Please sign in to comment.