tvst / st-annotated-text

A simple component to display annotated text in Streamlit apps.
Apache License 2.0
523 stars 41 forks source link

ci: make pycafe link on each commit / playground #42

Open maartenbreddels opened 2 weeks ago

maartenbreddels commented 2 weeks ago

Hi Thiago :wave:,

This PR adds two github actions that together set up a Python/Streamlit playground with the latest st-annotated-text.

  1. build.yml: build the source distribution into a github artifact
  2. pycafe.yml: creates a snippet link to a PyCafe streamlit app that will install the wheel from 1. into a fresh in-browser Python environment and puts it as a status text (what you normally see next to a commit or at the bottom or a PR).

This process is documented here for one of our libraries. But I wanted to try it out on a streamlit project, and this one was easy to build.

I've tested this out on https://github.com/maartenbreddels/st-annotated-text/pull/1 to see if it works. It does, and it generates a link in the status:

image

Which should bring you to this playground

The reason that this is not one GitHub action, but two is due to security. The build.yml runs with the permission of the person opening the PR (and thus cannot write the status text). The pycafe.yml workflow runs with your permission (it can write the status text), but run on your master branch (so it does not execute a modified workflow files).

This is super useful for trying out a branch when someone opens a PR, nothing to install, no server running in the background 🍃 and no costs.

Let me know what you think.

Regards,

Maarten

PS: this PR does not write the status text yet, because pycafe.yml should be merged first before it runs, that's why I've created https://github.com/maartenbreddels/st-annotated-text/pull/1 to show that it works.