forked from cloudnative-pg/charts
-
-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (54 loc) · 1.81 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: ubuntu-latest
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: Add Trailing Newlines
run: .github/workflows/helpers/lint_trailing_newlines.sh
- 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
- name: Check for Trailing Whitespaces
run: |
FILES=$(git grep -Ilr '[[:blank:]]$' || 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 .github/workflows/helpers/lint_trailing_newlines.sh"
false
fi