From patchwork Wed Dec 8 17:02:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1565363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=hLe5VnFY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8NlH4nfSz9ssD for ; Thu, 9 Dec 2021 04:02:51 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J8NlG1qKPz300S for ; Thu, 9 Dec 2021 04:02:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=hLe5VnFY; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1035; helo=mail-pj1-x1035.google.com; envelope-from=vicamo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=hLe5VnFY; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J8NlC4y4nz2yg5 for ; Thu, 9 Dec 2021 04:02:45 +1100 (AEDT) Received: by mail-pj1-x1035.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so4372461pjb.1 for ; Wed, 08 Dec 2021 09:02:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vs/Mb4ac1wHnJs4db9D6ww7uaHkzJYH3ylSoXWwOekM=; b=hLe5VnFY2eNM7QpafOtN6AbGdTCM/29lkLYUdwhVv27DnvOchubBxT5Mlpd+xyyn4S BcoGqnbLblQNPuZMxXkWP4kf98DGBdiZCWWP/f0jfU/1SU3SjJVaOLHMuS3JsdnhTI/L snDoJaDYBvSx65NGKFBTJ7NJMi7Q1B7epGYXvDdZky9g5abT0QfStpNGf+Pskkc7R23q 8tSJ3gDZoVNH3qL8m7nL+vatgSJcQ2Tm2rr1e6CgWwY1h4s38rPEg+9bn+kKK66XPilb ikCYcsipGSqgdTvV6FiNeIJJXk2zFrd7JGp//7McVu60zWVOQ3H/U18yG/FhN3VfWdga 4ouw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vs/Mb4ac1wHnJs4db9D6ww7uaHkzJYH3ylSoXWwOekM=; b=eQCepHnqAEIJgcVzdwlJ0PU6I74PrCzz3OlC3A5AtM8oaIggQwBbRdMdJ9Mg6+QEG4 75BYzhwkV6lWfmhCvROuQ2EcrSgUztcsCN1dX/o6Iqc5/isGV1t6dqeWt7SK+kTWwVEy gtPai5vuQwpaWP+jTruxE5H/xzOhVpYbgCoUqeLklfgUfbt7HyrfhgYFDaK87x1709NP CBwmAiZVYAV96AwphntLsS1ipG5Ipbn8B2OphAXnVj4uJk64srziI1omNu3CGRzMEHf0 5iVbsomaYeAhlWo/t1ZRw8GqFaEy4AfjN8nGqqPVOuB+5CLsv+pxSHAkTvOioSArox91 K15g== X-Gm-Message-State: AOAM532RFyw5ksIynkjJ0QmOHpaLXlbf6iInyJdafA82D+ROqVc5HG+t ISLcAX9z63CI1nla+xBrZ+YO8iM1YZA= X-Google-Smtp-Source: ABdhPJwEiF/G1Z/cjIv6C4NIS73dHo8ldWAdO2dFOVW8mCp3TLHf7KcsXhF0MnaYtQVqu0JkRmK7ZA== X-Received: by 2002:a17:90a:1a55:: with SMTP id 21mr8551981pjl.240.1638982962959; Wed, 08 Dec 2021 09:02:42 -0800 (PST) Received: from localhost (218-173-141-247.dynamic-ip.hinet.net. [218.173.141.247]) by smtp.gmail.com with ESMTPSA id h5sm4257778pfi.46.2021.12.08.09.02.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 09:02:42 -0800 (PST) From: You-Sheng Yang To: patchwork@lists.ozlabs.org Subject: [PATCH v3 1/6] settings: unify database connection variables Date: Thu, 9 Dec 2021 01:02:33 +0800 Message-Id: <20211208170238.142017-2-vicamo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208170238.142017-1-vicamo@gmail.com> References: <20211208170238.142017-1-vicamo@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This changeset replaces all PW_TEST_DB_* with corresponding DATABASE_* variables, fixes inconsistent DATABASE_PASS/DATABASE_PASSWORD usages, and moves database settings into base.py for sharing/syncing between dev and production setup. Signed-off-by: You-Sheng Yang --- .github/workflows/ci.yaml | 40 +++++++++++-------- docker-compose-pg.yml | 12 +++--- docker-compose.yml | 10 +++-- docs/deployment/installation.rst | 4 +- docs/development/installation.rst | 13 +++--- lib/uwsgi/patchwork.ini | 2 +- patchwork/settings/base.py | 39 ++++++++++++++++++ patchwork/settings/dev.py | 28 +------------ patchwork/settings/production.example.py | 17 -------- tools/docker/entrypoint.sh | 51 ++++++++++++++++-------- tox.ini | 4 +- 11 files changed, 123 insertions(+), 97 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f4a33b3..d37cdbf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,13 +25,20 @@ jobs: matrix: python: [3.6, 3.7, 3.8, 3.9] db: [postgres, mysql] + env: + DATABASE_TYPE: "${{ matrix.db }}" + DATABASE_HOST: "127.0.0.1" + DATABASE_NAME: patchwork + DATABASE_USER: patchwork + DATABASE_PASSWORD: password + MYSQL_ROOT_PASSWORD: root services: postgres: image: postgres:latest env: - POSTGRES_DB: patchwork - POSTGRES_PASSWORD: patchwork - POSTGRES_USER: patchwork + POSTGRES_DB: ${{ env.DATABASE_NAME }} + POSTGRES_PASSWORD: ${{ env.DATABASE_PASSWORD }} + POSTGRES_USER: ${{ env.DATABASE_USER }} ports: - 5432:5432 options: >- @@ -42,10 +49,10 @@ jobs: mysql: image: mysql:latest env: - MYSQL_DATABASE: patchwork - MYSQL_USER: patchwork - MYSQL_PASSWORD: patchwork - MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: ${{ env.DATABASE_NAME }} + MYSQL_USER: ${{ env.DATABASE_USER }} + MYSQL_PASSWORD: ${{ env.DATABASE_PASSWORD }} + MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} ports: - 3306:3306 options: >- @@ -64,22 +71,23 @@ jobs: run: python -m pip install tox tox-gh-actions codecov - name: Log database configuration (mysql) if: ${{ matrix.db == 'mysql' }} - run: mysql -h 127.0.0.1 -e "SELECT VERSION(), CURRENT_USER();" -uroot -proot patchwork + run: | + mysql -h 127.0.0.1 -e "SELECT VERSION(), CURRENT_USER();" \ + -uroot -p${MYSQL_ROOT_PASSWORD} ${DATABASE_NAME} - name: Log database configuration (postgres) if: ${{ matrix.db == 'postgres' }} - run: psql -h 127.0.0.1 -c "SELECT VERSION(), CURRENT_USER, current_database()" -U patchwork -d patchwork + run: | + psql -h 127.0.0.1 -c "SELECT VERSION(), CURRENT_USER, current_database()" \ + -U ${DATABASE_USER} -d ${DATABASE_NAME} env: - PGPASSWORD: patchwork + PGPASSWORD: ${{ env.DATABASE_PASSWORD }} - name: Modify database user permissions (mysql) if: ${{ matrix.db == 'mysql' }} - run: mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_patchwork%\`.* to 'patchwork'@'%';" -uroot -proot + run: | + mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* to '${DATABASE_USER}'@'%';" \ + -uroot -p${MYSQL_ROOT_PASSWORD} - name: Run unit tests (via tox) run: tox - env: - PW_TEST_DB_TYPE: "${{ matrix.db }}" - PW_TEST_DB_USER: "patchwork" - PW_TEST_DB_PASS: "patchwork" - PW_TEST_DB_HOST: "127.0.0.1" docs: name: Build docs runs-on: ubuntu-latest diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml index 44c49fb..7398929 100644 --- a/docker-compose-pg.yml +++ b/docker-compose-pg.yml @@ -24,9 +24,9 @@ services: environment: - UID - GID - - PW_TEST_DB_HOST=db - - PW_TEST_DB_PORT=5432 - - PW_TEST_DB_TYPE=postgres - - PW_TEST_DB_USER=postgres - - PW_TEST_DB_PASS=password - - PGPASSWORD=password + - DATABASE_TYPE=postgres + - DATABASE_HOST=db + - DATABASE_PORT=5432 + - DATABASE_NAME=patchwork + - DATABASE_USER=postgres + - DATABASE_PASSWORD=password diff --git a/docker-compose.yml b/docker-compose.yml index 1d49c51..103f19f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: volumes: - ./tools/docker/db/data:/var/lib/mysql environment: - - MYSQL_ROOT_PASSWORD=password + - MYSQL_ROOT_PASSWORD=root - MYSQL_USER=patchwork - MYSQL_PASSWORD=password @@ -26,5 +26,9 @@ services: environment: - UID - GID - - PW_TEST_DB_HOST=db - - PW_TEST_DB_PORT=3306 + # skip DATABASE_TYPE explicitly as mysql should be the default type. + - DATABASE_HOST=db + - DATABASE_PORT=3306 + - DATABASE_USER=patchwork + - DATABASE_PASSWORD=password + - MYSQL_ROOT_PASSWORD=root diff --git a/docs/deployment/installation.rst b/docs/deployment/installation.rst index 1abf187..14ad746 100644 --- a/docs/deployment/installation.rst +++ b/docs/deployment/installation.rst @@ -64,7 +64,7 @@ used to ease deployment: Username that the Patchwork web application will access the database with. We will use ``www-data``, for reasons described later in this guide. -``DATABASE_PASS=`` +``DATABASE_PASSWORD=`` Password that the Patchwork web application will access the database with. As we're going to use *peer* authentication (more on this later), this will be unset. @@ -323,7 +323,7 @@ Once done, we should be able to check that all requirements are met using the $ sudo -u www-data \ --preserve-env=DATABASE_NAME \ --preserve-env=DATABASE_USER \ - --preserve-env=DATABASE_PASS \ + --preserve-env=DATABASE_PASSWORD \ --preserve-env=DATABASE_HOST \ --preserve-env=DATABASE_PORT \ --preserve-env=STATIC_ROOT \ diff --git a/docs/development/installation.rst b/docs/development/installation.rst index d16177c..3507f43 100644 --- a/docs/development/installation.rst +++ b/docs/development/installation.rst @@ -316,7 +316,7 @@ if necessary: The ``patchwork`` username and ``password`` password are the defaults expected by the provided ``dev`` settings files. If using something - different, export the ``PW_TEST_DB_USER`` and ``PW_TEST_DB_PASS`` variables + different, export the ``DATABASE_USER`` and ``DATABASE_PASSWORD`` variables described in the :ref:`Environment Variables ` section below. Alternatively, you can create your own settings file with these variables hardcoded and change the value of ``DJANGO_SETTINGS_MODULE`` as described @@ -470,17 +470,16 @@ __ https://django-dbbackup.readthedocs.io/en/stable/ Environment Variables --------------------- -The following environment variables are available to configure settings when -using the provided ``dev`` settings file. +The following environment variables are available to configure settings. -``PW_TEST_DB_NAME=patchwork`` +``DATABASE_NAME=patchwork`` Name of the database -``PW_TEST_DB_USER=patchwork`` +``DATABASE_USER=patchwork`` Username to access the database with -``PW_TEST_DB_PASS=password`` +``DATABASE_PASSWORD=password`` Password to access the database with< -``PW_TEST_DB_TYPE=mysql`` +``DATABASE_TYPE=mysql`` Type of database to use. Options: ``mysql``, ``postgres`` diff --git a/lib/uwsgi/patchwork.ini b/lib/uwsgi/patchwork.ini index 95a0613..dbff508 100644 --- a/lib/uwsgi/patchwork.ini +++ b/lib/uwsgi/patchwork.ini @@ -10,7 +10,7 @@ url = / # env = DJANGO_SECRET_KEY= # env = DATABASE_NAME= # env = DATABASE_USER= -# env = DATABASE_PASS= +# env = DATABASE_PASSWORD= # env = DATABASE_HOST= # env = DATABASE_PORT= # env = STATIC_ROOT= diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py index ff14d91..5e200f0 100644 --- a/patchwork/settings/base.py +++ b/patchwork/settings/base.py @@ -105,6 +105,45 @@ STATICFILES_DIRS = [ os.path.join(ROOT_DIR, 'htdocs'), ] +# Database +# +# If you're using a postgres database, connecting over a local unix-domain +# socket, then the following setting should work for you. Otherwise, +# see https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +if os.getenv('DATABASE_TYPE', None) == 'postgres': + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'HOST': os.environ.get('DATABASE_HOST', 'localhost'), + 'PORT': os.environ.get('DATABASE_PORT', ''), + 'NAME': os.environ.get('DATABASE_NAME', 'patchwork'), + 'USER': os.environ.get('DATABASE_USER', 'patchwork'), + 'PASSWORD': os.environ.get('DATABASE_PASSWORD', 'password'), + }, + } +elif os.getenv('DATABASE_TYPE', None) == 'sqlite3': + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.environ.get('DATABASE_NAME', ''), + }, + } +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'HOST': os.getenv('DATABASE_HOST', 'localhost'), + 'PORT': os.getenv('DATABASE_PORT', ''), + 'NAME': os.getenv('DATABASE_NAME', 'patchwork'), + 'USER': os.getenv('DATABASE_USER', 'patchwork'), + 'PASSWORD': os.getenv('DATABASE_PASSWORD', 'password'), + 'TEST': { + 'CHARSET': 'utf8', + }, + }, + } + # # Third-party application settings # diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py index 2b7fc95..cb4cb19 100644 --- a/patchwork/settings/dev.py +++ b/patchwork/settings/dev.py @@ -7,8 +7,6 @@ Design based on: http://www.revsys.com/blog/2014/nov/21/recommended-django-project-layout/ """ -import os - from .base import * # noqa try: @@ -36,30 +34,8 @@ SECRET_KEY = '00000000000000000000000000000000000000000000000000' # noqa DEBUG = True -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'HOST': os.getenv('PW_TEST_DB_HOST', 'localhost'), - 'PORT': os.getenv('PW_TEST_DB_PORT', ''), - 'USER': os.getenv('PW_TEST_DB_USER', 'patchwork'), - 'PASSWORD': os.getenv('PW_TEST_DB_PASS', 'password'), - 'NAME': os.getenv('PW_TEST_DB_NAME', 'patchwork'), - 'TEST': { - 'CHARSET': 'utf8', - }, - }, -} - -if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres': - DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' - DATABASES['default']['HOST'] = os.getenv('PW_TEST_DB_HOST', '') -elif os.getenv('PW_TEST_DB_TYPE', None) == 'sqlite': - DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3' - DATABASES['default']['NAME'] = '/dev/shm/patchwork.test.db.sqlite3' - del DATABASES['default']['HOST'] - del DATABASES['default']['PORT'] - del DATABASES['default']['USER'] - del DATABASES['default']['PASSWORD'] +if DATABASES['default']['ENGINE'] == 'mysql': # noqa: F405 + DATABASES['default']['TEST'] = {'CHARSET': 'utf8'} # noqa: F405 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/patchwork/settings/production.example.py b/patchwork/settings/production.example.py index caaf429..ff05629 100644 --- a/patchwork/settings/production.example.py +++ b/patchwork/settings/production.example.py @@ -48,23 +48,6 @@ ADMINS = ( # ('Jeremy Kerr', 'jk@ozlabs.org'), ) -# Database -# -# If you're using a postgres database, connecting over a local unix-domain -# socket, then the following setting should work for you. Otherwise, -# see https://docs.djangoproject.com/en/2.2/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': os.environ.get('DATABASE_NAME', ''), - 'USER': os.environ.get('DATABASE_USER', ''), - 'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''), - 'HOST': os.environ.get('DATABASE_HOST', ''), - 'PORT': os.environ.get('DATABASE_PORT', ''), - }, -} - # # Static files settings # https://docs.djangoproject.com/en/2.2/ref/settings/#static-files diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index 5450a53..faa36b3 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -1,45 +1,62 @@ #!/bin/bash set -euo pipefail -PW_TEST_DB_TYPE=${PW_TEST_DB_TYPE:-mysql} +export DATABASE_HOST=${DATABASE_HOST:-} +export DATABASE_PORT=${DATABASE_PORT:-} +export DATABASE_NAME=${DATABASE_NAME:-patchwork} +export DATABASE_USER=${DATABASE_USER:-patchwork} +export DATABASE_PASSWORD=${DATABASE_PASSWORD:-password} + +case "${DATABASE_TYPE:-}" in +postgres) + export PGPORT=${DATABASE_PORT} + export PGPASSWORD=${DATABASE_PASSWORD} + psql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} "--username=${DATABASE_USER}" ) + ;; +*) + export DATABASE_TYPE=mysql + mysql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} ${DATABASE_PORT:+--port=${DATABASE_PORT}} "--user=${DATABASE_USER}" "--password=${DATABASE_PASSWORD}" ) + mysql_root_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} ${DATABASE_PORT:+--port=${DATABASE_PORT}} "--user=root" "--password=${MYSQL_ROOT_PASSWORD:-}" ) + ;; +esac # functions test_db_connection() { - if [ ${PW_TEST_DB_TYPE} = "postgres" ]; then - echo ';' | psql -h $PW_TEST_DB_HOST -U postgres 2> /dev/null > /dev/null + if [ ${DATABASE_TYPE} = "postgres" ]; then + echo ';' | psql "${psql_args[@]}" 2> /dev/null > /dev/null else - mysqladmin -h $PW_TEST_DB_HOST -u patchwork --password=password ping > /dev/null 2> /dev/null + mysqladmin "${mysql_root_args[@]}" ping > /dev/null 2> /dev/null fi } test_database() { - if [ ${PW_TEST_DB_TYPE} = "postgres" ]; then - echo ';' | psql -h $PW_TEST_DB_HOST -U postgres patchwork 2> /dev/null + if [ ${DATABASE_TYPE} = "postgres" ]; then + echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null else - echo ';' | mysql -h $PW_TEST_DB_HOST -u patchwork -ppassword patchwork 2> /dev/null + echo ';' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null fi } reset_data_mysql() { - mysql -uroot -ppassword -h $PW_TEST_DB_HOST << EOF -DROP DATABASE IF EXISTS patchwork; -CREATE DATABASE patchwork CHARACTER SET utf8; -GRANT ALL ON patchwork.* TO 'patchwork' IDENTIFIED BY 'password'; -GRANT ALL ON \`test\\_patchwork%\`.* to 'patchwork'@'%'; + mysql "${mysql_root_args[@]}" << EOF +DROP DATABASE IF EXISTS ${DATABASE_NAME}; +CREATE DATABASE ${DATABASE_NAME} CHARACTER SET utf8; +GRANT ALL ON ${DATABASE_NAME}.* TO '${DATABASE_USER}' IDENTIFIED BY '${DATABASE_PASSWORD}'; +GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* to '${DATABASE_USER}'@'%'; FLUSH PRIVILEGES; EOF } reset_data_postgres() { - psql -h $PW_TEST_DB_HOST -U postgres < X-Patchwork-Id: 1565365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WWtYatEU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8Nlb0lRvz9ssD for ; Thu, 9 Dec 2021 04:03:07 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J8NlV6ghJz3c5F for ; Thu, 9 Dec 2021 04:03:02 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WWtYatEU; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62a; helo=mail-pl1-x62a.google.com; envelope-from=vicamo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WWtYatEU; dkim-atps=neutral Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J8NlC74pCz2yng for ; Thu, 9 Dec 2021 04:02:47 +1100 (AEDT) Received: by mail-pl1-x62a.google.com with SMTP id y7so1970596plp.0 for ; Wed, 08 Dec 2021 09:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=q0zkMm8QMBlNil/9Y1IjeC28raOsGc0ddbuZVMMOb2I=; b=WWtYatEUAWCZ2BGLVwkqEHTwm1po3JAI2oCjKUpW576YlCqdvMdsc6sfNq7+Miix0n 8EW9LlfmQtmgf3SIrd0mtU1P5f5/Fyv1kypF5yz7yrKIMoJrC+LzJiiZvWsCvrt0g9uz 9wy6A+2ofcR20hQ5I/IrfF+P0oZIc9nAi0S//Wp6iDBOGet5O/gzJTGAx+7VxWsJxiUy h8QmCu4ewfDM8IvHPCQcxISrDqR5CQcAI0OjG+W01GUCxzsQkBjlocVEuFa6eaPQTiZU FSSjUnimUnP5f1e08tRLhTZM6KCTxEnnUs9FqiW0Y8iYNELS6IWq/eQdE9w504cIp4TL BrAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q0zkMm8QMBlNil/9Y1IjeC28raOsGc0ddbuZVMMOb2I=; b=GSPcBxopS9e5b5QnLluHq1HLyGwmKPaWAhRbo0aIbJWBh5c3R+GB7UBx4BdAzSSuBR BOh7s4ek7hOj05gLikC/MIXYZ4fTvf81Bc5QY3Gwy10vCtSzR57OGSYbCJzM7e3ZXtKZ 9J+YsUvf5lKE2vLcYE35cz6cvBctcvt/u34q38ZqUOZpWE2UHjHyBAUBOqOmQGR7vvh9 l9oCKQzPEGfl7nG1Af3GMpqrUkgfjXww+X7jBJAgj6Sryzn407HyDB3vOTHyEkHxvlKF omFvWZBL3y4ywdIYvGNt7AwyJd9lU7OOU+aJieVpX0N+mH5kR9j+B/mix9dQ3LssYLDp toEw== X-Gm-Message-State: AOAM5316t6s1oMxFavf0L0NF9/05I4WqO0aHVZ0pjWVCAjAllOcbiTQn 28rK2GPVK7H2tF10w3susGPJmgsXfTU= X-Google-Smtp-Source: ABdhPJxvaeYCe0i95zSX8JXkMwqsxPWBSsDWeLSOZ/MUr7EciHpZeoY0wbImLHHEYFqNv0fR9e733A== X-Received: by 2002:a17:90b:4c4b:: with SMTP id np11mr8708907pjb.233.1638982965808; Wed, 08 Dec 2021 09:02:45 -0800 (PST) Received: from localhost (218-173-141-247.dynamic-ip.hinet.net. [218.173.141.247]) by smtp.gmail.com with ESMTPSA id h1sm4190431pfh.219.2021.12.08.09.02.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 09:02:45 -0800 (PST) From: You-Sheng Yang To: patchwork@lists.ozlabs.org Subject: [PATCH v3 2/6] docker: remove deprecated startup arguments Date: Thu, 9 Dec 2021 01:02:34 +0800 Message-Id: <20211208170238.142017-3-vicamo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208170238.142017-1-vicamo@gmail.com> References: <20211208170238.142017-1-vicamo@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This also adds a default CMD directive so that it will launch a patchwork instance when started with no argument. Signed-off-by: You-Sheng Yang --- docker-compose-pg.yml | 1 - docker-compose.yml | 1 - docs/development/installation.rst | 4 ++-- ...recated-startup-arguments-768425c23b523d1e.yaml | 9 +++++++++ tools/docker/Dockerfile | 1 + tools/docker/entrypoint.sh | 14 ++------------ 6 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 releasenotes/notes/docker-remove-deprecated-startup-arguments-768425c23b523d1e.yaml diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml index 7398929..c99b25c 100644 --- a/docker-compose-pg.yml +++ b/docker-compose-pg.yml @@ -16,7 +16,6 @@ services: - GID depends_on: - db - command: python3 manage.py runserver 0.0.0.0:8000 volumes: - .:/home/patchwork/patchwork/ ports: diff --git a/docker-compose.yml b/docker-compose.yml index 103f19f..b91b7ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,6 @@ services: - GID depends_on: - db - command: python3 manage.py runserver 0.0.0.0:8000 volumes: - .:/home/patchwork/patchwork/ ports: diff --git a/docs/development/installation.rst b/docs/development/installation.rst index 3507f43..c5c0269 100644 --- a/docs/development/installation.rst +++ b/docs/development/installation.rst @@ -60,7 +60,7 @@ To run a shell within this environment, run: .. code-block:: shell - $ docker-compose run --rm web --shell + $ docker-compose run --rm web /bin/bash To run ``django-manage`` commands, such as ``createsuperuser`` or ``migrate``, run: @@ -85,7 +85,7 @@ Likewise, to restore an older version of the database, run: .. code-block:: shell - $ docker-compose run --rm -web python manage.py dbrestore + $ docker-compose run --rm web python manage.py dbrestore To run unit tests against the system Python packages, run: diff --git a/releasenotes/notes/docker-remove-deprecated-startup-arguments-768425c23b523d1e.yaml b/releasenotes/notes/docker-remove-deprecated-startup-arguments-768425c23b523d1e.yaml new file mode 100644 index 0000000..7b71ded --- /dev/null +++ b/releasenotes/notes/docker-remove-deprecated-startup-arguments-768425c23b523d1e.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Development docker image now launches a patchwork instance by default when + started with no argument. +deprecations: + - | + Long deprecated development docker image startup arguments --shell, --test, + --tox, --quick-test and --quick-tox are removed. diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index fe0cd59..71167e0 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -61,5 +61,6 @@ RUN pip install -r /opt/requirements-dev.txt COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"] USER patchwork WORKDIR /home/patchwork/patchwork diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index faa36b3..7e0af5a 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -133,20 +133,10 @@ elif ! test_database; then reset_data fi -# TODO(stephenfin): Deprecated the --test, --tox, --quick-test and --quick-tox -# flags in a future release if [ $# -eq 0 ]; then # we probably ran with --reset and nothing else # just exit cleanly exit 0 -elif [ "$1" == "--shell" ]; then - exec bash -elif [ "$1" == "--test" ] || [ "$1" == "--quick-test" ]; then - shift - python manage.py test $@ -elif [ "$1" == "--tox" ] || [ "$1" == "--quick-tox" ]; then - shift - tox $@ -else # run whatever CMD is set to - $@ fi + +exec "$@" From patchwork Wed Dec 8 17:02:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1565367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=g/qkkI4E; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8Nlg3Rt9z9tk5 for ; Thu, 9 Dec 2021 04:03:11 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J8Nlg2JyZz3bY9 for ; Thu, 9 Dec 2021 04:03:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=g/qkkI4E; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::431; helo=mail-pf1-x431.google.com; envelope-from=vicamo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=g/qkkI4E; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J8NlL2yfHz3bhl for ; Thu, 9 Dec 2021 04:02:54 +1100 (AEDT) Received: by mail-pf1-x431.google.com with SMTP id r130so3013746pfc.1 for ; Wed, 08 Dec 2021 09:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OmOqV1lErG9IFOXGgfnJwEAvIUpDKOwYQ5gBLXkDTmI=; b=g/qkkI4EVY2OJHuyBkbldOpPnLhcEThecbvArZUU28pAtdZ4ezkHWCRl3ul/tgG5DP TK4zjBrwV12QE/8KKsNtunqhjEzlCkMZIkfTgKKA0I+ecn8N9hncKpmJCyr48eGVffO1 moPwPvtQhPCUnGsvObmU0jcgxpV1cUIhJxZqNNtghwvG85tKAn8gaoKfLDKoocDC7TYA u1gf+ECch6PRwoseCvnyJ7TXGB+h7sOPAL4b0vymEn0/vULOmpI8O30DseajlxOC/A29 2acnNgC3kai4uONwL3jF5kNrFqdmT6gNcKcQj49h1hswyK4NlVGtDVnO/4yoh2aY+C+Q TYVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OmOqV1lErG9IFOXGgfnJwEAvIUpDKOwYQ5gBLXkDTmI=; b=uMe1GRxBgmqKR+gnuvMYIphsx/MBv1vaknsRsDpidScHc8KX9qNdOm6ZxcwBdpXo6L Gn+nntPt0v2IrqVQflSYJH/7Km5EbKXwbh8M6sw4pPEx3TSoYTDSXyxj6zNAgLvyOmen yB7x2mv9ZzOQJNzkE1HSu8hLKWhcH3yPP2YnAdJ+ju2IvREPPIoTOIXGls5i/QYdQzuO FnQ9im5MLZDk2p1ePxQVwu/it559fjAqrh2kmJZz43gz5lENg5TFKDSp9bfIqLbFb7v0 +aK9mQXQ93v+7f3aXysMPJdxGQFC3svqRAIFmxuWYhMONwFPJH5PTn47TcJJnqhbQJnn VmTw== X-Gm-Message-State: AOAM530romEVLH0Pa0u9/cCu2DT5ev0VtYrw78fjXCrq7eziTuGKlM6o JoFWgCH1x5nHf2InpTyeEU3dbWnZ0PQ= X-Google-Smtp-Source: ABdhPJxa2xHMvckMxeQQjQEG64gv/mvP008mMomglDS7nYF/QyCXuPvaGj3yqyfTDIIzJzJdkXRa9A== X-Received: by 2002:a63:a0b:: with SMTP id 11mr31069255pgk.282.1638982967544; Wed, 08 Dec 2021 09:02:47 -0800 (PST) Received: from localhost (218-173-141-247.dynamic-ip.hinet.net. [218.173.141.247]) by smtp.gmail.com with ESMTPSA id y31sm4735821pfa.92.2021.12.08.09.02.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 09:02:47 -0800 (PST) From: You-Sheng Yang To: patchwork@lists.ozlabs.org Subject: [PATCH v3 3/6] ci: test supported docker container operations Date: Thu, 9 Dec 2021 01:02:35 +0800 Message-Id: <20211208170238.142017-4-vicamo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208170238.142017-1-vicamo@gmail.com> References: <20211208170238.142017-1-vicamo@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: You-Sheng Yang --- .github/workflows/ci.yaml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d37cdbf..6e9033d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -116,6 +116,8 @@ jobs: strategy: matrix: db: [postgres, mysql] + env: + COMPOSE_FILE: ${{ matrix.db == 'mysql' && 'docker-compose.yml' || 'docker-compose-pg.yml' }} steps: - name: Checkout source code uses: actions/checkout@v2 @@ -125,11 +127,30 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.9 - - name: Bring up docker-compose service - env: - COMPOSE_FILE: ${{ matrix.db == 'mysql' && 'docker-compose.yml' || 'docker-compose-pg.yml' }} + - name: Build docker-compose service run: | docker-compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) + - name: Test createsuperuser/changepassword + run: | + docker-compose run -T --rm web \ + python manage.py createsuperuser \ + --username patchwork --no-input --email test@example.com + { echo patchwork; echo patchwork; } | \ + docker-compose run -T --rm web \ + python manage.py changepassword patchwork + - name: Test dbbackup/dbrestore + run: | + docker-compose run -T --rm web python manage.py dbbackup + echo y | docker-compose run -T --rm web python manage.py dbrestore + - name: Modify database user permissions (mysql) + if: ${{ matrix.db == 'mysql' }} + run: | + docker-compose exec -T -- db \ + sh -c "exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* to '\${MYSQL_USER}'@'%'; FLUSH PRIVILEGES;\"" + - name: Run unittest + run: docker-compose run -T --rm web tox + - name: Test normal startup + run: | docker-compose up --detach for count in $(seq 50); do \ @@ -140,12 +161,6 @@ jobs: done echo - docker-compose exec -T web \ - python manage.py createsuperuser \ - --username patchwork --no-input --email test@example.com - { echo patchwork; echo patchwork; } | \ - docker-compose exec -T web \ - python manage.py changepassword patchwork docker-compose ps - name: Test client access (git-pw) run: | From patchwork Wed Dec 8 17:02:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1565370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YSsWnBAo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8Nlp3rLMz9ssD for ; Thu, 9 Dec 2021 04:03:18 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J8Nlp2RjFz3bW6 for ; Thu, 9 Dec 2021 04:03:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YSsWnBAo; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1033; helo=mail-pj1-x1033.google.com; envelope-from=vicamo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YSsWnBAo; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J8NlQ5hHPz3bXP for ; Thu, 9 Dec 2021 04:02:58 +1100 (AEDT) Received: by mail-pj1-x1033.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so4768183pjc.4 for ; Wed, 08 Dec 2021 09:02:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=poAXdVduPqdbZmZN5f7gmkNTGD9AktJCMiPTg0AktyA=; b=YSsWnBAohBFsi82yTfRIODFGoYDqiE/6BKy+UzEzAYUjjHpMUm34TKceVuRHkFuL3Y VDcr8LG5Jv1QSiu5XglyuuNo13t8XdzF8FazNffd2DRoI9+iV7d1PyQOlDWYxanerl5N 50HaVnnql1NXdX8HE1xuuf1xbUa/2IUHeB8fzdA2rJDQWvlK9zrps2Aavwjr+cWALm1O xfMDvawhVROJNRVwmVs1NOPLYhgaoB+lYHPhXICGEISVpyE6lcPve1AdokT5ju/f0eK1 Q1sbSbrK3ngUxcc4//9+vrpqUjtyybU1iKwyDyAYIU0rwraApClT4yM9SlnpPc4P6xcz 0frg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=poAXdVduPqdbZmZN5f7gmkNTGD9AktJCMiPTg0AktyA=; b=RF9kgHbKjFK03q1QT1JiWWh7qxbrWOGDD0ixw6z2ex8A/US0QhnVtH2YeWZxZK5SHH 8JhhUSUnF6KofvUv3F28jX7ukmQOoSH4NDh9WkUzW+jxn22OZWO9CayvOBhFA3SpFsdJ bRxObnOV6pI2abBZhtIS8OFGnkZAfpwNHf6W/oylAd3/yg/C/IRx66Kzn6h0PCI+qaXq HKMhtU4KOUlkWwGP1jJ467PxwwEIRqtxm7eSL9WYVeZ26GB2gHwaBq45iuwJLHPnmu+g jLA0olfrypvLEKMhuZRA+O/l8Lah3tEOu0AczPZ3tr9CWC27HTfNwxDBm+8Cpcd/A6XR zFOg== X-Gm-Message-State: AOAM530l/dHeOOhg2X7AOhlQXXLvCbvLYu3d/3oMafN4r7nPiRFlpS9J fDylZvGCLdxqUYRzrBPek/RZP9J0DNg= X-Google-Smtp-Source: ABdhPJzETw6hMK5lGe9mixhk0Fb+UkVWeKRIuQcAVv+Km0GQyM6N6/lYyugPVOOrJ6Eij8M5ZcyXCQ== X-Received: by 2002:a17:90a:7086:: with SMTP id g6mr8642141pjk.34.1638982974442; Wed, 08 Dec 2021 09:02:54 -0800 (PST) Received: from localhost (218-173-141-247.dynamic-ip.hinet.net. [218.173.141.247]) by smtp.gmail.com with ESMTPSA id c5sm3125363pgi.89.2021.12.08.09.02.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 09:02:54 -0800 (PST) From: You-Sheng Yang To: patchwork@lists.ozlabs.org Subject: [PATCH v3 4/6] docker: drop database maintenance stuff Date: Thu, 9 Dec 2021 01:02:36 +0800 Message-Id: <20211208170238.142017-5-vicamo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208170238.142017-1-vicamo@gmail.com> References: <20211208170238.142017-1-vicamo@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Trying to re-create database inside a client docker could be risky and error prone. 1. The previous handling process may fail service startup when an empty database was created. `test_database()` will always succeed as it tests only the existence of the database, not any table inside. Without migrations being called on such empty database, patchwork cannot work normally. 2. Checking the existence of a patchwork specific table is also invalid under the empty database scenario, because migrations might still remain to be done. As a result, we shall test if the database exist and do migrations always, so this change removes database maintenance functions. Signed-off-by: You-Sheng Yang --- docker-compose-pg.yml | 4 +- docker-compose.yml | 3 +- docs/development/installation.rst | 10 ++- ...se-maintenance-stuff-e3317975c1c53ade.yaml | 5 ++ tools/docker/entrypoint.sh | 67 +++---------------- 5 files changed, 26 insertions(+), 63 deletions(-) create mode 100644 releasenotes/notes/docker-drop-database-maintenance-stuff-e3317975c1c53ade.yaml diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml index c99b25c..9129f32 100644 --- a/docker-compose-pg.yml +++ b/docker-compose-pg.yml @@ -5,6 +5,8 @@ services: volumes: - ./tools/docker/db/postdata:/var/lib/postgresql/data environment: + - POSTGRES_DB=patchwork + - POSTGRES_USER=patchwork - POSTGRES_PASSWORD=password web: @@ -27,5 +29,5 @@ services: - DATABASE_HOST=db - DATABASE_PORT=5432 - DATABASE_NAME=patchwork - - DATABASE_USER=postgres + - DATABASE_USER=patchwork - DATABASE_PASSWORD=password diff --git a/docker-compose.yml b/docker-compose.yml index b91b7ef..d824436 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: - ./tools/docker/db/data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=root + - MYSQL_DATABASE=patchwork - MYSQL_USER=patchwork - MYSQL_PASSWORD=password @@ -28,6 +29,6 @@ services: # skip DATABASE_TYPE explicitly as mysql should be the default type. - DATABASE_HOST=db - DATABASE_PORT=3306 + - DATABASE_NAME=patchwork - DATABASE_USER=patchwork - DATABASE_PASSWORD=password - - MYSQL_ROOT_PASSWORD=root diff --git a/docs/development/installation.rst b/docs/development/installation.rst index c5c0269..877c2f6 100644 --- a/docs/development/installation.rst +++ b/docs/development/installation.rst @@ -91,6 +91,10 @@ To run unit tests against the system Python packages, run: .. code-block:: shell + # For MySQL database: + $ docker-compose exec -T -- db sh -c \ + "exec mysql -uroot -p\"\${MYSQL_ROOT_PASSWORD}\" -e \"GRANT ALL ON \\\`test\\_\${MYSQL_DATABASE}%\\\`.* to '\${MYSQL_USER}'@'%'; FLUSH PRIVILEGES;\"" + $ docker-compose run --rm web python manage.py test To run unit tests for multiple versions using ``tox``, run: @@ -99,12 +103,12 @@ To run unit tests for multiple versions using ``tox``, run: $ docker-compose run --rm web tox -To reset the database before any of these commands, add ``--reset`` to the -command line after ``web`` and before any other arguments: +To reset the database, stop the db container and purge the database files: .. code-block:: shell - $ docker-compose run --rm web --reset tox + $ docker-compose stop db + $ sudo rm -rf tools/docker/db Any local edits to the project files made locally are immediately visible to the Docker container, and so should be picked up by the Django auto-reloader. diff --git a/releasenotes/notes/docker-drop-database-maintenance-stuff-e3317975c1c53ade.yaml b/releasenotes/notes/docker-drop-database-maintenance-stuff-e3317975c1c53ade.yaml new file mode 100644 index 0000000..9cf0fcb --- /dev/null +++ b/releasenotes/notes/docker-drop-database-maintenance-stuff-e3317975c1c53ade.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + No longer perform database recreation inside development container startup. + Users should provide a ready-to-use database, empty or previously populated. diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index 7e0af5a..d1bad82 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -16,20 +16,11 @@ postgres) *) export DATABASE_TYPE=mysql mysql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} ${DATABASE_PORT:+--port=${DATABASE_PORT}} "--user=${DATABASE_USER}" "--password=${DATABASE_PASSWORD}" ) - mysql_root_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} ${DATABASE_PORT:+--port=${DATABASE_PORT}} "--user=root" "--password=${MYSQL_ROOT_PASSWORD:-}" ) ;; esac # functions -test_db_connection() { - if [ ${DATABASE_TYPE} = "postgres" ]; then - echo ';' | psql "${psql_args[@]}" 2> /dev/null > /dev/null - else - mysqladmin "${mysql_root_args[@]}" ping > /dev/null 2> /dev/null - fi -} - test_database() { if [ ${DATABASE_TYPE} = "postgres" ]; then echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null @@ -38,37 +29,6 @@ test_database() { fi } -reset_data_mysql() { - mysql "${mysql_root_args[@]}" << EOF -DROP DATABASE IF EXISTS ${DATABASE_NAME}; -CREATE DATABASE ${DATABASE_NAME} CHARACTER SET utf8; -GRANT ALL ON ${DATABASE_NAME}.* TO '${DATABASE_USER}' IDENTIFIED BY '${DATABASE_PASSWORD}'; -GRANT ALL ON \`test\\_${DATABASE_NAME}%\`.* to '${DATABASE_USER}'@'%'; -FLUSH PRIVILEGES; -EOF -} - -reset_data_postgres() { - psql "${psql_args[@]}" < /dev/null - python manage.py loaddata default_tags #> /dev/null - python manage.py loaddata default_states #> /dev/null - python manage.py loaddata default_projects #> /dev/null -} - # the script begins! # check if patchwork is mounted. Checking if we exist is a @@ -103,20 +63,20 @@ done set -e # check if db is connected -if ! test_db_connection; then +if ! test_database; then echo "The database seems not to be connected, or the ${DATABASE_USER} user is broken" echo "MySQL/Postgres may still be starting. Waiting 5 seconds." sleep 5 - if ! test_db_connection; then + if ! test_database; then echo "Still cannot connect to database." echo "Maybe you are starting the db for the first time. Waiting up to 60 seconds." for i in {0..9}; do sleep 5 - if test_db_connection; then + if test_database; then break fi done - if ! test_db_connection; then + if ! test_database; then echo "Still cannot connect to database. Giving up." echo "Are you using docker-compose? If not, have you set up the link correctly?" exit 1 @@ -124,19 +84,10 @@ if ! test_db_connection; then fi fi -# rebuild db -# do this on --reset or if the db doesn't exist -if [[ "$1" == "--reset" ]]; then - shift - reset_data -elif ! test_database; then - reset_data -fi - -if [ $# -eq 0 ]; then - # we probably ran with --reset and nothing else - # just exit cleanly - exit 0 -fi +# load initial data +python manage.py migrate #> /dev/null +python manage.py loaddata default_tags #> /dev/null +python manage.py loaddata default_states #> /dev/null +python manage.py loaddata default_projects #> /dev/null exec "$@" From patchwork Wed Dec 8 17:02:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1565371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QvgKsIw4; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8Nlx4pYlz9ssD for ; Thu, 9 Dec 2021 04:03:25 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J8Nlx3hJ1z3c7q for ; Thu, 9 Dec 2021 04:03:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QvgKsIw4; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::636; helo=mail-pl1-x636.google.com; envelope-from=vicamo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QvgKsIw4; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J8NlT4Rmxz3c4X for ; Thu, 9 Dec 2021 04:03:01 +1100 (AEDT) Received: by mail-pl1-x636.google.com with SMTP id z6so1927183plk.6 for ; Wed, 08 Dec 2021 09:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uA0O6n2gldesCSrq1T2WbjY5FKRvBjr4tMJmcX5/V7M=; b=QvgKsIw4+v63IujZAl+GB+nHVHrACZFMGz7xlZxC2CzIQP+HqzjGizc4Vfpe51KfU2 1JQwV3yRHE3t/1PZgZ4cf7e8kVd3MMLuklVEkSRaJbtaFAepeP6SwuWb4L4DGnpadbje q5YK3LVGDhumPyd+xqQV4GedXEWF1BMfiv6ZFThi843tkvp97IUhGyWfEqhFmBu2hWQb MjPvffiv5yv5OaVP5DMUKQ/Y9hsgQ2bOtG1j+e/HekX/y4mV84MS/bLvNxFOc653D7ES Ru09/USfUlgsb+891/0NXlDSlXsj5C+wdv3Nshl/fRCiyr4emVgIUCNwaPKyVsvHHP2E PyQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uA0O6n2gldesCSrq1T2WbjY5FKRvBjr4tMJmcX5/V7M=; b=SrqMpyepKccVOxRFf8qQi8xqICsXHGyjn9yyrYp1h7KvyuqjSeqq/MOYV7NvoIZCZb BNVnhSRKY538nAvwiCZTz2QUtzIpq19++e6XWmlCre4MXnZAMwKQZY1ADMNqM0eZryAT NUZpHr2HJtxgIwXFF3Ksar5e3Wn08SmYaW/mQoo9SyCXoPB+ra7PXJsWGM8T3N641jYE x93CBMCOOaBVRXKw1zoyDtxe4Q6g8QqJL0g695vONAjHwCNKtykinkuNcR5sSLSuWWc0 nlkzAaDeBS5KUiWreeagksvmzF2PPKu19DZMJMg3ltt4KHDPyJQL24pFppmJOZuIP28y FhDQ== X-Gm-Message-State: AOAM531b6wwJ3BFr+Tm81YeYmrxzMqd+sNTr41L9R63ylvvxRTi0aGaD 6sRqSa79f0b7lCly+j7oa4FRV6JKQWg= X-Google-Smtp-Source: ABdhPJw7fW6o14U60Hmwyy4xtcmPnfB53znYV1wJ0jM/byfUpVJtUMdZcqlht5bzXIJ7aylo8yY7Fw== X-Received: by 2002:a17:902:bd88:b0:143:d318:76e6 with SMTP id q8-20020a170902bd8800b00143d31876e6mr61198094pls.66.1638982978936; Wed, 08 Dec 2021 09:02:58 -0800 (PST) Received: from localhost (218-173-141-247.dynamic-ip.hinet.net. [218.173.141.247]) by smtp.gmail.com with ESMTPSA id t8sm3274176pgk.66.2021.12.08.09.02.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 09:02:58 -0800 (PST) From: You-Sheng Yang To: patchwork@lists.ozlabs.org Subject: [PATCH v3 5/6] ci: add tests for sqlite3 Date: Thu, 9 Dec 2021 01:02:37 +0800 Message-Id: <20211208170238.142017-6-vicamo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208170238.142017-1-vicamo@gmail.com> References: <20211208170238.142017-1-vicamo@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: You-Sheng Yang --- .github/workflows/ci.yaml | 8 ++++---- docker-compose-sqlite3.yml | 19 +++++++++++++++++++ tools/docker/Dockerfile | 1 + tools/docker/entrypoint.sh | 19 +++++++++++++------ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 docker-compose-sqlite3.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6e9033d..0818aca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,11 +24,11 @@ jobs: strategy: matrix: python: [3.6, 3.7, 3.8, 3.9] - db: [postgres, mysql] + db: [postgres, mysql, sqlite3] env: DATABASE_TYPE: "${{ matrix.db }}" DATABASE_HOST: "127.0.0.1" - DATABASE_NAME: patchwork + DATABASE_NAME: ${{ matrix.db != 'sqlite3' && 'patchwork' || '/dev/shm/patchwork.test.db.sqlite3' }} DATABASE_USER: patchwork DATABASE_PASSWORD: password MYSQL_ROOT_PASSWORD: root @@ -115,9 +115,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - db: [postgres, mysql] + db: [postgres, mysql, sqlite3] env: - COMPOSE_FILE: ${{ matrix.db == 'mysql' && 'docker-compose.yml' || 'docker-compose-pg.yml' }} + COMPOSE_FILE: ${{ matrix.db == 'mysql' && 'docker-compose.yml' || (matrix.db == 'postgres' && 'docker-compose-pg.yml') || 'docker-compose-sqlite3.yml' }} steps: - name: Checkout source code uses: actions/checkout@v2 diff --git a/docker-compose-sqlite3.yml b/docker-compose-sqlite3.yml new file mode 100644 index 0000000..d4c6659 --- /dev/null +++ b/docker-compose-sqlite3.yml @@ -0,0 +1,19 @@ +version: "3" +services: + web: + build: + context: . + dockerfile: ./tools/docker/Dockerfile + args: + - UID + - GID + command: python3 manage.py runserver 0.0.0.0:8000 + volumes: + - .:/home/patchwork/patchwork/ + ports: + - "8000:8000" + environment: + - UID + - GID + - DATABASE_TYPE=sqlite3 + - DATABASE_NAME=/home/patchwork/patchwork/tools/docker/db/db.sqlite3 diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 71167e0..d9d0905 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -38,6 +38,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ mysql-client \ postgresql-client \ + sqlite3 \ tzdata \ zlib1g-dev \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh index d1bad82..96a59ed 100755 --- a/tools/docker/entrypoint.sh +++ b/tools/docker/entrypoint.sh @@ -3,18 +3,22 @@ set -euo pipefail export DATABASE_HOST=${DATABASE_HOST:-} export DATABASE_PORT=${DATABASE_PORT:-} -export DATABASE_NAME=${DATABASE_NAME:-patchwork} export DATABASE_USER=${DATABASE_USER:-patchwork} export DATABASE_PASSWORD=${DATABASE_PASSWORD:-password} case "${DATABASE_TYPE:-}" in postgres) + export DATABASE_NAME=${DATABASE_NAME:-patchwork} export PGPORT=${DATABASE_PORT} export PGPASSWORD=${DATABASE_PASSWORD} psql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} "--username=${DATABASE_USER}" ) ;; +sqlite3) + export DATABASE_NAME=${DATABASE_NAME:-} + ;; *) export DATABASE_TYPE=mysql + export DATABASE_NAME=${DATABASE_NAME:-patchwork} mysql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} ${DATABASE_PORT:+--port=${DATABASE_PORT}} "--user=${DATABASE_USER}" "--password=${DATABASE_PASSWORD}" ) ;; esac @@ -22,11 +26,14 @@ esac # functions test_database() { - if [ ${DATABASE_TYPE} = "postgres" ]; then - echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null - else - echo ';' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null - fi + case "${DATABASE_TYPE}" in + "postgres") + echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null ;; + "mysql") + echo ';' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null ;; + "sqlite3") + echo ';' | sqlite3 "${DATABASE_NAME}" > /dev/null 2> /dev/null ;; + esac } # the script begins! From patchwork Wed Dec 8 17:02:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1565374 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=eYYP0IvW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8Nm60VLzz9ssD for ; Thu, 9 Dec 2021 04:03:34 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J8Nm56S27z3c8J for ; Thu, 9 Dec 2021 04:03:33 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=eYYP0IvW; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::102c; helo=mail-pj1-x102c.google.com; envelope-from=vicamo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=eYYP0IvW; dkim-atps=neutral Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J8NlW3tFKz3c5b for ; Thu, 9 Dec 2021 04:03:03 +1100 (AEDT) Received: by mail-pj1-x102c.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so4400255pjj.0 for ; Wed, 08 Dec 2021 09:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BlRCTXf/1KfpbGy/tMXg+NCcj9o4EC8u2urcnl0OWBQ=; b=eYYP0IvW3kf3xUdYKgkfa/YbFg3Pic7KNxZoo1/MlhKes57CJ5OGKjrT7Odl4zgtYt SvCmH4q2W/IL8I4RjjuxLsrRhTMwZp7yJY2kxFIdzx4eNVlUJWEa1EZdxeE/ffjc0Fp/ 5jzAnl+MPwFcTpfmT2UFhFRJ9GsT9A7j7VF3AiNjOA7ru8pNp7tWMmeBeSSIzEuBKugp etwSBCo+WBiGXOAwx0dAgKBchI3CMZTbsciX4u+ALAQ0LIUHgzR/OiLdTnvyw/naBrar EgHx5GMeh/9iuW4Cy+DcbXlq8+Rqz0iiHTOC1J2lYQ0nrkmoPdkCMZVKR28suDghcX3I 9bbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BlRCTXf/1KfpbGy/tMXg+NCcj9o4EC8u2urcnl0OWBQ=; b=CyEaugp8CxaXhW+HqmeVYvTiORn0DEOlav0ECeDxeFwpMRq+FaAK40zqL8dqxvOHdG iI4ch3q5fStbSCZUK8prWsqIcOOdp/0Jz5geMM9n0wBABsoAy+tyq6m+SYzGJNdqxgOQ IcDmO6kJ3bAfPiPyCxaJYHxOGv/ZA/MYCcshYj4/cZy34upbwhxRNqp/eeJYafSE+uY0 lN7U6Z/A0v8G9qZ7GAwBVwSK1tXRPNqS5+ccDIZDgb44Fr9icoC15cofBNqpWtawv6/t X9a0mAb6MMx3mHfoS4zRy3Rf3DI8JTkmnR3dFPtUv7CByoQVlG+vJSW+mT1WCTR+llhm kMWg== X-Gm-Message-State: AOAM531zj2Z7MsQx4vAhxrLauSHVYvhg659+ibQf5qZHP1NjwGHs5rUC i5cDzAFeoTB+IMRvFxA8cXXzh5tQ7ZQ= X-Google-Smtp-Source: ABdhPJxwRCpJgS4rL7LiNZwB5NWG/u+6ylxRcEq827lASztTI8Avnqe4OlOpju6BrX1L66lJzdnvgQ== X-Received: by 2002:a17:902:f551:b0:143:759c:6a30 with SMTP id h17-20020a170902f55100b00143759c6a30mr61579046plf.0.1638982981011; Wed, 08 Dec 2021 09:03:01 -0800 (PST) Received: from localhost (218-173-141-247.dynamic-ip.hinet.net. [218.173.141.247]) by smtp.gmail.com with ESMTPSA id on5sm3674746pjb.23.2021.12.08.09.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 09:03:00 -0800 (PST) From: You-Sheng Yang To: patchwork@lists.ozlabs.org Subject: [PATCH v3 6/6] ci: randomize database credentials a bit Date: Thu, 9 Dec 2021 01:02:38 +0800 Message-Id: <20211208170238.142017-7-vicamo@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211208170238.142017-1-vicamo@gmail.com> References: <20211208170238.142017-1-vicamo@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: You-Sheng Yang --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0818aca..19a1098 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,10 +28,10 @@ jobs: env: DATABASE_TYPE: "${{ matrix.db }}" DATABASE_HOST: "127.0.0.1" - DATABASE_NAME: ${{ matrix.db != 'sqlite3' && 'patchwork' || '/dev/shm/patchwork.test.db.sqlite3' }} - DATABASE_USER: patchwork - DATABASE_PASSWORD: password - MYSQL_ROOT_PASSWORD: root + DATABASE_NAME: ${{ matrix.db != 'sqlite3' && format('patchwork-db-{0}', github.run_id) || '/dev/shm/patchwork.test.db.sqlite3' }} + DATABASE_USER: patchwork-user-${{ github.run_id }} + DATABASE_PASSWORD: password-${{ github.run_id }} + MYSQL_ROOT_PASSWORD: root-${{ github.run_id }} services: postgres: image: postgres:latest