forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 4
222 lines (183 loc) · 6.78 KB
/
code_checks.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
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
name: Code Checks
on:
push:
paths-ignore:
- 'doc/**'
branches-ignore:
- 'backport**'
- 'dependabot**'
pull_request:
paths-ignore:
- 'doc/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cppcheck_2004:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y cppcheck libsqlite3-dev ccache sqlite3 libproj-dev cmake
- name: Run cmake
run: |
mkdir build
cd build
cmake ..
- name: Run cppcheck test
run: |
cd build
../scripts/cppcheck.sh
cppcheck_2404:
runs-on: ubuntu-latest
container: ubuntu:24.04
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install Requirements
run: |
apt update
apt install -y cppcheck libsqlite3-dev ccache sqlite3 libproj-dev cmake g++ make
- name: Run cmake
run: |
mkdir build
cd build
cmake ..
- name: Run cppcheck test
run: |
cd build
../scripts/cppcheck.sh
cppcheck_master:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install Requirements
run: |
sudo apt update
sudo apt install -y git libsqlite3-dev ccache sqlite3 libproj-dev cmake g++ make
- name: Build cppcheck
run: |
git clone https://github.com/danmar/cppcheck
cd cppcheck
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
cd ../..
- name: Run cmake
run: |
mkdir build
cd build
cmake ..
- name: Run cppcheck test
run: |
cd build
# Do not fail the job. This is just used as a tool to monitor how we are regarding recent cppcheck
../scripts/cppcheck.sh || /bin/true
code_quality_checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Detect tabulations
run: ./scripts/detect_tabulations.sh
- name: Detect printf
run: ./scripts/detect_printf.sh
- name: Detect self assignments
run: ./scripts/detect_self_assignment.sh
- name: Detect suspicious char digit zero
run: ./scripts/detect_suspicious_char_digit_zero.sh
- name: Detect missing includes
run: ./scripts/detect_missing_include.sh
# Helps detecting updates of internal libjson-c where replacement
# of strtod() -> CPLStrtod() is missing. The later function is not
# locale sensitive. An alternative would be to make sure that HAVE_USELOCALE
# or HAVE_SETLOCALE are passed on Windows, but avoiding to mess with
# locale seems to be a better option
- name: Detect invalid use of atof() or strtod() in internal libjson
run: |
grep -e "CPLStrtod(" ../ogr/ogrsf_frmts/geojson/libjson/*.c >/dev/null && echo "CPLStrtod() found as expected"
if grep -e "strtod(" ogr/ogrsf_frmts/geojson/libjson/*.c; then echo "Unexpected use of strtod(). Use CPLStrtod() instead"; /bin/false; fi
if grep -e "atof(" ogr/ogrsf_frmts/geojson/libjson/*.c; then echo "Unexpected use of atof()."; /bin/false; fi
- name: Shellcheck
# SC2129: (style): Consider using { cmd1; cmd2; } >> file instead of individual redirects
run: shellcheck -e SC2086,SC2046,SC2164,SC2054,SC2129 $(find . -name '*.sh' -a -not -name ltmain.sh -a -not -wholename "./autotest/*" -a -not -wholename "./.github/*")
binary_files:
runs-on: ubuntu-latest
steps:
- name: Install Requirements
run: |
sudo apt-get install -y python3 coreutils
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Detect binary files
run: python3 ./scripts/check_binaries.py
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
doxygen:
runs-on: ubuntu-latest
container: ghcr.io/osgeo/proj-docs
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Run doxygen
run: |
cd doc
make doxygen_check_warnings
other_checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install Requirements
run: |
sudo apt install python3-pip wget
# ruamel.yaml.clib 0.2.9 throws a 'TypeError: a string or stream input is required' when running cffconvert --validate
sudo pip3 install cffconvert "ruamel.yaml.clib<0.2.9"
- name: Validate citation file
run: |
cffconvert --validate
cffconvert -f bibtex
cffconvert -f apalike
cmake-lint:
# Disabled because of https://github.com/OSGeo/gdal/pull/5326#issuecomment-1042617407
if: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.8
- name: Install lint tool
run: |
python -m pip install --upgrade pip
pip install cmake-format pyyaml
- name: Check cmakelist
run: find . -name CMakeLists.txt |xargs cmake-format --check
validate_xml:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install requirements
run: |
sudo apt update
sudo apt install -y libxml2-utils
- name: Run xmllint checks
run: |
xmllint --schema ./frmts/nitf/data/nitf_spec.xsd ./frmts/nitf/data/nitf_spec.xml --noout
xmllint --schema ./ogr/ogrsf_frmts/vdv/data/vdv452.xsd ./ogr/ogrsf_frmts/vdv/data/vdv452.xml --noout
xmllint --schema ./ogr/ogrsf_frmts/gmlas/data/gmlasconf.xsd ./ogr/ogrsf_frmts/gmlas/data/gmlasconf.xml --noout