forked from STEllAR-GROUP/hpx
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (110 loc) · 4.12 KB
/
check-formatting.yml
File metadata and controls
140 lines (110 loc) · 4.12 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright (c) 2026 The STE||AR Group
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
name: Check Formatting
on:
pull_request:
push:
branches:
- master
- 'release**'
workflow_dispatch:
jobs:
clang-format:
runs-on: ubuntu-latest
container: stellargroup/build_env:17
steps:
- uses: actions/checkout@v6
- name: Clang Format
shell: bash
run: |
git config --global --add safe.directory /__w/hpx/hpx
REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT/libs" && shopt -s globstar # to activate the ** globbing
clang-format-20 --version
clang-format-20 -i **/*.{cpp,hpp}
cd "$REPO_ROOT/examples"
clang-format-20 -i **/*.{cpp,hpp}
cd "$REPO_ROOT/tests"
clang-format-20 -i **/*.{cpp,hpp}
cd "$REPO_ROOT"
if ! git diff --exit-code > /tmp/modified_clang_format_files.txt; then
echo "The following files are not properly clang-formatted:"
cat /tmp/modified_clang_format_files.txt
exit 1
fi
- name: Upload Clang Format Artifacts
if: success() || failure()
uses: actions/upload-artifact@v7
with:
name: modified-clang-format-files
path: /tmp/modified_clang_format_files.txt
cmake-format:
runs-on: ubuntu-latest
container: stellargroup/build_env:17
steps:
- uses: actions/checkout@v6
- name: CMake Format
shell: bash
run: |
git config --global --add safe.directory /__w/hpx/hpx
REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT" && shopt -s globstar # to activate the ** globbing
cmake-format --version
cmake-format -i **/*.cmake **/CMakeLists.txt
if ! git diff --exit-code > /tmp/modified_cmake_format_files.txt; then
echo "The following files are not properly cmake-formatted:"
cat /tmp/modified_cmake_format_files.txt
exit 1
fi
- name: Upload CMake Format Artifacts
if: success() || failure()
uses: actions/upload-artifact@v7
with:
name: modified-cmake-format-files
path: /tmp/modified_cmake_format_files.txt
spell-check:
runs-on: ubuntu-latest
container: stellargroup/build_env:17
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Ensure full history for proper diff
- name: Running Spell Check
shell: bash
run: |
if [[ -n "${{ github.event.pull_request.number || '' }}" ]] || [[ "${{ github.event_name }}" == "pull_request" ]]; then
git config --global --add safe.directory /__w/hpx/hpx
REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT"
codespell --version
echo "Fetching changed files from origin/master..."
git fetch origin master --depth=1
echo "Files being checked:"
git diff --name-only origin/master... > /tmp/file_list.txt
cat /tmp/file_list.txt # Print all files being checked
set -x # Enable debug mode
# Read all changed files into an array
mapfile -t FILES < /tmp/file_list.txt
# Process files in batches of 50
for ((i = 0; i < ${#FILES[@]}; i += 50)); do
codespell --ignore-words tools/.codespell_whitelist --skip='*.h5,*.png' "${FILES[@]:i:50}" >> /tmp/spelling_suggestions.txt
done
set +x # Disable debug mode
# If there are spelling errors, exit with error code 1
if [[ -s /tmp/spelling_suggestions.txt ]]; then
echo "Spelling errors found:"
cat /tmp/spelling_suggestions.txt
exit 1
fi
else
echo "Skipping spellcheck on non-PR build"
fi
- name: Upload Spell Check Artifacts
if: success() || failure()
uses: actions/upload-artifact@v7
with:
name: spelling-suggestions
path: /tmp/spelling_suggestions.txt