|
| 1 | +# Taken from https://github.com/whitphx/streamlit-server-state/blob/main/.github/workflows/tests.yml |
| 2 | +name: Tests |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + pull_request: |
| 8 | + branches: [main] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: [3.7, 3.8, 3.9] |
| 16 | + streamlit-version: [null] |
| 17 | + include: |
| 18 | + - python-version: 3.9 |
| 19 | + streamlit-version: 1.0.0 |
| 20 | + - python-version: 3.9 |
| 21 | + streamlit-version: 1.7.0 |
| 22 | + - python-version: 3.9 |
| 23 | + streamlit-version: 1.8.0 |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v2 |
| 27 | + |
| 28 | + - name: Set up Python ${{ matrix.python-version }} |
| 29 | + uses: actions/setup-python@v2 |
| 30 | + with: |
| 31 | + python-version: ${{ matrix.python-version }} |
| 32 | + |
| 33 | + - name: Install poetry |
| 34 | + run: | |
| 35 | + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - |
| 36 | + echo "$HOME/.poetry/bin" >> $GITHUB_PATH |
| 37 | +
|
| 38 | + # Ref: https://github.com/python-poetry/poetry/blob/de0b32c245c72568cf546090600d4626917cd3a4/.github/workflows/main.yml#L46-L60 |
| 39 | + - name: Configure poetry |
| 40 | + run: poetry config virtualenvs.in-project true |
| 41 | + - name: Set up cache |
| 42 | + |
| 43 | + id: cache |
| 44 | + with: |
| 45 | + path: .venv |
| 46 | + key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} |
| 47 | + - name: Ensure cache is healthy |
| 48 | + if: steps.cache.outputs.cache-hit == 'true' |
| 49 | + shell: bash |
| 50 | + run: timeout 10s poetry run pip --version || rm -rf .venv |
| 51 | + |
| 52 | + - name: Install a specific version of Streamlit |
| 53 | + if: ${{ matrix.streamlit-version }} |
| 54 | + run: poetry add -D streamlit=="${STREAMLIT_VERSION}" |
| 55 | + env: |
| 56 | + STREAMLIT_VERSION: ${{ matrix.streamlit-version }} |
| 57 | + |
| 58 | + - name: Install dependencies |
| 59 | + run: poetry install |
| 60 | + |
| 61 | + - name: Lint with black, isort, and flake8 |
| 62 | + run: | |
| 63 | + poetry run black . --check |
| 64 | + poetry run isort . --check |
| 65 | + poetry run flake8 |
| 66 | +
|
| 67 | + # Mypy checks currently not working on all versions of streamlit |
| 68 | + # - name: Type checking with mypy |
| 69 | + # run: | |
| 70 | + # poetry run mypy streamlit_sync |
| 71 | + |
| 72 | + - name: Test with pytest |
| 73 | + run: | |
| 74 | + poetry run pytest streamlit_sync_tests |
0 commit comments