https://github.com/streamlit/streamlit-app-action
Simple GitHub Action workflows for validating a Streamlit app
https://github.com/streamlit/streamlit-app-action
Last synced: 5 months ago
JSON representation
Simple GitHub Action workflows for validating a Streamlit app
- Host: GitHub
- URL: https://github.com/streamlit/streamlit-app-action
- Owner: streamlit
- License: apache-2.0
- Created: 2023-10-27T22:48:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-25T19:27:50.000Z (over 1 year ago)
- Last Synced: 2025-01-29T10:36:29.587Z (5 months ago)
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 15
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# streamlit-app-action
Github Action providing simple workflows for validating a Streamlit app. This action will:
- Run `pytest` for any tests, including [Streamlit AppTests](https://docs.streamlit.io/library/api-reference/app-testing),
that are part of your repo.
- Run a smoke test AppTest that runs each page of your app and verifies no exceptions are thrown on the initial run
- Optionally, run [ruff](https://github.com/astral-sh/ruff) for linting and formatting via
[ruff-action](https://github.com/ChartBoost/ruff-action).## Usage
Use the action by creating a `.yml` file in the `.github/workflows/` folder of your GitHub repository with contents
like the example below. This specific example will run the ruff linting and smoke testing action each time there's
a push to the `main` branch or a pull request update targeting main.You can learn more in the [GitHub Actions documentation](https://docs.github.com/en/actions) and the section on
[GitHub Actions workflows](https://docs.github.com/en/actions/using-workflows/about-workflows).```yml
name: Streamlit appon:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]permissions:
contents: readjobs:
streamlit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: streamlit/[email protected]
with:
app-path: streamlit_app.py
ruff: true
```### Printing a pretty output of test results
[pytest-results-action](https://github.com/marketplace/actions/pytest-results-actions) is a useful action
to print the output of pytest runs in your GitHub Actions workflow summary view. You can add it as follows:```yml
# ... setup as above ...
- uses: streamlit/[email protected]
with:
app-path: streamlit_app.py
ruff: true
# Add pytest-args to output junit xml
pytest-args: -v --junit-xml=test-results.xml
- if: always()
uses: pmeier/[email protected]
with:
path: test-results.xml
summary: true
display-options: fEX
```