potiuk commented on a change in pull request #4932: [AIRFLOW-3611] Simplified 
development workflow
URL: https://github.com/apache/airflow/pull/4932#discussion_r266651267
 
 

 ##########
 File path: scripts/ci/in_container/run_ci.sh
 ##########
 @@ -0,0 +1,127 @@
+#!/usr/bin/env bash
+
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+set -euo pipefail
+
+MY_DIR=$(cd "$(dirname "$0")"; pwd)
+
+if [[ ${AIRFLOW_CI_VERBOSE:="false"} == "true" ]]; then
+    set -x
+fi
+
+AIRFLOW_ROOT="${MY_DIR}/../.."
+
+PYTHON_VERSION=${PYTHON_VERSION:=3.6}
+ENV=${ENV:=docker}
+BACKEND=${BACKEND:=sqlite}
+KUBERNETES_VERSION=${KUBERNETES_VERSION:=}
+
+RUN_TESTS=${RUN_TESTS:="true"}
+
+ARGS=$@
+
+if [[ -z "${AIRFLOW_HOME:=}" ]]; then
+    echo
+    echo AIRFLOW_HOME not set !!!!
+    echo
+    exit 1
+fi
+
+# Fix file permissions
+if [[ -d $HOME/.minikube ]]; then
+    sudo chown -R airflow.airflow $HOME/.kube $HOME/.minikube
+fi
+
+if [[ ${PYTHON_VERSION} == 3* ]]; then
+    PIP=pip3
+else
+    PIP=pip2
+fi
+
+if [[ "${ENV}" == "docker" ]]; then
+    ${MY_DIR}/setup_env.sh
+    ${MY_DIR}/setup_kdc.sh
+fi
+
+if [[ "${BACKEND}" == "mysql" ]]; then
+    export AIRFLOW__CORE__SQL_ALCHEMY_CONN=mysql://root@mysql/airflow
+    export AIRFLOW__CELERY__RESULT_BACKEND=db+mysql://root@mysql/airflow
+    ${MY_DIR}/setup_mysql.sh >/dev/null
 
 Review comment:
   I think this way is quite good. As we need to pass only one variable BACKEND 
through bash/docker-compose/docker chain. 
   
   We could potentially set the database variables outside -  the easiest way I 
know is to have extra docker-compose.yaml (for example 
docker-compose-postgres.yaml, docker-compose-mysql.yaml and add "-f 
docker-compose-${BACKEND}.yaml". But I find clunky than the "if" in bash 
script. Especially that we use AIRFLOW_HOME for sqlite and it is defined in the 
Dockerfile, so it's better to set it only when we are in the container. 
   
   Also this is abut more than database - we also choose executor (in case of 
SQLite) or CELERY_BACKEND.
   
   I think this is quite good place for setting the variables.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to