-
Notifications
You must be signed in to change notification settings - Fork 339
130 lines (128 loc) · 6.36 KB
/
analysis.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
name: "Static Analysis"
on:
push:
pull_request:
branches: [ latest ]
schedule:
- cron: '18 6 * * 2'
jobs:
local-analysis:
name: "custom analysis"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Check Headers
run: |
tools/check_headers/check_headers.rb "include/**/*.h*" "include/**/**/*.h"
tools/check_headers/check_headers.rb "src/**/*.c"
tools/check_headers/check_headers.rb "test/**/*.cpp"
tools/check_headers/check_headers.rb "docs/examples/**/*.c"
- name: Check Localization
run: |
scripts/check_l10n.rb "include/private/config/locale/*-??.h"
- name: Build Documentation
run: |
sudo apt-get update
sudo apt-get install doxygen
cmake .
make docs
codeql-analysis:
name: "codeql analysis"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Initialize CodeQL
uses: github/codeql-action/init@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
sonarcloud-analysis:
name: "sonarcloud analysis"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 0
- name: Configure
run: |
cmake .
- name: Sonarcloud Analysis
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
run: |
wget -q https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make all
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
unzip -qq -o sonar-scanner-cli-5.0.1.3006-linux.zip
chmod +x sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner
sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner -Dproject.settings=tools/sonar/sonar-project.properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONARQUBE_SCANNER_PARAMS: '{"sonar.host.url":"https://sonarcloud.io"}'
custom-anaysis:
name: Custom Analysis
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 0
- name: "@since standardization"
run: |
# look for all instances of @since, then look for any that do not meet the required pattern. @since release x.x.x
if grep --include=\*.{c,h,cpp,hpp} -rnw . -e ".*@since .*" | grep -qv ".* @since release v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]].*"; then
# at this point the check has failed, but we want to give some info to the user. i have found it difficult to get the status code
# and print out the offending lines without this duplication
# get all instances of @since, offending and not offending
grep --include=\*.{c,h,cpp,hpp} -rnw . -e "@since .*" | \
# find all instances that do not meet the required pattern
grep -v ".* @since release v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]].*" | \
# print an error message, including line number with -n from grep. mention supported format.
xargs -I{} echo "Static Analysis Failed: \"{}\" Supported format is \"@since release vX.X.X\""
exit 1
else
exit 0
fi
release-version-and-date-analysis:
name: "release version and date analysis"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 0
- name: Release Version and Date Analysis
run: |
# search for release and date line from CITATION.cff with format:
# 'version: X.X.X' and 'date-released: XXXX-XX-XX' then extract to variables
# find the line with each, then extract the value wanted (version number or date) as well as line number
version_citation_info=$(grep -n -E -m1 '^version: [0-9]+\.[0-9]+\.[0-9]+' "CITATION.cff")
version_citation_line=$(echo "$version_citation_info" | cut -d: -f1)
version_citation=$(echo "$version_citation_info" | awk '{print $2}')
date_citation_info=$(grep -n -E -m1 'date-released: [0-9]{4}-[0-9]{2}-[0-9]{2}' "CITATION.cff")
date_citation_line=$(echo "$date_citation_info" | cut -d: -f1)
date_citation=$(echo "$date_citation_info" | awk '{print $2}')
# search for version and date line from ChangeLog.md with format:
# '## [X.X.X] - [XX-XX-XXXX]'
# find most recent line with version and date of release in ChangeLog.md
vd_changelog_info=$(grep -n -E -m1 '## \[[0-9]+\.[0-9]+\.[0-9]+\] - [0-9]{4}-[0-9]{2}-[0-9]{2}' "ChangeLog.md")
vd_changelog_line=$(echo "$vd_changelog_info" | cut -d: -f1)
# extract version, date and line number (since it's always on one line) to variables
version_changelog=$(echo "$vd_changelog_info" | awk -F'[][]' '{print $2}')
date_changelog=$(echo "$vd_changelog_info" | awk -F' - ' '{print $2}')
# compare version numbers and dates between files, listing discrepancies where found
if [[ "$version_changelog" != "$version_citation" ]]; then
echo "Release version numbers do not match: $version_changelog (ChangeLog.md on line $vd_changelog_line) vs $version_citation (CITATION.cff on line $version_citation_line)"
exit 1
fi
if [[ "$date_changelog" != "$date_citation" ]]; then
echo "Release dates do not match: $date_changelog (ChangeLog.md on line $vd_changelog_line) vs $date_citation (CITATION.cff on line $date_citation_line)"
exit 1
fi