Github Action providing simple workflows for validating a Streamlit app. This action will:
- Run
pytest
for any tests, including Streamlit AppTests, 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 for linting and formatting via ruff-action.
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 and the section on GitHub Actions workflows.
name: Streamlit app
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
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
pytest-results-action is a useful action to print the output of pytest runs in your GitHub Actions workflow summary view. You can add it as follows:
# ... 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