-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (213 loc) · 6.79 KB
/
static.yml
File metadata and controls
253 lines (213 loc) · 6.79 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: Static Analysis
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
env:
ACT: 'false'
jobs:
change-metadata:
name: Capture Change Metadata
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect docs changes
id: detect-docs
run: |
set -euo pipefail
mkdir -p ci/change
head_sha="${GITHUB_SHA}"
event_name="${GITHUB_EVENT_NAME}"
base_sha=""
if [[ "${event_name}" == "push" ]]; then
base_sha=$(python - <<'PY'
import json
import os
with open(os.environ['GITHUB_EVENT_PATH'], 'r', encoding='utf-8') as fh:
data = json.load(fh)
print(data.get('before', ''))
PY
)
elif [[ "${event_name}" == "pull_request" ]]; then
base_sha=$(python - <<'PY'
import json
import os
with open(os.environ['GITHUB_EVENT_PATH'], 'r', encoding='utf-8') as fh:
data = json.load(fh)
base = data.get('pull_request', {}).get('base', {})
print(base.get('sha', ''))
PY
)
fi
if [[ -n "${base_sha}" ]]; then
base_ref="${base_sha}"
else
base_ref=$(git rev-parse "${head_sha}^" 2>/dev/null || true)
fi
if [[ -z "${base_ref}" ]]; then
base_ref=$(git rev-list --max-parents=0 "${head_sha}" | tail -n1)
fi
git diff --name-only "${base_ref}" "${head_sha}" | sort > ci/change/changed-files.txt || true
docs_changed="false"
if grep -E '^docs/' ci/change/changed-files.txt >/dev/null 2>&1; then
docs_changed="true"
fi
printf '%s\n' "${docs_changed}" > ci/change/docs-changed.txt
printf '%s\n' "${head_sha}" > ci/change/head-sha.txt
printf '%s\n' "${base_ref}" > ci/change/base-sha.txt
echo "docs_changed=${docs_changed}" >> "${GITHUB_OUTPUT}"
- name: Upload change metadata
if: ${{ env.ACT != 'true' }}
uses: actions/upload-artifact@v4
with:
name: ci-change-flags
path: ci/change/
retention-days: 30
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install Python formatting tools
run: |
pip install black isort
- name: Check Python formatting (black)
run: |
# Check if there are any Python files, if so format them
if find . -name "*.py" -not -path "./build/*" -not -path "./.venv/*" | grep -q .; then
black --check --diff .
else
echo "No Python files found to check"
fi
- name: Check Python imports (isort)
run: |
# Check if there are any Python files, if so check imports
if find . -name "*.py" -not -path "./build/*" -not -path "./.venv/*" | grep -q .; then
isort --check-only --diff .
else
echo "No Python files found to check"
fi
- name: Check file endings (end-of-file-fixer)
uses: pre-commit/action@v3.0.1
with:
extra_args: --hook-stage manual end-of-file-fixer
- name: Check trailing whitespace
uses: pre-commit/action@v3.0.1
with:
extra_args: --hook-stage manual trailing-whitespace
- name: Check mixed line endings
uses: pre-commit/action@v3.0.1
with:
extra_args: --hook-stage manual mixed-line-ending
- name: Validate YAML
uses: pre-commit/action@v3.0.1
with:
extra_args: --hook-stage manual check-yaml
- name: Validate JSON
uses: pre-commit/action@v3.0.1
with:
extra_args: --hook-stage manual check-json
lint-cpp:
name: C++ Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
# Add repositories for newer compilers
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y \
clang-tidy-18 \
clang-18 \
gcc-13 \
g++-13 \
build-essential \
cmake \
ninja-build \
pkg-config \
libx11-dev \
libxext-dev \
libxrandr-dev \
libxcursor-dev \
libxfixes-dev \
libxi-dev \
libxss-dev \
libwayland-dev \
libxkbcommon-dev \
libdrm-dev \
libgl1-mesa-dev \
libgles2-mesa-dev \
libegl1-mesa-dev \
libdbus-1-dev \
libudev-dev
- name: Generate compile_commands.json
run: |
export CC=gcc-13
export CXX=g++-13
cmake -B build \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DLAYA_BUILD_TESTS=ON \
-DLAYA_BUILD_EXAMPLES=ON
- name: Run clang-tidy (CI config)
run: |
# Run clang-tidy with CI-specific minimal checks on all C++ files
# Uses .clang-tidy-ci for focused, non-pedantic checks
# Fails the build on serious issues
find src include -type f \( -name "*.cpp" -o -name "*.hpp" \) | \
xargs clang-tidy-18 -p build --config-file=.clang-tidy-ci
static-analyzers:
name: Static Analyzers
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
mkdir -p reports
cppcheck --enable=all \
--inconclusive \
--xml \
--xml-version=2 \
--suppress=missingIncludeSystem \
--suppress=unmatchedSuppression \
--suppress=unusedFunction \
src/ include/ \
2> reports/cppcheck-report.xml || true
# Also generate text report for readability
cppcheck --enable=all \
--inconclusive \
--suppress=missingIncludeSystem \
--suppress=unmatchedSuppression \
--suppress=unusedFunction \
src/ include/ \
2> reports/cppcheck-report.txt || true
- name: Upload cppcheck reports
if: ${{ env.ACT != 'true' }}
uses: actions/upload-artifact@v4
with:
name: cppcheck-reports
path: reports/cppcheck-*.xml
retention-days: 30