name: Run Migrations on: pull_request: paths: - "backend/alembic/versions/**" - ".github/workflows/migrations.yml" - pyproject.toml - uv.lock - .python-version permissions: read-all jobs: migrate-postgres: runs-on: ubuntu-latest permissions: checks: write pull-requests: write services: postgres: image: postgres:15 env: POSTGRES_USER: user POSTGRES_PASSWORD: password POSTGRES_DB: testdb ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install mariadb connectors run: | sudo apt-get update sudo apt-get install -y libmariadb3 libmariadb-dev - name: Install uv uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install python run: uv python install - name: Install dependencies run: uv sync - name: Run PostgreSQL Migrations working-directory: backend env: ROMM_DB_DRIVER: postgresql DB_HOST: localhost DB_PORT: 5432 DB_USER: user DB_PASSWD: password DB_NAME: testdb ROMM_AUTH_SECRET_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ROMM_BASE_PATH: romm_test run: uv run alembic upgrade head migrate-mariadb: # A server configured for utf8mb3 makes the roms table, the view literals # and the JSON_TABLE columns utf8mb3, which breaks collation-sensitive # migration SQL that a default utf8mb4 server accepts (issue #4350). name: migrate-mariadb (${{ matrix.collation }}) runs-on: ubuntu-latest permissions: checks: write pull-requests: write strategy: fail-fast: false matrix: include: - charset: utf8mb4 collation: utf8mb4_general_ci - charset: utf8mb3 collation: utf8mb3_unicode_ci steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install mariadb connectors run: | sudo apt-get update sudo apt-get install -y libmariadb3 libmariadb-dev - name: Install uv uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install python run: uv python install - name: Install dependencies run: uv sync - name: Start MariaDB env: CHARSET: ${{ matrix.charset }} COLLATION: ${{ matrix.collation }} run: | docker run -d --name mariadb -p 3306:3306 \ -e MARIADB_USER=user \ -e MARIADB_PASSWORD=password \ -e MARIADB_DATABASE=testdb \ -e MARIADB_ROOT_PASSWORD=root \ --health-cmd "healthcheck.sh --connect --innodb_initialized" \ --health-interval 5s \ --health-timeout 2s \ --health-retries 10 \ mariadb:11.3.2 \ --character-set-server="$CHARSET" \ --collation-server="$COLLATION" for _ in $(seq 1 30); do if [ "$(docker inspect -f '{{.State.Health.Status}}' mariadb)" = healthy ]; then exit 0 fi sleep 2 done echo "MariaDB never became healthy" >&2 docker logs mariadb >&2 exit 1 - name: Run MariaDB Migrations working-directory: backend env: ROMM_DB_DRIVER: mariadb DB_HOST: 127.0.0.1 DB_PORT: 3306 DB_USER: user DB_PASSWD: password DB_NAME: testdb ROMM_AUTH_SECRET_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ROMM_BASE_PATH: romm_test run: uv run alembic upgrade head