-
Notifications
You must be signed in to change notification settings - Fork 191
89 lines (85 loc) · 2.77 KB
/
lint.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
name: Lint
on:
pull_request:
push:
jobs:
astyle:
env:
ASTYLE_CMD: >-
astyle
--break-blocks
--indent-switches
--indent=force-tab=8
--lineend=linux
--options=none
--pad-header
--pad-oper
--style=1tbs
--suffix=none
--unpad-paren
includes/*.h includes/*.hpp src/*.c src/*.cpp
name: Lint with `Artistic Style`
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Provision environment
uses: ./.github/actions/dependencies/install/apt-get
with:
packages: astyle
- name: Check if any modifications were made by `astyle`
run: |
ASTYLE_OUTPUT=$(${ASTYLE_CMD} --dry-run)
if [ -n "$(echo "${ASTYLE_OUTPUT}" | grep -v "Unchanged")" ]; then
echo "The following files are in need of formatting:"
echo "${ASTYLE_OUTPUT}" | grep -v "Unchanged" | awk '{print "`"$2"`"}'
echo ""
echo "Run the following command before submitting a pull request:"
echo '`'"${ASTYLE_CMD}"'`'
exit 1
fi
- name: Write `$ASTYLE_OUTPUT` to `$GITHUB_STEP_SUMMARY`
run: |
ASTYLE_OUTPUT=$(${ASTYLE_CMD} --dry-run)
echo "### The following files are in need of formatting:" >> ${GITHUB_STEP_SUMMARY}
echo "${ASTYLE_OUTPUT}" | grep -v "Unchanged" | awk '{print "- `"$2"`"}' >> ${GITHUB_STEP_SUMMARY}
echo "### Run the following command before submitting a pull request:" >> ${GITHUB_STEP_SUMMARY}
echo -e '```shell\n'"${ASTYLE_CMD}"'\n```' >> ${GITHUB_STEP_SUMMARY}
if: failure()
- name: Generate `ArtisticStyleFormattingFixes.patch` file
run: |
${ASTYLE_CMD}
git diff --patch > ArtisticStyleFormattingFixes.patch
if: failure()
- name: Upload `ArtisticStyleFormattingFixes.patch` file
uses: actions/upload-artifact@v4
with:
name: ArtisticStyleFormattingFixes.patch
path: ArtisticStyleFormattingFixes.patch
if: failure()
cmakelint:
name: Lint with `CMakeLint`
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Provision environment
run: pip install --user cmakelint
- name: Run linter
run: |
cmakelint --linelength=125 \
CMakeLists.txt \
*/CMakeLists.txt \
*/*.cmake
prettier:
name: Lint with `Prettier`
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Provision environment
run: npm install prettier
- name: Run linter
run: |
npx prettier --check .