diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 17b666d3..6a0d5f2b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,22 +11,22 @@ variables: DB_HOST: localhost TEST_RECURSION_LIMIT: 10000 -before_script: - - export PATH="$HOME/.poetry/bin:${PATH}" - - ./docker/scripts/install-deps.sh - - ./docker/scripts/install-python-deps.sh - - useradd -U -d /aurweb -c 'AUR User' aur - - ./docker/mariadb-entrypoint.sh - - (cd '/usr' && /usr/bin/mysqld_safe --datadir='/var/lib/mysql') & - - 'until : > /dev/tcp/127.0.0.1/3306; do sleep 1s; done' - - ./docker/test-mysql-entrypoint.sh # Create mysql AUR_CONFIG. - - ./docker/test-sqlite-entrypoint.sh # Create sqlite AUR_CONFIG. - - make -C po all install - - python -m aurweb.initdb # Initialize MySQL tables. - - AUR_CONFIG=conf/config.sqlite python -m aurweb.initdb - - make -C test clean - test: + stage: test + before_script: + - export PATH="$HOME/.poetry/bin:${PATH}" + - ./docker/scripts/install-deps.sh + - ./docker/scripts/install-python-deps.sh + - useradd -U -d /aurweb -c 'AUR User' aur + - ./docker/mariadb-entrypoint.sh + - (cd '/usr' && /usr/bin/mysqld_safe --datadir='/var/lib/mysql') & + - 'until : > /dev/tcp/127.0.0.1/3306; do sleep 1s; done' + - ./docker/test-mysql-entrypoint.sh # Create mysql AUR_CONFIG. + - ./docker/test-sqlite-entrypoint.sh # Create sqlite AUR_CONFIG. + - make -C po all install + - python -m aurweb.initdb # Initialize MySQL tables. + - AUR_CONFIG=conf/config.sqlite python -m aurweb.initdb + - make -C test clean script: - make -C test sh pytest # sharness tests use sqlite & pytest w/ mysql. - AUR_CONFIG=conf/config.sqlite make -C test pytest @@ -41,3 +41,21 @@ test: artifacts: reports: cobertura: coverage.xml + +deploy: + stage: deploy + tags: + - secure + rules: + - if: $CI_COMMIT_BRANCH == "pu" + when: manual + script: + - pacman -Syu --noconfirm docker-compose socat openssh + - chmod 600 ${SSH_KEY} + - socat "UNIX-LISTEN:/tmp/docker.sock,reuseaddr,fork" EXEC:"ssh -o UserKnownHostsFile=${SSH_KNOWN_HOSTS} -Ti ${SSH_KEY} ${SSH_USER}@${SSH_HOST}" & + - export DOCKER_HOST="unix:///tmp/docker.sock" + - docker-compose build + - docker-compose -f docker-compose.yml -f docker-compose.aur-dev.yml up -d + environment: + name: development + url: https://aur-dev.archlinux.org diff --git a/docker-compose.prod.yml b/docker-compose.aur-dev.yml similarity index 82% rename from docker-compose.prod.yml rename to docker-compose.aur-dev.yml index 9ea26663..f03d0a4f 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.aur-dev.yml @@ -5,32 +5,47 @@ services: volumes: - cache:/cache + memcached: + restart: always + + redis: + restart: always + + mariadb: + restart: always + git: + restart: always volumes: - ${GIT_DATA_DIR}:/aurweb/aur.git - cache:/cache - ${MARIADB_SOCKET_DIR}:/var/run/mysqld smartgit: + restart: always volumes: - ${GIT_DATA_DIR}:/aurweb/aur.git - cache:/cache - smartgit_run:/var/run/smartgit cgit-php: + restart: always volumes: - ${GIT_DATA_DIR}:/aurweb/aur.git cgit-fastapi: + restart: always volumes: - ${GIT_DATA_DIR}:/aurweb/aur.git php-fpm: + restart: always volumes: - cache:/cache - ${MARIADB_SOCKET_DIR}:/var/run/mysqld fastapi: + restart: always environment: - FASTAPI_BACKEND="gunicorn" volumes: @@ -42,6 +57,7 @@ services: - ${MARIADB_SOCKET_DIR}:/var/run/mysqld nginx: + restart: always volumes: - ${GIT_DATA_DIR}:/aurweb/aur.git - cache:/cache