Skip to content

Commit

Permalink
airbyte-ci: better gradle caching (airbytehq#31535)
Browse files Browse the repository at this point in the history
Co-authored-by: postamar <postamar@users.noreply.github.com>
  • Loading branch information
postamar and postamar authored Oct 23, 2023
1 parent 9d8218f commit 9835f6b
Show file tree
Hide file tree
Showing 20 changed files with 150 additions and 67 deletions.
8 changes: 8 additions & 0 deletions .github/actions/run-dagger-pipeline/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ inputs:
ci_job_key:
description: "CI job key"
required: false
s3_build_cache_access_key_id:
description: "Gradle S3 Build Cache AWS access key ID"
required: false
s3_build_cache_secret_key:
description: "Gradle S3 Build Cache AWS secret key"
required: false
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -120,4 +126,6 @@ runs:
SPEC_CACHE_GCS_CREDENTIALS: ${{ inputs.spec_cache_gcs_credentials }}
DOCKER_HUB_USERNAME: ${{ inputs.docker_hub_username }}
DOCKER_HUB_PASSWORD: ${{ inputs.docker_hub_password }}
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ inputs.s3_build_cache_access_key_id }}
S3_BUILD_CACHE_SECRET_KEY: ${{ inputs.s3_build_cache_secret_key }}
CI: "True"
2 changes: 2 additions & 0 deletions .github/workflows/connectors_nightly_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ jobs:
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
git_branch: ${{ steps.extract_branch.outputs.branch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: "connectors ${{ inputs.test-connectors-options || '--concurrency=8 --support-level=certified' }} test"
4 changes: 4 additions & 0 deletions .github/workflows/connectors_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
git_branch: ${{ steps.extract_branch.outputs.branch }}
git_revision: ${{ steps.fetch_last_commit_id_pr.outputs.commit_id }}
github_token: ${{ env.PAT }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: "connectors ${{ github.event.inputs.test-connectors-options }} test"
- name: Test connectors [PULL REQUESTS]
if: github.event_name == 'pull_request'
Expand All @@ -76,4 +78,6 @@ jobs:
git_branch: ${{ github.head_ref }}
git_revision: ${{ steps.fetch_last_commit_id_pr.outputs.commit_id }}
github_token: ${{ env.PAT }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: "connectors --modified test"
4 changes: 4 additions & 0 deletions .github/workflows/publish_connectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
slack_webhook_url: ${{ secrets.PUBLISH_ON_MERGE_SLACK_WEBHOOK }}
spec_cache_gcs_credentials: ${{ secrets.SPEC_CACHE_SERVICE_ACCOUNT_KEY_PUBLISH }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: "connectors --concurrency=1 --execute-timeout=3600 --metadata-changes-only publish --main-release"

- name: Publish connectors [manual]
Expand All @@ -57,6 +59,8 @@ jobs:
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
slack_webhook_url: ${{ secrets.PUBLISH_ON_MERGE_SLACK_WEBHOOK }}
spec_cache_gcs_credentials: ${{ secrets.SPEC_CACHE_SERVICE_ACCOUNT_KEY_PUBLISH }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: "connectors ${{ github.event.inputs.connectors-options }} publish ${{ github.event.inputs.publish-options }}"

set-instatus-incident-on-failure:
Expand Down
1 change: 1 addition & 0 deletions airbyte-ci/connectors/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ This command runs the Python tests for a airbyte-ci poetry package.
## Changelog
| Version | PR | Description |
| ------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| 2.2.4 | [#31535](https://github.com/airbytehq/airbyte/pull/31535) | Improve gradle caching when building java connectors. |
| 2.2.3 | [#31688](https://github.com/airbytehq/airbyte/pull/31688) | Fix failing `CheckBaseImageUse` step when not running on PR. |
| 2.2.2 | [#31659](https://github.com/airbytehq/airbyte/pull/31659) | Support builds on x86_64 platform |
| 2.2.1 | [#31653](https://github.com/airbytehq/airbyte/pull/31653) | Fix CheckBaseImageIsUsed failing on non certified connectors. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def build(ctx: click.Context, use_host_gradle_dist_tar: bool) -> bool:
use_local_cdk=ctx.obj.get("use_local_cdk"),
open_report_in_browser=ctx.obj.get("open_report_in_browser"),
use_host_gradle_dist_tar=use_host_gradle_dist_tar,
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
)
for connector in ctx.obj["selected_connectors_with_modified_files"]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def bump_version(
ci_git_user=ctx.obj["ci_git_user"],
ci_github_access_token=ctx.obj["ci_github_access_token"],
open_report_in_browser=False,
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
)
for connector in ctx.obj["selected_connectors_with_modified_files"]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import yaml
from anyio import Path
from asyncer import asyncify
from dagger import Directory
from dagger import Directory, Secret
from github import PullRequest
from pipelines.airbyte_ci.connectors.reports import ConnectorReport
from pipelines.dagger.actions import secrets
Expand Down Expand Up @@ -57,6 +57,8 @@ def __init__(
open_report_in_browser: bool = True,
docker_hub_username: Optional[str] = None,
docker_hub_password: Optional[str] = None,
s3_build_cache_access_key_id: Optional[str] = None,
s3_build_cache_secret_key: Optional[str] = None,
):
"""Initialize a connector context.
Expand All @@ -82,6 +84,8 @@ def __init__(
open_report_in_browser (bool, optional): Open HTML report in browser window. Defaults to True.
docker_hub_username (Optional[str], optional): Docker Hub username to use to read registries. Defaults to None.
docker_hub_password (Optional[str], optional): Docker Hub password to use to read registries. Defaults to None.
s3_build_cache_access_key_id (Optional[str], optional): Gradle S3 Build Cache credentials. Defaults to None.
s3_build_cache_secret_key (Optional[str], optional): Gradle S3 Build Cache credentials. Defaults to None.
"""

self.pipeline_name = pipeline_name
Expand All @@ -101,6 +105,8 @@ def __init__(
self.open_report_in_browser = open_report_in_browser
self.docker_hub_username = docker_hub_username
self.docker_hub_password = docker_hub_password
self.s3_build_cache_access_key_id = s3_build_cache_access_key_id
self.s3_build_cache_secret_key = s3_build_cache_secret_key

super().__init__(
pipeline_name=pipeline_name,
Expand All @@ -121,6 +127,18 @@ def __init__(
open_report_in_browser=open_report_in_browser,
)

@property
def s3_build_cache_access_key_id_secret(self) -> Optional[Secret]:
if self.s3_build_cache_access_key_id:
return self.dagger_client.set_secret("s3_build_cache_access_key_id", self.s3_build_cache_access_key_id)
return None

@property
def s3_build_cache_secret_key_secret(self) -> Optional[Secret]:
if self.s3_build_cache_access_key_id and self.s3_build_cache_secret_key:
return self.dagger_client.set_secret("s3_build_cache_secret_key", self.s3_build_cache_secret_key)
return None

@property
def modified_files(self):
return self.connector.modified_files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def migrate_to_base_image(
open_report_in_browser=False,
docker_hub_username=docker_hub_username,
docker_hub_password=docker_hub_password,
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
)
for connector in ctx.obj["selected_connectors_with_modified_files"]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def publish(
ci_context=ctx.obj.get("ci_context"),
ci_gcs_credentials=ctx.obj["ci_gcs_credentials"],
pull_request=ctx.obj.get("pull_request"),
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
)
for connector in ctx.obj["selected_connectors_with_modified_files"]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def __init__(
ci_context: Optional[str] = None,
ci_gcs_credentials: str = None,
pull_request: PullRequest = None,
s3_build_cache_access_key_id: Optional[str] = None,
s3_build_cache_secret_key: Optional[str] = None,
):
self.pre_release = pre_release
self.spec_cache_bucket_name = spec_cache_bucket_name
Expand Down Expand Up @@ -66,6 +68,8 @@ def __init__(
should_save_report=True,
docker_hub_username=docker_hub_username,
docker_hub_password=docker_hub_password,
s3_build_cache_access_key_id=s3_build_cache_access_key_id,
s3_build_cache_secret_key=s3_build_cache_secret_key,
)

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def test(
fast_tests_only=fast_tests_only,
code_tests_only=code_tests_only,
use_local_cdk=ctx.obj.get("use_local_cdk"),
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
)
for connector in ctx.obj["selected_connectors_with_modified_files"]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def upgrade_base_image(ctx: click.Context, set_if_not_exists: bool, docker_hub_u
open_report_in_browser=False,
docker_hub_username=docker_hub_username,
docker_hub_password=docker_hub_password,
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
)
for connector in ctx.obj["selected_connectors_with_modified_files"]
]
Expand Down
Loading

0 comments on commit 9835f6b

Please sign in to comment.