forked from phoenix-oss/llama-stack-mirror
45 lines
1.3 KiB
YAML
45 lines
1.3 KiB
YAML
name: Pre-commit
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [main]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
pre-commit:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
with:
|
|
python-version: '3.11'
|
|
cache: pip
|
|
cache-dependency-path: |
|
|
**/requirements*.txt
|
|
.pre-commit-config.yaml
|
|
|
|
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
|
|
env:
|
|
SKIP: no-commit-to-branch
|
|
RUFF_OUTPUT_FORMAT: github
|
|
|
|
- name: Verify if there are any diff files after pre-commit
|
|
run: |
|
|
git diff --exit-code || (echo "There are uncommitted changes, run pre-commit locally and commit again" && exit 1)
|
|
|
|
- name: Verify if there are any new files after pre-commit
|
|
run: |
|
|
unstaged_files=$(git ls-files --others --exclude-standard)
|
|
if [ -n "$unstaged_files" ]; then
|
|
echo "There are uncommitted new files, run pre-commit locally and commit again"
|
|
echo "$unstaged_files"
|
|
exit 1
|
|
fi
|