forked from vllm-project/afd-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (47 loc) · 1.63 KB
/
Copy pathpre-commit.yml
File metadata and controls
51 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# SPDX-License-Identifier: Apache-2.0
name: pre-commit
on:
pull_request:
branches: [main, master]
push:
branches: [main, master]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Resolve changed-files range
id: range
shell: bash
run: |
zero=0000000000000000000000000000000000000000
if [ "${{ github.event_name }}" = "pull_request" ]; then
from_ref="${{ github.event.pull_request.base.sha }}"
to_ref="${{ github.event.pull_request.head.sha }}"
elif [ -n "${{ github.event.before }}" ] && [ "${{ github.event.before }}" != "$zero" ]; then
from_ref="${{ github.event.before }}"
to_ref="${{ github.sha }}"
else
from_ref="$(git rev-parse HEAD~1)"
to_ref="${{ github.sha }}"
fi
echo "from_ref=${from_ref}" >> "$GITHUB_OUTPUT"
echo "to_ref=${to_ref}" >> "$GITHUB_OUTPUT"
# Only check files changed in this push/PR; do not scan the whole tree.
- uses: pre-commit/action@v3.0.1
with:
extra_args: --from-ref ${{ steps.range.outputs.from_ref }} --to-ref ${{ steps.range.outputs.to_ref }}