forked from Verified-zkEVM/CompPoly
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (55 loc) · 2.11 KB
/
Copy pathlinting.yml
File metadata and controls
66 lines (55 loc) · 2.11 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Lint Style
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main, master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history to detect changed files
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Get changed Lean files
id: changed-files
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For PRs, compare against the base branch
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.sha }}"
else
# For pushes, compare against the previous commit
BASE_SHA="${{ github.event.before }}"
HEAD_SHA="${{ github.sha }}"
fi
# Get list of changed .lean files (one per line)
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" "$HEAD_SHA" | grep '\.lean$' || true)
if [ -z "$CHANGED_FILES" ]; then
echo "No changed Lean files found"
echo "has_files=false" >> $GITHUB_OUTPUT
else
# Save to file for use in next step
echo "$CHANGED_FILES" > changed_files.txt
echo "has_files=true" >> $GITHUB_OUTPUT
fi
- name: Run style linter
run: |
# Ensure style-exceptions.txt exists (even if empty)
touch scripts/style-exceptions.txt
if [ "${{ steps.changed-files.outputs.has_files }}" != "true" ]; then
echo "No changed Lean files to lint"
exit 0
fi
# Run linter on changed files only (one file per line)
# The script will exit with code 1 if there are any errors not in style-exceptions.txt
# This will cause the CI check to fail
cat changed_files.txt | xargs -r python3 scripts/lint-style.py