Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding codechecker analysis workflow #4353

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 220 additions & 0 deletions .github/workflows/codechecker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
name: codechecker-tests

# Triggers the workflow on push or pull request events.
on: [push, pull_request]

jobs:
# Note: UI related linter tests will run in the gui job.
lint:
name: Linters (pylint, pycodestyle)

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)
- name: Run tests
run: make pylint pycodestyle

tools:
name: Tools (report-converter, etc.)
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Setup Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 4.0.0
- name: Install common dependencies
run: |
sudo apt-get update -q
sudo apt-get install gcc-multilib

- name: Run build-logger tests
working-directory: analyzer/tools/build-logger
run: |
pip install -r requirements_py/dev/requirements.txt
make all
make test

- name: Run merge-clang-extdef-mappings tests
working-directory: analyzer/tools/merge_clang_extdef_mappings
run: |
pip install -r requirements_py/dev/requirements.txt
make test

- name: Run statistics-collector tests
working-directory: analyzer/tools/statistics_collector
run: |
pip install -r requirements_py/dev/requirements.txt
make test

- name: Run report-converter tests
working-directory: tools/report-converter
run: |
pip install -r requirements_py/dev/requirements.txt
make package
make test

- name: Run tu-collector tests
working-directory: tools/tu_collector
run: |
pip install -r requirements_py/dev/requirements.txt
make test

- name: Run bazel-compile-commands tests
working-directory: tools/bazel
run: |
pip install -r requirements_py/dev/requirements.txt
make test

analyzer:
name: Analyzer
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install dependencies
run: sh .github/workflows/install-deps.sh

- name: Build the package
run: |
make pip_dev_deps
BUILD_UI_DIST=NO make package

- name: Run analyzer tests
working-directory: analyzer
run: make test_unit test_functional

- name: Analyzer unit tests coverage
working-directory: analyzer
run: make test_unit_cov

common:
name: Common libraries
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install requirements
working-directory: codechecker_common
run: |
pip install -r requirements_py/dev/requirements.txt

- name: Run mypy tests
working-directory: codechecker_common/tests
run: make mypy

web:
name: Web
runs-on: ubuntu-20.04

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

strategy:
matrix:
database: [sqlite, psql_pg8000, psql_psycopg2]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install dependencies
run: sh .github/workflows/install-deps.sh

- name: Init .pgpass
run: |
echo '*:*:*:*:postgres' > $HOME/.pgpass
chmod 0600 $HOME/.pgpass

- name: Run tests
env:
PGPASSWORD: postgres
run: |
export PGPASSFILE=$HOME/.pgpass

make pip_dev_deps
pip3 install -r web/requirements_py/auth/requirements.txt
BUILD_UI_DIST=NO make package

make -C web test_matrix_${{ matrix.database }}

- name: Run unit tests coverage
working-directory: web
run: make test_unit_cov

gui:
name: GUI
runs-on: ubuntu-20.04

strategy:
matrix:
# FIXME: in Chrome the UI test cases run non-deterministically and
# sometimes fail. For this reason we will not run GUI test cases
# in Chrome.
browser: [firefox]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: actions/setup-node@v1
with:
node-version: '16.x'

# - name: Update chrome
# run: |
# sudo apt-get update -q
# sudo apt-get install google-chrome-stable

- name: Install dependencies
run: sh .github/workflows/install-deps.sh

- name: Build the package
run: |
make pip_dev_deps
make package

- name: Run tests
working-directory: web/server/vue-cli
env:
# CHROME_HEADLESS: 1
MOZ_HEADLESS: 1
DISPLAY: ":99.0"
run: |
export PATH="${{ github.workspace }}/build/CodeChecker/bin:$PATH"

npm run test:lint
npm run test:unit
npm run test:e2e.${{ matrix.browser }}
39 changes: 39 additions & 0 deletions .github/workflows/codechecker_master_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: codechecker-master-analysis

# Triggers the workflow on push or pull request events.
on:
push:
branches:
- master
jobs:
codechecker-master-analyis:
name: CodeChecker analyze master

runs-on: ubuntu-20.04
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)
pip install codechecker
sh .github/workflows/install-deps.sh
- name: Build the CodeChecker package
run: |
make pip_dev_deps
BUILD_UI_DIST=NO make package
- name: Run CodeChecker analysis
env:
CODECHECKER_TOKEN: ${{secrets.CODECHECKER_STORE_TOKEN}}
PR_NUMBER: ${{ github.event.number }}
run: |
pwd
ls
touch ~/.codechecker.passwords.json
chmod 0600 ~/.codechecker.passwords.json
echo "{\"client_autologin\" : true,\"credentials\": {\"https://codechecker-demo.eastus.cloudapp.azure.com\": \"store:$CODECHECKER_TOKEN\"}}" > ~/.codechecker.passwords.json
bash ./scripts/github-analysis/codechecker_gate_master.sh
39 changes: 39 additions & 0 deletions .github/workflows/codechecker_pr_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: codechecker-pr-analysis

# Triggers the workflow on push or pull request events.
on:
push:
branches-ignore:
- master
jobs:
codechecker-pr-analyis:
name: CodeChecker PR analysis

runs-on: ubuntu-20.04
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)
pip install codechecker
sh .github/workflows/install-deps.sh
- name: Build the CodeChecker package
run: |
make pip_dev_deps
BUILD_UI_DIST=NO make package
- name: Run CodeChecker analysis
env:
CODECHECKER_TOKEN: ${{secrets.CODECHECKER_STORE_TOKEN}}
PR_NUMBER: ${{ github.event.number }}
run: |
pwd
ls
touch ~/.codechecker.passwords.json
chmod 0600 ~/.codechecker.passwords.json
echo "{\"client_autologin\" : true,\"credentials\": {\"https://codechecker-demo.eastus.cloudapp.azure.com\": \"store:$CODECHECKER_TOKEN\"}}" > ~/.codechecker.passwords.json
bash ./scripts/github-analysis/codechecker_gate_pr.sh $GITHUB_REF
15 changes: 15 additions & 0 deletions scripts/github-analysis/codechecker_gate_master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
./scripts/github-analysis/pylint_analyze.sh
report-converter -c -t pylint -o ./reports-pylint ./pylint-reports.json
CodeChecker store ./reports-pylint --url https://codechecker-demo.eastus.cloudapp.azure.com/codechecker --trim-path-prefix `pwd` -n master
new_findings=`CodeChecker cmd results --url https://codechecker-demo.eastus.cloudapp.azure.com/codechecker/ master --detection-status 'NEW' 'REOPENED' --review-status 'UNREVIEWED' 'CONFIRMED'|grep "NEW\|REOPENED"|wc -l`
if [ "$new_findings" -ne "0" ]; then
echo "ERROR. This PUSH introduced $new_findings new findings to the master branch! Please check them at https://codechecker-demo.eastus.cloudapp.azure.com/codechecker/reports?review-status=Unreviewed&review-status=Confirmed%20bug&detection-status=New&run=master&is-unique=off&diff-type=New"
exit 1
else
echo "SUCCESS. No new reports introduced"
fi




18 changes: 18 additions & 0 deletions scripts/github-analysis/codechecker_gate_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "<PR_NAME> is missing"
fi
./scripts/github-analysis/pylint_analyze.sh
report-converter -c -t pylint -o ./reports-pylint ./pylint-reports.json
CodeChecker store -f ./reports-pylint --url https://codechecker-demo.eastus.cloudapp.azure.com/codechecker --trim-path-prefix `pwd` -n $1
CodeChecker cmd diff --url https://codechecker-demo.eastus.cloudapp.azure.com/codechecker -b master -n $1 --new
if [ $? -ne 0 ]; then
echo "ERROR. YOUR PR FAILED GATING! Please check new reports at https://codechecker-demo.eastus.cloudapp.azure.com/codechecker/reports?run=master&newcheck=$1"
exit 1
else
echo "Gating successful. No new report found. Your PR is ready to be merged."
fi




5 changes: 5 additions & 0 deletions scripts/github-analysis/pylint_analyze.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
pylint --version
disabled_checkers="--disable duplicate-code --disable fixme --disable consider-using-get --disable too-many-instance-attributes"
pylint --rcfile=.pylintrc -j0 --ignore=migrations ./build/CodeChecker/lib/python3/* --enable all $disabled_checkers -f json --output ./pylint-reports.json

Loading