Add Precommit to repo and update formatting #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Enforce Pre-Commit Hooks | |
on: | |
push: | |
branches: | |
- "develop" | |
pull_request: | |
types: [opened, synchronize, reopened] | |
# Allows workflow to be called from other workflows | |
workflow_call: | |
inputs: | |
ref: | |
required: true | |
type: string | |
# Avoid duplicate workflows on same branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-enforce-pre-commit | |
cancel-in-progress: true | |
jobs: | |
enforce-pre-commit: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout Streamlit code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref }} | |
persist-credentials: false | |
submodules: "recursive" | |
fetch-depth: 2 | |
- name: Set Python version vars | |
uses: ./.github/actions/build_info | |
- name: Set up Python ${{ env.PYTHON_MAX_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ env.PYTHON_MAX_VERSION }}" | |
- name: Restore pre-commit cache | |
id: cache-pre-commit | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: v1-pre-commit-${{ env.pythonLocation }}-${{ hashFiles('**/.pre-commit-config.yaml') }} | |
- name: Install pre-commit | |
run: | | |
pip install pre-commit | |
pre-commit install-hooks | |
shell: bash | |
- name: Install prettier | |
run: cd frontend && npm install | |
- name: Run pre-commit hooks | |
run: PRE_COMMIT_NO_CONCURRENCY=true pre-commit run --show-diff-on-failure --color=always |