Skip to content

Commit cb1af87

Browse files
[ci] Add CodeChecker analyze to GitHub Actions
Analyze CodeChecker code with CodeChecker when creating pull-request and compare to master. Fail PR if new issues introduced.
1 parent a1411fd commit cb1af87

6 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: codechecker-master-analysis
2+
3+
# Triggers the workflow on push or pull request events.
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
codechecker-master-analyis:
11+
name: CodeChecker analyze master
12+
13+
runs-on: ubuntu-24.04
14+
env:
15+
PR_NUMBER: ${{ github.event.number }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.9'
21+
- name: Install dependencies
22+
run: |
23+
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)
24+
pip install codechecker==6.25.1
25+
sh .github/workflows/install-deps.sh
26+
- name: Build the CodeChecker package
27+
run: |
28+
make pip_dev_deps
29+
BUILD_UI_DIST=NO make package
30+
- name: Run CodeChecker analysis
31+
env:
32+
CODECHECKER_TOKEN: ${{ secrets.CODECHECKER_STORE_TOKEN }}
33+
PR_NUMBER: ${{ github.event.number }}
34+
run: |
35+
pwd
36+
ls
37+
touch ~/.codechecker.passwords.json
38+
chmod 0600 ~/.codechecker.passwords.json
39+
echo "{\"client_autologin\" : true,\"credentials\": {\"*\": \"store:$CODECHECKER_TOKEN\"}}" > ~/.codechecker.passwords.json
40+
bash ./ci/github_analysis/codechecker_gate_master.sh
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: codechecker-pr-analysis
2+
3+
# Triggers the workflow on push or pull request events.
4+
on: [push, pull_request]
5+
6+
jobs:
7+
codechecker-pr-analyis:
8+
name: CodeChecker analyze PR
9+
10+
runs-on: ubuntu-24.04
11+
env:
12+
PR_NUMBER: ${{ github.event.number }}
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.9'
18+
- name: Install dependencies
19+
run: |
20+
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)
21+
pip install codechecker==6.25.1
22+
sh .github/workflows/install-deps.sh
23+
- name: Build the CodeChecker package
24+
run: |
25+
make pip_dev_deps
26+
BUILD_UI_DIST=NO make package
27+
- name: Run CodeChecker analysis
28+
env:
29+
CODECHECKER_TOKEN: ${{ secrets.TEST }}
30+
PR_NUMBER: ${{ github.event.number }}
31+
run: |
32+
pwd
33+
ls
34+
CodeChecker version
35+
touch ~/.codechecker.passwords.json
36+
chmod 0600 ~/.codechecker.passwords.json
37+
echo "{\"client_autologin\" : true,\"credentials\": {\"https://codechecker-demo.eastus.cloudapp.azure.com\": \"store:${{ secrets.TEST }}\"}}" > ~/.codechecker.passwords.json
38+
cat ~/.codechecker.passwords.json
39+
bash ./ci/github_analysis/codechecker_gate_pr.sh $GITHUB_REF

.gitmessage

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# --- COMMIT END ---
1010
# Tag can be
1111
# analyzer (Analyzer related changes)
12+
# ci (CI/CD related changes)
1213
# clang (Clang Static Analyzer related changes)
1314
# clang-tidy (Clang Tidy related changes)
1415
# cmd (Command line changes)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
CC_URL="https://codechecker-demo.eastus.cloudapp.azure.com/codechecker"
4+
5+
./ci/github_analysis/pylint_analyze.sh
6+
7+
report-converter -c -t pylint -o ./reports-pylint ./pylint-reports.json
8+
CodeChecker version
9+
CodeChecker store ./reports-pylint --url "$CC_URL" --trim-path-prefix "$(pwd)" -n master
10+
new_finding_count=$(CodeChecker cmd results --url "$CC_URL" master --detection-status 'NEW' 'REOPENED' --review-status 'UNREVIEWED' 'CONFIRMED' | grep -c "NEW\|REOPENED")
11+
if [ "$new_finding_count" -ne "0" ]; then
12+
echo "ERROR. This PUSH introduced $new_finding_count new findings to the master branch! Please check them at $CC_URL/reports?review-status=Unreviewed&review-status=Confirmed%20bug&detection-status=New&run=master&is-unique=off&diff-type=New"
13+
exit 1
14+
else
15+
echo "SUCCESS. No new reports introduced"
16+
exit 0
17+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
CC_URL="https://codechecker-demo.eastus.cloudapp.azure.com/codechecker"
4+
5+
if [ "$#" -ne 1 ]; then
6+
echo "<PR_NAME> is missing"
7+
fi
8+
9+
./ci/github_analysis/pylint_analyze.sh
10+
report-converter -c -t pylint -o ./reports-pylint ./pylint-reports.json
11+
CodeChecker store -f ./reports-pylint --url "$CC_URL" --trim-path-prefix "$(pwd)" -n "$1"
12+
CodeChecker cmd diff --url "$CC_URL" -b master -n "$1" --new
13+
if [ "$?" -ne 0 ]; then
14+
echo "ERROR. YOUR PR FAILED GATING! Please check new reports at $CC_URL/reports?run=master&newcheck=$1"
15+
exit 1
16+
else
17+
echo "Gating successful. No new report found. Your PR is ready to be merged."
18+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
pylint --version
4+
disabled_checkers="duplicate-code,fixme,consider-using-get,too-many-instance-attributes"
5+
pylint --rcfile=.pylintrc -j0 --disable $disabled_checkers -f json --output ./pylint-reports.json ./build/CodeChecker/lib/python3/*

0 commit comments

Comments
 (0)