You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/04/21 18:15:44 UTC

[GitHub] [airflow] potiuk opened a new pull request #8497: Add support for GitHub registry cache

potiuk opened a new pull request #8497:
URL: https://github.com/apache/airflow/pull/8497


   NOTE TO REVIEWERS! This one is based on top of #8496 so only review the last commit.
   
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412394192



##########
File path: scripts/ci/_utils.sh
##########
@@ -136,6 +136,14 @@ function initialize_common_environment {
             "--env" "PYTHONDONTWRITEBYTECODE" \
         )
     fi
+
+    if [[ ${CI:=} == "true" ]]; then

Review comment:
       For those curious ones. This is a recommended way of passing codecov variables to docker run command: https://docs.codecov.io/docs/testing-with-docker




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412393409



##########
File path: .travis.yml
##########
@@ -21,14 +21,13 @@ language: python
 os: linux
 env:
   global:
-    - BUILD_ID=${TRAVIS_BUILD_ID}
     - MOUNT_LOCAL_SOURCES="false"
     - MOUNT_HOST_AIRFLOW_VOLUME="true"
     - FORCE_ANSWER_TO_QUESTIONS="yes"
     - SKIP_CHECK_REMOTE_IMAGE="true"
     - DB_RESET="true"
     - VERBOSE="true"
-    - CI="true"

Review comment:
       NOTE ! CI is set to "true" by both Travis and Github. We do not need to set it separately.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412739166



##########
File path: scripts/ci/_utils.sh
##########
@@ -919,86 +933,82 @@ function match_files_regexp() {
     export FILE_MATCHES
 }
 
-function build_ci_image_on_ci() {
-    if [[ "${CI:=}" != "true" ]]; then
-        print_info
-        print_info "Cleaning up docker installation!!!!!!"
-        print_info
-        "${AIRFLOW_SOURCES}/confirm" "Cleaning docker data and rebuilding"
+function get_ci_environment() {
+    export CI_EVENT_TYPE="manual"
+    export CI_TARGET_REPO="apache/airflow"
+    export CI_TARGET_BRANCH="master"
+    export CI_BUILD_ID="default-build-id"
+    export CI_JOB_ID="default-job-id"
+    if [[ ${CI:=} != "true" ]]; then
+        echo
+        echo "This is not a CI environment!. Staying with the defaults"
+        echo
+    else
+        if [[ ${TRAVIS:=} == "true" ]]; then
+            if [[ "${TRAVIS_PULL_REQUEST:=}" == "true" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+            elif [[ "${TRAVIS_EVENT_TYPE:=}" == "cron" ]]; then
+                export CI_EVENT_TYPE="schedule"
+            else
+                export CI_EVENT_TYPE="push"
+            fi
+            export CI_TARGET_BRANCH="${TRAVIS_BRANCH}"
+            export CI_TARGET_REPO="${TRAVIS_REPO_SLUG}"
+            export CI_BUILD_ID="${TRAVIS_BUILD_ID}"
+            export CI_JOB_ID="${TRAVIS_JOB_ID}"
+        elif [[ ${GITHUB_ACTIONS:=} == "true" ]]; then
+            if [[ ${GITHUB_EVENT_NAME:=} == "pull_request" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+                export CI_TARGET_REPO="${GITHUB_REPOSITORY}"
+                export CI_TARGET_BRANCH="${GITHUB_BASE_REF}"
+            elif [[ ${GITHUB_EVENT_TYPE:=} == "schedule" ]]; then
+                export CI_EVENT_TYPE="schedule"
+                export CI_TARGET_REPO="${GITHUB_REPOSITORY}"
+                export CI_TARGET_BRANCH="${SOURCE_BRANCH}"
+            else
+                export CI_EVENT_TYPE="push"
+                export CI_TARGET_REPO="${GITHUB_REPOSITORY}"
+                export CI_TARGET_BRANCH="${SOURCE_BRANCH}"

Review comment:
       Can we move those variables before elif? It seems we are replicating those lines.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412768804



##########
File path: scripts/ci/_utils.sh
##########
@@ -1071,31 +1127,15 @@ Docker pulling ${PYTHON_BASE_IMAGE}.
             verbose_docker pull "${PYTHON_BASE_IMAGE}" | tee -a "${OUTPUT_LOG}"
             echo
         fi
-        local PULL_IMAGE=${FORCE_PULL_IMAGES}
-        local IMAGE_HASH
-        IMAGE_HASH=$(docker images -q "${AIRFLOW_CI_IMAGE}" 2> /dev/null)
-        if [[ "${IMAGE_HASH}" == "" ]]; then
-            PULL_IMAGE="true"
-        fi
-        if [[ "${PULL_IMAGE}" == "true" ]]; then
-            echo
-            echo "Pulling the image ${AIRFLOW_CI_IMAGE}"
-            echo
-            if [[ -n ${DETECTED_TERMINAL:=""} ]]; then
-                echo -n "
-Docker pulling ${IMAGE}.
-" > "${DETECTED_TERMINAL}"
-            fi
-            verbose_docker pull "${AIRFLOW_CI_IMAGE}" | tee -a "${OUTPUT_LOG}" || true
-            echo
-        fi
+        # C production image

Review comment:
       Right :)




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412767654



##########
File path: scripts/ci/_utils.sh
##########
@@ -919,86 +933,82 @@ function match_files_regexp() {
     export FILE_MATCHES
 }
 
-function build_ci_image_on_ci() {
-    if [[ "${CI:=}" != "true" ]]; then
-        print_info
-        print_info "Cleaning up docker installation!!!!!!"
-        print_info
-        "${AIRFLOW_SOURCES}/confirm" "Cleaning docker data and rebuilding"
+function get_ci_environment() {
+    export CI_EVENT_TYPE="manual"
+    export CI_TARGET_REPO="apache/airflow"
+    export CI_TARGET_BRANCH="master"
+    export CI_BUILD_ID="default-build-id"
+    export CI_JOB_ID="default-job-id"
+    if [[ ${CI:=} != "true" ]]; then
+        echo
+        echo "This is not a CI environment!. Staying with the defaults"
+        echo
+    else
+        if [[ ${TRAVIS:=} == "true" ]]; then
+            if [[ "${TRAVIS_PULL_REQUEST:=}" == "true" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+            elif [[ "${TRAVIS_EVENT_TYPE:=}" == "cron" ]]; then
+                export CI_EVENT_TYPE="schedule"
+            else
+                export CI_EVENT_TYPE="push"
+            fi
+            export CI_TARGET_BRANCH="${TRAVIS_BRANCH}"
+            export CI_TARGET_REPO="${TRAVIS_REPO_SLUG}"
+            export CI_BUILD_ID="${TRAVIS_BUILD_ID}"
+            export CI_JOB_ID="${TRAVIS_JOB_ID}"
+        elif [[ ${GITHUB_ACTIONS:=} == "true" ]]; then
+            if [[ ${GITHUB_EVENT_NAME:=} == "pull_request" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+                export CI_TARGET_REPO="${GITHUB_REPOSITORY}"
+                export CI_TARGET_BRANCH="${GITHUB_BASE_REF}"
+            elif [[ ${GITHUB_EVENT_TYPE:=} == "schedule" ]]; then
+                export CI_EVENT_TYPE="schedule"
+                export CI_TARGET_REPO="${GITHUB_REPOSITORY}"
+                export CI_TARGET_BRANCH="${SOURCE_BRANCH}"
+            else
+                export CI_EVENT_TYPE="push"
+                export CI_TARGET_REPO="${GITHUB_REPOSITORY}"
+                export CI_TARGET_BRANCH="${SOURCE_BRANCH}"

Review comment:
       Or even after :) indeed.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412740240



##########
File path: scripts/ci/_utils.sh
##########
@@ -1071,31 +1127,15 @@ Docker pulling ${PYTHON_BASE_IMAGE}.
             verbose_docker pull "${PYTHON_BASE_IMAGE}" | tee -a "${OUTPUT_LOG}"
             echo
         fi
-        local PULL_IMAGE=${FORCE_PULL_IMAGES}
-        local IMAGE_HASH
-        IMAGE_HASH=$(docker images -q "${AIRFLOW_CI_IMAGE}" 2> /dev/null)
-        if [[ "${IMAGE_HASH}" == "" ]]; then
-            PULL_IMAGE="true"
-        fi
-        if [[ "${PULL_IMAGE}" == "true" ]]; then
-            echo
-            echo "Pulling the image ${AIRFLOW_CI_IMAGE}"
-            echo
-            if [[ -n ${DETECTED_TERMINAL:=""} ]]; then
-                echo -n "
-Docker pulling ${IMAGE}.
-" > "${DETECTED_TERMINAL}"
-            fi
-            verbose_docker pull "${AIRFLOW_CI_IMAGE}" | tee -a "${OUTPUT_LOG}" || true
-            echo
-        fi
+        # C production image

Review comment:
       ```suggestion
           # production image
   ```
   ?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412954249



##########
File path: scripts/ci/_utils.sh
##########
@@ -919,86 +933,78 @@ function match_files_regexp() {
     export FILE_MATCHES
 }
 
-function build_ci_image_on_ci() {
-    if [[ "${CI:=}" != "true" ]]; then
-        print_info
-        print_info "Cleaning up docker installation!!!!!!"
-        print_info
-        "${AIRFLOW_SOURCES}/confirm" "Cleaning docker data and rebuilding"
+function get_ci_environment() {
+    export CI_EVENT_TYPE="manual"
+    export CI_TARGET_REPO="apache/airflow"
+    export CI_TARGET_BRANCH="master"
+    export CI_BUILD_ID="default-build-id"
+    export CI_JOB_ID="default-job-id"
+    if [[ ${CI:=} != "true" ]]; then
+        echo
+        echo "This is not a CI environment!. Staying with the defaults"
+        echo
+    else
+        if [[ ${TRAVIS:=} == "true" ]]; then
+            if [[ "${TRAVIS_PULL_REQUEST:=}" == "true" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+            elif [[ "${TRAVIS_EVENT_TYPE:=}" == "cron" ]]; then
+                export CI_EVENT_TYPE="schedule"
+            else
+                export CI_EVENT_TYPE="push"
+            fi
+            export CI_TARGET_BRANCH="${TRAVIS_BRANCH}"
+            export CI_TARGET_REPO="${TRAVIS_REPO_SLUG}"
+            export CI_BUILD_ID="${TRAVIS_BUILD_ID}"
+            export CI_JOB_ID="${TRAVIS_JOB_ID}"
+        elif [[ ${GITHUB_ACTIONS:=} == "true" ]]; then
+            if [[ ${GITHUB_EVENT_NAME:=} == "pull_request" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+            elif [[ ${GITHUB_EVENT_TYPE:=} == "schedule" ]]; then
+                export CI_EVENT_TYPE="schedule"
+            else
+                export CI_EVENT_TYPE="push"

Review comment:
       Yes. but I wanted to keep parallel with TRAVIS above -> this is just mapping from "CI specific" value to "common Ci value" so I prefer to keep the mapping.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #8497: Add support for GitHub registry cache

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #8497:
URL: https://github.com/apache/airflow/pull/8497#discussion_r412861270



##########
File path: scripts/ci/_utils.sh
##########
@@ -919,86 +933,78 @@ function match_files_regexp() {
     export FILE_MATCHES
 }
 
-function build_ci_image_on_ci() {
-    if [[ "${CI:=}" != "true" ]]; then
-        print_info
-        print_info "Cleaning up docker installation!!!!!!"
-        print_info
-        "${AIRFLOW_SOURCES}/confirm" "Cleaning docker data and rebuilding"
+function get_ci_environment() {
+    export CI_EVENT_TYPE="manual"
+    export CI_TARGET_REPO="apache/airflow"
+    export CI_TARGET_BRANCH="master"
+    export CI_BUILD_ID="default-build-id"
+    export CI_JOB_ID="default-job-id"
+    if [[ ${CI:=} != "true" ]]; then
+        echo
+        echo "This is not a CI environment!. Staying with the defaults"
+        echo
+    else
+        if [[ ${TRAVIS:=} == "true" ]]; then
+            if [[ "${TRAVIS_PULL_REQUEST:=}" == "true" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+            elif [[ "${TRAVIS_EVENT_TYPE:=}" == "cron" ]]; then
+                export CI_EVENT_TYPE="schedule"
+            else
+                export CI_EVENT_TYPE="push"
+            fi
+            export CI_TARGET_BRANCH="${TRAVIS_BRANCH}"
+            export CI_TARGET_REPO="${TRAVIS_REPO_SLUG}"
+            export CI_BUILD_ID="${TRAVIS_BUILD_ID}"
+            export CI_JOB_ID="${TRAVIS_JOB_ID}"
+        elif [[ ${GITHUB_ACTIONS:=} == "true" ]]; then
+            if [[ ${GITHUB_EVENT_NAME:=} == "pull_request" ]]; then
+                export CI_EVENT_TYPE="pull_request"
+            elif [[ ${GITHUB_EVENT_TYPE:=} == "schedule" ]]; then
+                export CI_EVENT_TYPE="schedule"
+            else
+                export CI_EVENT_TYPE="push"

Review comment:
       I am not bash master but can't we simplify it?
   ```suggestion
               if [[ ${GITHUB_EVENT_NAME:=} != "" ]]; then
                   export CI_EVENT_TYPE=${GITHUB_EVENT_NAME}
                else
                   export CI_EVENT_TYPE="push"
   ```
   or 
   ```bash
   export CI_EVENT_TYPE=${GITHUB_EVENT_NAME:="push"}
   ```




----------------------------------------------------------------
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:
users@infra.apache.org