https://dev.kronoz.win/r/marzneshin.git
1name: Python Alembic Migration Tests
2
3on:
4 push:
5 branches: master
6 pull_request:
7 branches: master
8
9jobs:
10 test:
11 runs-on: ubuntu-latest
12
13 services:
14 postgres:
15 image: postgres:15
16 env:
17 POSTGRES_USER: testuser
18 POSTGRES_PASSWORD: testpassword
19 POSTGRES_DB: testdb
20 ports:
21 - 5432:5432
22 options: >-
23 --health-cmd "pg_isready -U testuser"
24 --health-interval 10s
25 --health-timeout 5s
26 --health-retries 5
27
28 mysql:
29 image: mysql:8
30 env:
31 MYSQL_ROOT_PASSWORD: testpassword
32 MYSQL_DATABASE: testdb
33 MYSQL_USER: testuser
34 MYSQL_PASSWORD: testpassword
35 ports:
36 - 3306:3306
37 options: >-
38 --health-cmd "mysqladmin ping -h localhost -u root --password=testpassword"
39 --health-interval 10s
40 --health-timeout 5s
41 --health-retries 5
42
43 mariadb:
44 image: mariadb:10.6
45 env:
46 MYSQL_ROOT_PASSWORD: testpassword
47 MYSQL_DATABASE: testdb
48 MYSQL_USER: testuser
49 MYSQL_PASSWORD: testpassword
50 ports:
51 - 3307:3306
52 options: >-
53 --health-cmd "mysqladmin ping -h localhost -u root --password=testpassword"
54 --health-interval 10s
55 --health-timeout 5s
56 --health-retries 5
57
58 strategy:
59 matrix:
60 db: [sqlite, postgres, mysql, mariadb]
61
62 name: "Db type: ${{ matrix.db }}"
63
64 steps:
65 - uses: actions/checkout@v3
66
67 - name: Set up Python
68 uses: actions/setup-python@v4
69 with:
70 python-version: '3.12'
71
72 - name: Install dependencies
73 run: |
74 python -m pip install --upgrade pip
75 pip install -r requirements.txt
76 pip install pytest pytest-alembic pymysql psycopg psycopg-binary
77
78 - name: Wait for database to be ready
79 run: sleep 10
80
81 - name: Set DATABASE_URL
82 run: |
83 case "${{ matrix.db }}" in
84 sqlite)
85 echo "SQLALCHEMY_DATABASE_URL=sqlite:///db.sqlite3" >> $GITHUB_ENV
86 ;;
87 postgres)
88 echo "SQLALCHEMY_DATABASE_URL=postgresql+psycopg://testuser:testpassword@localhost:5432/testdb" >> $GITHUB_ENV
89 ;;
90 mysql)
91 echo "SQLALCHEMY_DATABASE_URL=mysql+pymysql://testuser:testpassword@localhost:3306/testdb" >> $GITHUB_ENV
92 ;;
93 mariadb)
94 echo "SQLALCHEMY_DATABASE_URL=mysql+pymysql://testuser:testpassword@localhost:3307/testdb" >> $GITHUB_ENV
95 ;;
96 esac
97
98 - name: Run Alembic Tests
99 run: pytest tests/ -v --disable-warnings