forked from paradedb/paradedb
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 2.04 KB
/
lint-format.yml
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
# workflows/lint-format.yml
#
# Lint Format
# Lint the project's file trailing spaces, line endings, and format.
name: Lint Format
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
concurrency:
group: lint-format-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
lint-format:
name: Lint File Endings & Trailing Whitespaces
runs-on: depot-ubuntu-latest-2
if: github.event.pull_request.draft == false
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Install fd Search Tool
run: |
sudo apt-get update
sudo apt-get install -y fd-find
mkdir -p "$HOME/.local/bin"
sudo ln -s $(which fdfind) "$HOME/.local/bin/fd"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Check for CRLF Files
run: |
FILES=$(git ls-files --eol | grep crlf || true)
if [[ ! -z "$FILES" ]]; then
echo "The following files have incorrect line endings:"
echo "$FILES"
false
fi
# We ignore .out and .sql files, which are used by pg_regress for testing
# and need a very specific format
- name: Check for Trailing Whitespaces
run: |
FILES=$(git grep -Ilr '[[:blank:]]$' -- ':(exclude)*.out' ':(exclude)*.sql' ':(exclude)*.rs' || true)
if [[ ! -z "$FILES" ]]; then
echo "The following files have trailing whitespaces:"
echo "$FILES"
exit 1
fi
- name: Print Modified Files
run: |
FILES=$(git ls-files --modified)
if [[ ! -z "$FILES" ]]; then
echo "The following files have incorrect trailing newlines:"
echo "$FILES"
echo "Please fix them using:"
echo -e 'if [[ -f "$1" ]]; then\n echo -n "$1"\n if (diff /dev/null "$1" || true) | tail -1 | grep -q "^\\ No newline"; then\n echo >> "$1"\n echo "...fixed"\n else\n echo ""\n fi\nfi'
false
fi