diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d4723b632e7a82601cf6221169d2d06aec4a706..138c86676ca782a18fb3e0a973a780c57fc8c35b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,49 +1,48 @@ -image: postgis/postgis:17-3.5 - -stages: - - test - +# Define the variables globally variables: - NAME: anthology - USER: anthology_django - PASSWORD: password - HOST: mdillon-postgis + POSTGRES_DB: anthology + POSTGRES_USER: anthology_django + POSTGRES_PASSWORD: password + HOST: postgres UV_CACHE_DIR: "$CI_PROJECT_DIR/.uv-cache" APT_DIR: "$CI_PROJECT_DIR/.apt" APT_STATE_LISTS: "$CI_PROJECT_DIR/.apt/lists" APT_CACHE_ARCHIVES: "$CI_PROJECT_DIR/.apt/archives" -cache: - - key: - files: - - uv.lock - paths: - - $UV_CACHE_DIR - - paths: - - .apt/ +# Defining image, services and cache by default (defining globally is deprecated) +default: + image: ubuntu:latest + services: + - name: postgis/postgis:17-3.5 + alias: postgres + cache: + - key: + files: + - uv.lock + paths: + - $UV_CACHE_DIR + - paths: + - .apt/ -test: - stage: test - before_script: +tests: + script: # Install dependencies and create associated cache dirs - mkdir -p "${APT_STATE_LISTS}/partial" - mkdir -p "${APT_CACHE_ARCHIVES}/partial" - apt update -qy - - apt install -y apt-utils curl libgdal-dev - - export PGPASSWORD=$PASSWORD - - psql -c "CREATE DATABASE anthology;" - - psql -c "CREATE USER anthology_django WITH PASSWORD 'password';" - - psql -c "ALTER ROLE anthology_django SET client_encoding TO 'utf8';" - - psql -c "ALTER ROLE anthology_django SET default_transaction_isolation TO 'read committed';" - - psql -c "ALTER ROLE anthology_django SET timezone TO 'UTC-4';" - - psql -c "ALTER USER anthology_django CREATEDB;" - - psql -c "GRANT ALL PRIVILEGES ON DATABASE anthology TO anthology_django;" - - psql -c "CREATE EXTENSION postgis;" + - apt install -y apt-utils curl postgresql postgresql-contrib libgdal-dev make gettext + - export PGPASSWORD=$POSTGRES_PASSWORD + - psql --username $POSTGRES_USER --host $HOST -d $POSTGRES_DB -c "ALTER ROLE anthology_django SET client_encoding TO 'utf8';" + - psql --username $POSTGRES_USER --host $HOST -d $POSTGRES_DB -c "ALTER ROLE anthology_django SET default_transaction_isolation TO 'read committed';" + - psql --username $POSTGRES_USER --host $HOST -d $POSTGRES_DB -c "ALTER ROLE anthology_django SET timezone TO 'UTC-4';" + - psql --username $POSTGRES_USER --host $HOST -d $POSTGRES_DB -c "ALTER USER anthology_django CREATEDB;" + - psql --username $POSTGRES_USER --host $HOST -d $POSTGRES_DB -c "GRANT ALL PRIVILEGES ON DATABASE anthology TO anthology_django;" + - psql --username $POSTGRES_USER --host $HOST -d $POSTGRES_DB -c "CREATE EXTENSION IF NOT EXISTS postgis;" # Install uv, see https://docs.astral.sh/uv/#getting-started - curl -LsSf https://astral.sh/uv/install.sh | sh # Put uv in the path - source $HOME/.local/bin/env # Check the available version of Python - uv python list - script: + - make compilemessages_ci - make tests_ci diff --git a/Makefile b/Makefile index 8a6a649275fa092490607cdbdca2f256c46d7964..b6c06f4e83d35e600da16ccc9e0ae9ab4a65b1ae 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,11 @@ integration_tests: uv run python -m playwright install cd django/ && DJANGO_SETTINGS_MODULE=anthology.settings.local uv run pytest ../integration --browser firefox --browser chromium --browser webkit --base-url http://127.0.0.1:8000 +compilemessages_ci: + cd django/ && DJANGO_SETTINGS_MODULE=anthology.settings.gitlab_test uv run manage.py compilemessages + tests_ci: - cd django/ && DJANGO_SETTINGS_MODULE=anthology.settings.gitlab_test uv run pytest + cd django/ && DJANGO_SETTINGS_MODULE=anthology.settings.gitlab_test uv run pytest -x -vv tests: cd django/ && DJANGO_SETTINGS_MODULE=anthology.settings.local uv run pytest diff --git a/django/anthology/settings/gitlab_test.py b/django/anthology/settings/gitlab_test.py index 8245fef82cf5aa8ce42443ad6cacce167cfb52ab..35ccbcc7e2c1244d8966d8f55841f2d53bf7652b 100644 --- a/django/anthology/settings/gitlab_test.py +++ b/django/anthology/settings/gitlab_test.py @@ -2,4 +2,4 @@ from . import * # noqa DEBUG = True -DATABASES["default"]["HOST"] = "mdillon-postgis" +DATABASES["default"]["HOST"] = "postgres"