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 2022/08/23 05:56:09 UTC

[GitHub] [airflow] bkossakowska opened a new pull request, #25895: Build assets

bkossakowska opened a new pull request, #25895:
URL: https://github.com/apache/airflow/pull/25895

   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   Cloud Build assets & system tests migration (AIP-47)
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+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 a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk merged pull request #25895: Cloud Build assets & system tests migration (AIP-47)

Posted by GitBox <gi...@apache.org>.
potiuk merged PR #25895:
URL: https://github.com/apache/airflow/pull/25895


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] josh-fell commented on pull request #25895: Cloud Build assets & system tests migration (AIP-47)

Posted by GitBox <gi...@apache.org>.
josh-fell commented on PR #25895:
URL: https://github.com/apache/airflow/pull/25895#issuecomment-1224213158

   Well, approval with addressing the unit test failures too.


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] josh-fell commented on a diff in pull request #25895: Cloud Build assets & system tests migration (AIP-47)

Posted by GitBox <gi...@apache.org>.
josh-fell commented on code in PR #25895:
URL: https://github.com/apache/airflow/pull/25895#discussion_r952751684


##########
tests/system/providers/google/cloud/cloud_build/example_cloud_build_trigger.py:
##########
@@ -0,0 +1,152 @@
+#
+# 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.
+
+"""
+Example Airflow DAG that displays interactions with Google Cloud Build.
+This DAG relies on the following OS environment variables:
+* PROJECT_ID - Google Cloud Project to use for the Cloud Function.
+"""
+
+import os
+from datetime import datetime
+from typing import Any, Dict
+
+from airflow import models
+from airflow.models.baseoperator import chain
+from airflow.providers.google.cloud.operators.cloud_build import (
+    CloudBuildCreateBuildTriggerOperator,
+    CloudBuildDeleteBuildTriggerOperator,
+    CloudBuildGetBuildTriggerOperator,
+    CloudBuildListBuildTriggersOperator,
+    CloudBuildRunBuildTriggerOperator,
+    CloudBuildUpdateBuildTriggerOperator,
+)
+
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT")
+
+DAG_ID = "example_gcp_cloud_build_trigger"
+
+GCP_SOURCE_REPOSITORY_NAME = "test-cloud-build-repository"
+
+# [START howto_operator_gcp_create_build_trigger_body]
+create_build_trigger_body = {
+    "name": "test-cloud-build-trigger",
+    "trigger_template": {
+        "project_id": PROJECT_ID,
+        "repo_name": GCP_SOURCE_REPOSITORY_NAME,
+        "branch_name": "main",
+    },
+    "filename": "example_cloud_build.yaml",
+}
+# [END howto_operator_gcp_create_build_trigger_body]
+
+# [START howto_operator_gcp_update_build_trigger_body]
+update_build_trigger_body = {
+    "name": "test-cloud-build-trigger",
+    "trigger_template": {
+        "project_id": PROJECT_ID,
+        "repo_name": GCP_SOURCE_REPOSITORY_NAME,
+        "branch_name": "master",
+    },
+    "filename": "example_cloud_build.yaml",
+}
+# [END START howto_operator_gcp_update_build_trigger_body]
+
+# [START howto_operator_create_build_from_repo_body]
+create_build_from_repo_body: Dict[str, Any] = {
+    "source": {"repo_source": {"repo_name": GCP_SOURCE_REPOSITORY_NAME, "branch_name": "master"}},
+    "steps": [{"name": "ubuntu", "args": ['echo', 'Hello world']}],
+}
+# [END howto_operator_create_build_from_repo_body]
+
+
+with models.DAG(
+    DAG_ID,
+    schedule_interval='@once',

Review Comment:
   ```suggestion
       schedule='@once',
   ```
   Same here. See #25410 and #25648.



##########
tests/system/providers/google/cloud/cloud_build/example_cloud_build.py:
##########
@@ -42,88 +42,65 @@
 from airflow.providers.google.cloud.operators.cloud_build import (
     CloudBuildCancelBuildOperator,
     CloudBuildCreateBuildOperator,
-    CloudBuildCreateBuildTriggerOperator,
-    CloudBuildDeleteBuildTriggerOperator,
     CloudBuildGetBuildOperator,
-    CloudBuildGetBuildTriggerOperator,
     CloudBuildListBuildsOperator,
-    CloudBuildListBuildTriggersOperator,
     CloudBuildRetryBuildOperator,
-    CloudBuildRunBuildTriggerOperator,
-    CloudBuildUpdateBuildTriggerOperator,
 )
+from airflow.providers.google.cloud.operators.gcs import GCSCreateBucketOperator, GCSDeleteBucketOperator
+from airflow.providers.google.cloud.transfers.local_to_gcs import LocalFilesystemToGCSOperator
+from airflow.utils.trigger_rule import TriggerRule
 
-START_DATE = datetime(2021, 1, 1)
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT")
 
-GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "aitflow-test-project")
+DAG_ID = "example_gcp_cloud_build"
 
-GCP_SOURCE_ARCHIVE_URL = os.environ.get("GCP_CLOUD_BUILD_ARCHIVE_URL", "gs://airflow-test-bucket/file.tar.gz")
-GCP_SOURCE_REPOSITORY_NAME = os.environ.get("GCP_CLOUD_BUILD_REPOSITORY_NAME", "airflow-test-repo")
+BUCKET_NAME_SRC = f"bucket-src-{DAG_ID}-{ENV_ID}"
+
+GCP_SOURCE_ARCHIVE_URL = os.environ.get("GCP_CLOUD_BUILD_ARCHIVE_URL", f"gs://{BUCKET_NAME_SRC}/file.tar.gz")
+GCP_SOURCE_REPOSITORY_NAME = "test-cloud-build-repository"
 
 GCP_SOURCE_ARCHIVE_URL_PARTS = urlparse(GCP_SOURCE_ARCHIVE_URL)
 GCP_SOURCE_BUCKET_NAME = GCP_SOURCE_ARCHIVE_URL_PARTS.netloc
 
 CURRENT_FOLDER = Path(__file__).parent
-
-# [START howto_operator_gcp_create_build_trigger_body]
-create_build_trigger_body = {
-    "name": "test-cloud-build-trigger",
-    "trigger_template": {
-        "project_id": GCP_PROJECT_ID,
-        "repo_name": GCP_SOURCE_REPOSITORY_NAME,
-        "branch_name": "master",
-    },
-    "filename": "cloudbuild.yaml",
-}
-# [END howto_operator_gcp_create_build_trigger_body]
-
-update_build_trigger_body = {
-    "name": "test-cloud-build-trigger",
-    "trigger_template": {
-        "project_id": GCP_PROJECT_ID,
-        "repo_name": GCP_SOURCE_REPOSITORY_NAME,
-        "branch_name": "dev",
-    },
-    "filename": "cloudbuild.yaml",
-}
+FILE_LOCAL_PATH = str(Path(CURRENT_FOLDER) / "resources" / "file.tar.gz")
 
 # [START howto_operator_gcp_create_build_from_storage_body]
 create_build_from_storage_body = {
     "source": {"storage_source": GCP_SOURCE_ARCHIVE_URL},
-    "steps": [
-        {
-            "name": "gcr.io/cloud-builders/docker",
-            "args": ["build", "-t", f"gcr.io/$PROJECT_ID/{GCP_SOURCE_BUCKET_NAME}", "."],
-        }
-    ],
-    "images": [f"gcr.io/$PROJECT_ID/{GCP_SOURCE_BUCKET_NAME}"],
+    "steps": [{"name": "ubuntu", "args": ['echo', 'Hello world']}],
 }
 # [END howto_operator_gcp_create_build_from_storage_body]
 
 # [START howto_operator_create_build_from_repo_body]
 create_build_from_repo_body: Dict[str, Any] = {
-    "source": {"repo_source": {"repo_name": GCP_SOURCE_REPOSITORY_NAME, "branch_name": "main"}},
-    "steps": [
-        {
-            "name": "gcr.io/cloud-builders/docker",
-            "args": ["build", "-t", "gcr.io/$PROJECT_ID/$REPO_NAME", "."],
-        }
-    ],
-    "images": ["gcr.io/$PROJECT_ID/$REPO_NAME"],
+    "source": {"repo_source": {"repo_name": GCP_SOURCE_REPOSITORY_NAME, "branch_name": "master"}},
+    "steps": [{"name": "ubuntu", "args": ['echo', 'Hello world']}],
 }
 # [END howto_operator_create_build_from_repo_body]
 
 
 with models.DAG(
-    "example_gcp_cloud_build",
-    start_date=START_DATE,
+    DAG_ID,
+    schedule_interval='@once',

Review Comment:
   ```suggestion
       schedule='@once',
   ```
   Updating to the new `schedule` param. See #25410 and #25648.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on pull request #25895: Cloud Build assets & system tests migration (AIP-47)

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25895:
URL: https://github.com/apache/airflow/pull/25895#issuecomment-1229053590

   Congrats @bkossakowska !


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org