Skip to content

Commit

Permalink
Link to notebook previews in Squareone
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansick committed Aug 18, 2022
1 parent 505052b commit 341d2aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/timessquare/domain/githubcheckrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import os.path
from abc import ABCMeta, abstractproperty
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Sequence, Union
Expand Down Expand Up @@ -145,6 +146,10 @@ def squareone_pr_url_root(self) -> str:
f"/{self.repo.name}/{self.check_run.head_sha}"
)

def get_preview_url(self, notebook_path: str) -> str:
display_path = os.path.splitext(notebook_path)[0]
return f"{self.squareone_pr_url_root}/{display_path}"

def export_truncated_annotations(self) -> List[Dict[str, Any]]:
"""Export the first 50 annotations to objects serializable to
GitHub.
Expand Down Expand Up @@ -457,10 +462,12 @@ def text(self) -> str:
notebook_paths = list(set(self.notebook_paths_checked))
notebook_paths.sort()
for notebook_path in notebook_paths:
preview_url = self.get_preview_url(notebook_path)
linked_notebook = f"[{notebook_path}]({preview_url})"
if self._is_file_ok(notebook_path):
text = f"{text}| {notebook_path} | ✅ |\n"
text = f"{text}| {linked_notebook} | ✅ |\n"
else:
text = f"{text}| {notebook_path} | ❌ |\n"
text = f"{text}| {linked_notebook} | ❌ |\n"

return text

Expand Down

0 comments on commit 341d2aa

Please sign in to comment.