forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (144 loc) · 5.17 KB
/
validate-coding-standards.yml
File metadata and controls
174 lines (144 loc) · 5.17 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
name: Validating Coding Standards
on:
push:
branches:
- main
- "rc/**"
- next
pull_request:
branches:
- main
- "rc/**"
- next
env:
XARGS_MAX_PROCS: 4
jobs:
validate-package-files:
name: Validate Package Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install generate_package_files.py dependencies
run: pip install -r scripts/requirements.txt
- name: Validate Package Descriptions (CPP)
run: |
python scripts/validate-rule-package.py rule_packages/cpp/*.json
- name: Validate Package Descriptions (C)
run: |
python scripts/validate-rule-package.py rule_packages/c/*.json
- name: Validate Package Descriptions consistency (CPP)
run: |
python scripts/verify_rule_package_consistency.py cpp
- name: Validate Package Descriptions consistency (C)
run: |
python scripts/verify_rule_package_consistency.py c
- name: Validate Package Files (CPP)
run: |
find rule_packages/cpp -name \*.json -exec basename {} .json \; | xargs --max-procs "$XARGS_MAX_PROCS" --max-args 1 python scripts/generate_rules/generate_package_files.py cpp
git diff
git diff --compact-summary
git diff --quiet
- name: Validate Package Files (C)
run: |
find rule_packages/c -name \*.json -exec basename {} .json \; | xargs --max-procs "$XARGS_MAX_PROCS" --max-args 1 python scripts/generate_rules/generate_package_files.py c
git diff
git diff --compact-summary
git diff --quiet
validate-codeql-format:
name: "Validate CodeQL Format"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch CodeQL
run: |
TAG="v$( jq -r '.supported_environment | .[0] | .codeql_cli' supported_codeql_configs.json)"
gh release download $TAG --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip
unzip -q codeql-linux64.zip
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Validate CodeQL Format (CPP)
run: |
find cpp -name \*.ql -or -name \*.qll -print0 | xargs -0 --max-procs "$XARGS_MAX_PROCS" codeql/codeql query format --in-place
git diff
git diff --compact-summary
git diff --quiet
- name: Validate CodeQL Format (C)
run: |
find c -name \*.ql -or -name \*.qll -print0 | xargs -0 --max-procs "$XARGS_MAX_PROCS" codeql/codeql query format --in-place
git diff
git diff --compact-summary
git diff --quiet
validate-query-help-files:
name: Validate Query Help Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Validate CPP Query Help Files
run: |
exit_code=0
for help_file in `find cpp -name '*.md'`
do
if grep -F -q 'REPLACE THIS' "$help_file" > /dev/null
then
echo "Help file $help_file contains placeholders that are not replaced or removed!"
exit_code=1
fi
done
exit $exit_code
- name: Validate C Query Help Files
run: |
exit_code=0
for help_file in `find c -name '*.md'`
do
if grep -F -q 'REPLACE THIS' "$help_file" > /dev/null
then
echo "Help file $help_file contains placeholders that are not replaced or removed!"
exit_code=1
fi
done
exit $exit_code
validate-cpp-test-files:
name: Validate C++ Test Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install clang-format
run: |
sudo apt-get install --yes --quiet --no-install-recommends clang-format
echo "::debug::$(clang-format -version)"
- name: Validate C++ Test Files
run: |
if ! test -f .clang-format; then
echo "Cannot find .clang-format in '$PWD'. Exiting..."
fi
find cpp/*/test -name \*.cpp -print0 | xargs -0 --max-procs "$XARGS_MAX_PROCS" clang-format --style=file -i --verbose
git diff
git diff --compact-summary
git diff --quiet
validate-c-test-files:
name: Validate C Test Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install clang-format
run: |
sudo apt-get install --yes --quiet --no-install-recommends clang-format
echo "::debug::$(clang-format -version)"
- name: Validate C++ Test Files
run: |
if ! test -f .clang-format; then
echo "Cannot find .clang-format in '$PWD'. Exiting..."
fi
find c/*/test -name \*.c -print0 | xargs -0 --max-procs "$XARGS_MAX_PROCS" clang-format --style=file -i --verbose
git diff
git diff --compact-summary
git diff --quiet