Skip to content

Commit 4288dcb

Browse files
authored
airbyte-ci: burst gradle task cache on new java cdk release (#36480)
1 parent e11e4f5 commit 4288dcb

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

airbyte-ci/connectors/pipelines/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ E.G.: running Poe tasks on the modified internal packages of the current branch:
649649

650650
| Version | PR | Description |
651651
| ------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
652+
| 4.6.4 | [#36480](https://github.com/airbytehq/airbyte/pull/36480) | Burst the Gradle Task cache if a new CDK version was released |
652653
| 4.6.3 | [#36527](https://github.com/airbytehq/airbyte/pull/36527) | Handle extras as well as groups in `airbyte ci test` [poetry packages] |
653654
| 4.6.2 | [#36220](https://github.com/airbytehq/airbyte/pull/36220) | Allow using `migrate-to-base-image` without PULL_REQUEST_NUMBER |
654655
| 4.6.1 | [#36319](https://github.com/airbytehq/airbyte/pull/36319) | Fix `ValueError` related to PR number in migrate-to-poetry |

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/steps/gradle.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#
22
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33
#
4+
import xml.etree.ElementTree as ET
45
from abc import ABC
56
from datetime import datetime
67
from typing import Any, ClassVar, List, Optional, Tuple, cast
78

89
import pipelines.dagger.actions.system.docker
10+
import requests
911
from dagger import CacheSharingMode, CacheVolume, Container, ExecError
1012
from pipelines.airbyte_ci.connectors.context import ConnectorContext
1113
from pipelines.consts import AMAZONCORRETTO_IMAGE
@@ -32,6 +34,9 @@ class GradleTask(Step, ABC):
3234
GRADLE_DEP_CACHE_PATH = "/root/gradle-cache"
3335
GRADLE_HOME_PATH = "/root/.gradle"
3436
STATIC_GRADLE_OPTIONS = ("--no-daemon", "--no-watch-fs", "--build-cache", "--scan", "--console=plain")
37+
CDK_MAVEN_METADATA_URL = (
38+
"https://airbyte.mycloudrepo.io/public/repositories/airbyte-public-jars/io/airbyte/cdk/airbyte-cdk-core/maven-metadata.xml"
39+
)
3540
gradle_task_name: ClassVar[str]
3641
bind_to_docker_host: ClassVar[bool] = False
3742
mount_connector_secrets: ClassVar[bool] = False
@@ -65,6 +70,14 @@ def _get_gradle_command(self, task: str, *args: Any, task_options: Optional[List
6570
task_options = task_options or []
6671
return f"./gradlew {' '.join(self.gradle_task_options + args)} {task} {' '.join(task_options)}"
6772

73+
def get_last_cdk_update_time(self) -> str:
74+
response = requests.get(self.CDK_MAVEN_METADATA_URL)
75+
response.raise_for_status()
76+
last_updated = ET.fromstring(response.text).find(".//lastUpdated")
77+
if last_updated is None or last_updated.text is None:
78+
raise ValueError(f"Could not find the lastUpdated field in the CDK maven metadata at {self.CDK_MAVEN_METADATA_URL}")
79+
return last_updated.text
80+
6881
async def _run(self, *args: Any, **kwargs: Any) -> StepResult:
6982
include = [
7083
".root",
@@ -150,6 +163,8 @@ async def _run(self, *args: Any, **kwargs: Any) -> StepResult:
150163
gradle_container_base
151164
# Mount the whole repo.
152165
.with_directory("/airbyte", self.context.get_repo_dir("."))
166+
# Burst the cache if a new CDK version was released.
167+
.with_env_variable("CDK_LAST_UPDATE", self.get_last_cdk_update_time())
153168
# Update the cache in place by executing a gradle task which will update all dependencies.
154169
.with_exec(
155170
sh_dash_c(

airbyte-ci/connectors/pipelines/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pipelines"
7-
version = "4.6.3"
7+
version = "4.6.4"
88
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
99
authors = ["Airbyte <[email protected]>"]
1010

0 commit comments

Comments
 (0)