-
Notifications
You must be signed in to change notification settings - Fork 17
52 lines (41 loc) · 1.38 KB
/
perltidy.yml
File metadata and controls
52 lines (41 loc) · 1.38 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
name: Perltidy Format Check
on:
push:
pull_request:
jobs:
perltidy:
runs-on: ubuntu-latest
name: Check Perl formatting
container:
image: perl:5.32 # Use a container with Perl pre-installed
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Perl::Tidy
run: cpanm -n Perl::Tidy@20260204
- name: Run perltidy check
run: |
EXIT_CODE=0
FILES=$(find ./bin ./PerlLibs/Genesis2 -type f \( -name '*.pl' -o -name '*.pm' -o -name '*.t' \) 2>/dev/null)
if [ -z "$FILES" ]; then
echo "No Perl files found."
exit 0
fi
for file in $FILES; do
# Run perltidy and output to a temp file
perltidy --profile=.perltidyrc "$file" -o "$file.tdy"
if ! diff -u "$file" "$file.tdy" > "$file.diff" 2>&1; then
echo "::error file=${file}::${file} is not correctly formatted"
echo "--- Diff for $file ---"
cat "$file.diff"
echo ""
EXIT_CODE=1
fi
rm -f "$file.tdy" "$file.diff"
done
if [ "$EXIT_CODE" -ne 0 ]; then
echo ""
echo "::error::Some Perl files are not formatted correctly. Please run perltidy."
exit 1
fi
echo "All Perl files are correctly formatted."