name: Python Alembic Migration Tests on: push: branches: master pull_request: branches: master jobs: test: runs-on: ubuntu-latest services: postgres: image: postgres:15 env: POSTGRES_USER: testuser POSTGRES_PASSWORD: testpassword POSTGRES_DB: testdb ports: - 5432:5432 options: >- --health-cmd "pg_isready -U testuser" --health-interval 10s --health-timeout 5s --health-retries 5 mysql: image: mysql:8 env: MYSQL_ROOT_PASSWORD: testpassword MYSQL_DATABASE: testdb MYSQL_USER: testuser MYSQL_PASSWORD: testpassword ports: - 3306:3306 options: >- --health-cmd "mysqladmin ping -h localhost -u root --password=testpassword" --health-interval 10s --health-timeout 5s --health-retries 5 mariadb: image: mariadb:10.6 env: MYSQL_ROOT_PASSWORD: testpassword MYSQL_DATABASE: testdb MYSQL_USER: testuser MYSQL_PASSWORD: testpassword ports: - 3307:3306 options: >- --health-cmd "mysqladmin ping -h localhost -u root --password=testpassword" --health-interval 10s --health-timeout 5s --health-retries 5 strategy: matrix: db: [sqlite, postgres, mysql, mariadb] name: "Db type: ${{ matrix.db }}" steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install pytest pytest-alembic pymysql psycopg psycopg-binary - name: Wait for database to be ready run: sleep 10 - name: Set DATABASE_URL run: | case "${{ matrix.db }}" in sqlite) echo "SQLALCHEMY_DATABASE_URL=sqlite:///db.sqlite3" >> $GITHUB_ENV ;; postgres) echo "SQLALCHEMY_DATABASE_URL=postgresql+psycopg://testuser:testpassword@localhost:5432/testdb" >> $GITHUB_ENV ;; mysql) echo "SQLALCHEMY_DATABASE_URL=mysql+pymysql://testuser:testpassword@localhost:3306/testdb" >> $GITHUB_ENV ;; mariadb) echo "SQLALCHEMY_DATABASE_URL=mysql+pymysql://testuser:testpassword@localhost:3307/testdb" >> $GITHUB_ENV ;; esac - name: Run Alembic Tests run: pytest tests/ -v --disable-warnings