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
7 changes: 4 additions & 3 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,8 +378,9 @@ This command runs the Python tests for a airbyte-ci poetry package.

| Version | PR | Description |
|---------|-----------------------------------------------------------|----------------------------------------------------------------------------------------------|
| 0.3.2 | [#28789](https://github.com/airbytehq/airbyte/pull/28789) | Do not consider empty reports as successfull. |
| 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.2 | [#28789](https://github.com/airbytehq/airbyte/pull/28789) | Do not consider empty reports as successfull. |
| 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 @@ -477,6 +478,9 @@ def print(self):
failures_group = Group(*sub_panels)
to_render.append(failures_group)

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

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

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 runs for commit in Dagger Cloud]({self.pipeline_context.dagger_cloud_url})\n\n"

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 @@ -618,5 +628,8 @@ def print(self):
details_instructions = Text("ℹ️ You can find more details with step executions logs in the saved HTML report.")
to_render = [step_results_table, details_instructions]

if self.pipeline_context.dagger_cloud_url:
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't you already logging this on line 481?

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 is a different Report's print. One is ConnectorReport.print and the other is Report.print

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

main_panel = Panel(Group(*to_render), title=main_panel_title, subtitle=duration_subtitle)
console.print(main_panel)
12 changes: 12 additions & 0 deletions airbyte-ci/connectors/pipelines/pipelines/contexts.py
Original file line number Diff line number Diff line change
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 has_dagger_cloud_token(self) -> bool:
return "_EXPERIMENTAL_DAGGER_CLOUD_TOKEN" in os.environ

@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.has_dagger_cloud_token:
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 UI</a></b></li>
{% 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.2"
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
Loading