Skip to content

Commit

Permalink
[CI] Allow external contributors to trigger PyCafe CI (#826)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
maxschulz-COL and pre-commit-ci[bot] authored Oct 28, 2024
1 parent 5b9ba81 commit 4383dbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pycafe-dashboards-in-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:

- name: Create PyCafe links
run: |
hatch run python ../tools/pycafe/create_pycafe_links.py ${{ github.token }} ${{ github.repository }} ${{ github.event.number }} ${{ github.run_id }}
hatch run python ../tools/pycafe/create_pycafe_links.py ${{ github.token }} ${{ github.repository }} ${{ github.event.number }} ${{ github.event.workflow_run.id }} ${{ github.event.workflow_run.head_sha }}
11 changes: 6 additions & 5 deletions tools/pycafe/create_pycafe_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
REPO_NAME = sys.argv[2]
PR_NUMBER = int(sys.argv[3])
RUN_ID = sys.argv[4]
COMMIT_SHA = sys.argv[5]
WHL_FILE = next(Path("dist").glob("*.whl")).name
PYCAFE_URL = "https://py.cafe"
VIZRO_RAW_URL = "https://raw.githubusercontent.com/mckinsey/vizro"
Expand All @@ -34,13 +35,13 @@
# Get PR and commits
repo = g.get_repo(REPO_NAME)
pr = repo.get_pull(PR_NUMBER)
commit_sha = pr.head.sha
commit = repo.get_commit(commit_sha)
commit_sha_files = pr.head.sha
commit = repo.get_commit(COMMIT_SHA)


def generate_link(directory: str, extra_requirements: Optional[list[str]] = None):
"""Generate a PyCafe link for the example dashboards."""
base_url = f"{VIZRO_RAW_URL}/{commit_sha}/vizro-core/{directory}"
base_url = f"{VIZRO_RAW_URL}/{commit_sha_files}/vizro-core/{directory}"

# Requirements
requirements = "\n".join(
Expand Down Expand Up @@ -103,12 +104,12 @@ def post_comment(urls: dict[str, str]):
# Update the existing comment or create a new one
if bot_comment:
bot_comment.edit(
BOT_COMMENT_TEMPLATE.format(current_utc_time=current_utc_time, commit_sha=commit_sha, dashboards=dashboards)
BOT_COMMENT_TEMPLATE.format(current_utc_time=current_utc_time, commit_sha=COMMIT_SHA, dashboards=dashboards)
)
print("Comment updated on the pull request.") # noqa
else:
pr.create_issue_comment(
BOT_COMMENT_TEMPLATE.format(current_utc_time=current_utc_time, commit_sha=commit_sha, dashboards=dashboards)
BOT_COMMENT_TEMPLATE.format(current_utc_time=current_utc_time, commit_sha=COMMIT_SHA, dashboards=dashboards)
)
print("Comment added to the pull request.") # noqa

Expand Down
2 changes: 1 addition & 1 deletion vizro-core/examples/scratch_dev/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


page = vm.Page(
title="Test I",
title="Test Ultimate",
components=[
vm.Graph(
figure=px.bar(
Expand Down

0 comments on commit 4383dbc

Please sign in to comment.