Skip to content

Commit

Permalink
Use the inbuilt docker image for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
silentninja committed Sep 20, 2023
1 parent 6d3356f commit 9484062
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ jobs:
run: sudo chown -R 1000:1000 .

- name: Build the stack
run: docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d test-service
run: docker build -t mathesar_service_test --build-arg PYTHON_REQUIREMENTS=requirements-dev.txt .
env:
PG_VERSION: ${{ matrix.pg-version }}
PG_MAJOR: ${{ matrix.pg-version }}
- name: Run docker container
run: docker run --name mathesar_service_test

- name: Run tests with pytest
run: docker exec mathesar_service_test ./run_pytest.sh
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN set -ex; \
echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list; \
apt-get update -y; \
apt-get install -y --no-install-recommends \
postgresql-15 postgresql-client-15 postgresql-contrib-15 \
postgresql-$PG_MAJOR postgresql-client-$PG_MAJOR postgresql-contrib-$PG_MAJOR \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \
Expand Down
8 changes: 4 additions & 4 deletions db-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ docker_setup_env() {
docker_setup_env
# only run initialization on an empty data directory
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
pg_createcluster -d "$PGDATA" -p 5432 -u "postgres" 15 mathesar
pg_createcluster -d "$PGDATA" -p 5432 -u "postgres" "$PG_MAJOR" mathesar
# Create a temporary postgres server for setting password to the postgres user and for creating the default database
pg_ctlcluster 15 mathesar start
pg_ctlcluster "$PG_MAJOR" mathesar start
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'mathesar';"
sudo -u postgres psql -c "CREATE DATABASE mathesar_django;"
pg_ctlcluster 15 mathesar stop
pg_ctlcluster "$PG_MAJOR" mathesar stop
fi
pg_ctlcluster 15 mathesar start
pg_ctlcluster "$PG_MAJOR" mathesar start
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ env =
D:ALLOWED_HOSTS=
D:DEBUG=False
D:SECRET_KEY=hdC7qKjaFXNBjJ4heMMlOMrP-6j1-OvZpPf87DAXyaw
D:DJANGO_DATABASE_URL=postgres://mathesar:mathesar@mathesar_db:5432/mathesar_django
D:MATHESAR_DATABASES=(mathesar_db_test|postgres://mathesar:mathesar@mathesar_db:5432/mathesar_db_test)
D:DJANGO_DATABASE_URL=postgres://mathesar:mathesar@localhost:5432/mathesar_django
D:MATHESAR_DATABASES=(mathesar_db_test|postgres://mathesar:mathesar@localhost:5432/mathesar_db_test)
TEST=True
MODE=PRODUCTION
DJANGO_SETTINGS_MODULE=config.settings.production
Expand Down

0 comments on commit 9484062

Please sign in to comment.