Merge branch 'main' into 1774-introduce-user-settings #2989
Workflow file for this run
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
name: migrations | |
# Based on a dump of a existing postgresql database, valid for a given | |
# fractal-server version, apply current migrations and verify that they go | |
# through. The main goal is to identify cases where current data make a table | |
# definition invalid in a way that wouldn't be detected when starting from an | |
# empty database; typical example: a coulmn has a null value, and we later | |
# alter it to make it non-nullable. | |
on: | |
push: | |
branches: ["main", "1774-introduce-user-settings"] | |
pull_request: | |
branches: ["main", "1774-introduce-user-settings"] | |
env: | |
# The DB `${ROOTDIR}/clean_db_fractal_${SOURCE_VERSION}.sql` is compatible | |
# with the SOURCE_VERSION of fractal-server. | |
# Here we test the script that upgrades the DB from SOURCE_VERSION to the | |
#current version. | |
SOURCE_VERSION: 2.4.0 | |
ROOTDIR: tests/data/testing_databases | |
jobs: | |
migrations: | |
name: "Python ${{ matrix.python-version }} - ${{ matrix.db }}" | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 20 | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11"] | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: fractal_test | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Load database dump into postgres database | |
env: | |
PGPASSWORD: postgres | |
run: psql -U postgres -h localhost -d fractal_test -f ${ROOTDIR}/clean_db_fractal_${SOURCE_VERSION}.sql | |
- name: Install poetry | |
run: pipx install poetry==1.8.2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "poetry" | |
- name: Install fractal-server | |
run: | | |
poetry install --without dev --without docs --no-interaction -E postgres | |
- name: Convert postgres database into sqlite | |
run: pipx run db-to-sqlite[postgresql]==1.5 "postgresql://postgres:postgres@localhost/fractal_test" $ROOTDIR/clean_db_fractal_${SOURCE_VERSION}.sql.sqlite3 --all | |
- name: Apply migration and fix-db script (postgres) | |
run: | | |
cp $ROOTDIR/.fractal_server_postgres.env .fractal_server.env | |
poetry run fractalctl set-db | |
echo -e "yes\nyes\nyes\nyes\nyes"| poetry run fractalctl update-db-data | |
poetry run python scripts/validate_db_data_with_read_schemas.py | |
- name: Apply migration and fix-db script (sqlite) | |
run: | | |
echo -e "DB_ENGINE=sqlite\nSQLITE_PATH=${ROOTDIR}/clean_db_fractal_${SOURCE_VERSION}.sql.sqlite3" > .fractal_server.env | |
poetry run fractalctl set-db | |
echo -e "yes\nyes\nyes\nyes\nyes" | poetry run fractalctl update-db-data | |
poetry run python scripts/validate_db_data_with_read_schemas.py |