Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

airbyte-ci: add dagger run url #28947

Merged
merged 16 commits into from
Aug 2, 2023
Merged
5 changes: 3 additions & 2 deletions airbyte-ci/connectors/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ At this point you can run `airbyte-ci` commands from the root of the repository.
#### Options

| Option | Default value | Mapped environment variable | Description |
| --------------------------------------- | ------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------- |
|-----------------------------------------|---------------------------------|-------------------------------|---------------------------------------------------------------------------------------------|
| `--no-tui` | | | Disables the Dagger terminal UI. |
| `--is-local/--is-ci` | `--is-local` | | Determines the environment in which the CLI runs: local environment or CI environment. |
| `--git-branch` | The checked out git branch name | `CI_GIT_BRANCH` | The git branch on which the pipelines will run. |
Expand Down Expand Up @@ -378,7 +378,8 @@ This command runs the Python tests for a airbyte-ci poetry package.

| Version | PR | Description |
|---------|-----------------------------------------------------------|----------------------------------------------------------------------------------------------|
| 0.3.1 | [#28938](https://github.com/airbytehq/airbyte/pull/28938) | Handle 5 status code on MetadataUpload as skipped |
| 0.4.0 | [#28947](https://github.com/airbytehq/airbyte/pull/28947) | Show Dagger Cloud run URLs in CI |
| 0.3.1 | [#28938](https://github.com/airbytehq/airbyte/pull/28938) | Handle 5 status code on MetadataUpload as skipped |
| 0.3.0 | [#28869](https://github.com/airbytehq/airbyte/pull/28869) | Enable the Dagger terminal UI on local `airbyte-ci` execution |
| 0.2.3 | [#28907](https://github.com/airbytehq/airbyte/pull/28907) | Make dagger-in-dagger work for `airbyte-ci tests` command |
| 0.2.2 | [#28897](https://github.com/airbytehq/airbyte/pull/28897) | Sentry: Ignore error logs without exceptions from reporting |
Expand Down
13 changes: 13 additions & 0 deletions airbyte-ci/connectors/pipelines/pipelines/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ def to_json(self) -> str:
"git_revision": self.pipeline_context.git_revision,
"ci_context": self.pipeline_context.ci_context,
"pull_request_url": self.pipeline_context.pull_request.html_url if self.pipeline_context.pull_request else None,
"dagger_cloud_url": self.pipeline_context.dagger_cloud_url,
}
)

Expand Down Expand Up @@ -480,6 +481,9 @@ def print(self):
main_panel = Panel(Group(*to_render), title=main_panel_title, subtitle=duration_subtitle)
console.print(main_panel)

if self.pipeline_context.dagger_cloud_url:
self.pipeline_context.logger.info(f"🔗 View commit in Dagger Cloud: {self.pipeline_context.dagger_cloud_url}")


@dataclass(frozen=True)
class ConnectorReport(Report):
Expand Down Expand Up @@ -535,6 +539,7 @@ def to_json(self) -> str:
"ci_context": self.pipeline_context.ci_context,
"cdk_version": self.pipeline_context.cdk_version,
"html_report_url": self.html_report_url,
"dagger_cloud_url": self.pipeline_context.dagger_cloud_url,
}
)

Expand All @@ -551,6 +556,10 @@ def post_comment_on_pr(self) -> None:
]
markdown_comment += tabulate(report_data, headers=["Step", "Result"], tablefmt="pipe") + "\n\n"
markdown_comment += f"🔗 [View the logs here]({self.html_report_url})\n\n"

if self.pipeline_context.dagger_cloud_url:
markdown_comment += f"☁️ [View commit in Dagger Cloud]({self.pipeline_context.dagger_cloud_url})\n\n"
pedroslopez marked this conversation as resolved.
Show resolved Hide resolved

markdown_comment += "*Please note that tests are only run on PR ready for review. Please set your PR to draft mode to not flood the CI engine and upstream service on following commits.*\n"
markdown_comment += "**You can run the same pipeline locally on this branch with the [airbyte-ci](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connector_ops/connector_ops/pipelines/README.md) tool with the following command**\n"
markdown_comment += f"```bash\nairbyte-ci connectors --name={self.pipeline_context.connector.technical_name} test\n```\n\n"
Expand Down Expand Up @@ -580,6 +589,7 @@ async def to_html(self) -> str:
template_context["commit_url"] = f"https://github.com/airbytehq/airbyte/commit/{self.pipeline_context.git_revision}"
template_context["gha_workflow_run_url"] = self.pipeline_context.gha_workflow_run_url
template_context["dagger_logs_url"] = self.pipeline_context.dagger_logs_url
template_context["dagger_cloud_url"] = self.pipeline_context.dagger_cloud_url
template_context[
"icon_url"
] = f"https://raw.githubusercontent.com/airbytehq/airbyte/{self.pipeline_context.git_revision}/{self.pipeline_context.connector.code_directory}/icon.svg"
Expand Down Expand Up @@ -620,3 +630,6 @@ def print(self):

main_panel = Panel(Group(*to_render), title=main_panel_title, subtitle=duration_subtitle)
console.print(main_panel)

if self.pipeline_context.dagger_cloud_url:
self.pipeline_context.logger.info(f"🔗 View commit in Dagger Cloud: {self.pipeline_context.dagger_cloud_url}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally i wanted to add this as a section in the Panel printed with console.print, but for the life of me I couldn't figure out how to make the link not get cut off. In CI it kept adding a newline which made the link not clickable.

18 changes: 15 additions & 3 deletions airbyte-ci/connectors/pipelines/pipelines/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import yaml
from anyio import Path
from asyncer import asyncify
from connector_ops.utils import Connector
from dagger import Client, Directory, Secret
from github import PullRequest
from pipelines import hacks
from pipelines.actions import secrets
from pipelines.bases import CIContext, ConnectorReport, Report
from pipelines.github import update_commit_status_check
from pipelines.slack import send_message_to_webhook
from pipelines.utils import AIRBYTE_REPO_URL, METADATA_FILE_NAME, format_duration, sanitize_gcs_credentials
from connector_ops.utils import Connector
from dagger import Client, Directory, Secret
from github import PullRequest


class ContextState(Enum):
Expand Down Expand Up @@ -172,6 +172,18 @@ def github_commit_status(self) -> dict:
def should_send_slack_message(self) -> bool:
return self.slack_webhook is not None and self.reporting_slack_channel is not None

@property
def is_dagger_cloud(self) -> bool:
pedroslopez marked this conversation as resolved.
Show resolved Hide resolved
return bool(os.getenv("_EXPERIMENTAL_DAGGER_CLOUD_TOKEN"))
pedroslopez marked this conversation as resolved.
Show resolved Hide resolved

@property
def dagger_cloud_url(self) -> str:
"""Gets the link to the Dagger Cloud runs page for the current commit."""
if self.is_local or not self.is_dagger_cloud:
return None

return f"https://alpha.dagger.cloud/changeByPipelines?filter=dagger.io/git.ref:{self.git_revision}"

def get_repo_dir(self, subdir: str = ".", exclude: Optional[List[str]] = None, include: Optional[List[str]] = None) -> Directory:
"""Get a directory from the current repository.

Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pipelines/dagger_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def check_dagger_cli_install() -> str:
def main():
os.environ[DAGGER_CLOUD_TOKEN_ENV_VAR_NAME_VALUE[0]] = DAGGER_CLOUD_TOKEN_ENV_VAR_NAME_VALUE[1]
exit_code = 0
if sys.argv[1] == "--no-tui":
if len(sys.argv) > 1 and sys.argv[1] == "--no-tui":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug with the latest changes here when no args were passed to airbyte-ci

command = ["airbyte-ci-internal"] + sys.argv[2:]
else:
dagger_path = check_dagger_cli_install()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
{% if dagger_logs_url %}
<li><b><a href="{{ dagger_logs_url }}">Dagger logs</a></b></li>
{% endif %}
{% if dagger_cloud_url %}
<li><b><a href="{{ dagger_cloud_url }}">Dagger Cloud</a></b></li>
pedroslopez marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
</ul>
<h2>Summary</h2>
<table>
Expand Down Expand Up @@ -169,6 +172,6 @@
</div>
</div>
{% endfor %}
<p style="margin-top: 50px"><em>These reports are generated from <a href="https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connector_ops/connector_ops/pipelines/tests/templates/test_report.html.j2">this code</a>, please reach out to the Connector Operations team for support.</em></p>
<p style="margin-top: 50px"><em>These reports are generated from <a href="https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/pipelines/tests/templates/test_report.html.j2">this code</a>, please reach out to the Connector Operations team for support.</em></p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link was wrong after the move

</body>
</html>
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pipelines"
version = "0.3.1"
version = "0.4.0"
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
authors = ["Airbyte <contact@airbyte.io>"]

Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-faker/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="source_faker",
description="Source implementation for fake but realistic looking data.",
description="Source implementation for fake but realistic looking data!",
author="Airbyte",
author_email="evan@airbyte.io",
packages=find_packages(),
Expand Down
Loading