Skip to content

Commit

Permalink
Merge pull request #225 from rtibbles/old_sqlite_compatible_migrations
Browse files Browse the repository at this point in the history
Squash migrations to prevent issues with older SQLite versions.
  • Loading branch information
bjester committed Jun 26, 2024
2 parents ea2219c + ac4d5a3 commit 882236c
Show file tree
Hide file tree
Showing 5 changed files with 679 additions and 6 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/check_migrations_sqlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Migrations for SQLite versions

on: [push, pull_request]

jobs:
pre_job:
name: Path match check
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths: '["morango/migrations/*.py", ".github/workflows/check_migrations_sqlite.yml", "setup.py", "requirements/*.txt"]'
migration_test:
name: SQLite migration tests
needs: pre_job
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install build dependencies
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: sudo apt install -y build-essential tcl
- name: Build SQLite 3.25.3
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: |
# Following the instructions from https://til.simonwillison.net/sqlite/ld-preload
# to build SQLite from source, using version 3.25.3
wget https://www.sqlite.org/src/tarball/89e099fb/SQLite-89e099fb.tar.gz
tar -xzvf SQLite-89e099fb.tar.gz
cd SQLite-89e099fb
CPPFLAGS="-DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_RTREE=1" ./configure
make
LD_PRELOAD=.libs/libsqlite3.so python3 -c \
'import sqlite3; assert sqlite3.connect(":memory").execute("select sqlite_version()").fetchone()[0] == "3.25.3"'
# Once we have confirmed that this works, set it for subsequent steps
echo "LD_PRELOAD=$(realpath .libs/libsqlite3.so)" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install .
- name: Run migrations
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: python tests/testapp/manage.py migrate
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ SHELL := bash
.ONESHELL:
.PHONY: help clean clean-pyc release dist

# standalone install method
DOCKER_COMPOSE = docker-compose

# support new plugin installation for docker-compose
ifeq (, $(shell which docker-compose))
DOCKER_COMPOSE = docker compose
endif

define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
Expand Down Expand Up @@ -84,16 +92,16 @@ tox:
set -ex
function _on_interrupt() {
# leave off `-v` to skip volume cleanup for debugging error
docker-compose down
$(DOCKER_COMPOSE) down
}
trap _on_interrupt SIGINT SIGTERM SIGKILL ERR
docker-compose up --detach
until docker-compose logs --tail=1 postgres | grep -q "database system is ready to accept connections"; do
$(DOCKER_COMPOSE) up --detach
until $(DOCKER_COMPOSE) logs --tail=1 postgres | grep -q "database system is ready to accept connections"; do
echo "$(date) - waiting for postgres..."
sleep 1
done
$(MAKE) -e $(subst -with-postgres,,$@)
docker-compose down -v
$(DOCKER_COMPOSE) down -v

coverage: ## check code coverage quickly with the default Python
coverage run --source morango setup.py test
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

services:
postgres:
image: postgres:9.6
Expand Down
Loading

0 comments on commit 882236c

Please sign in to comment.