2021-11-27 11:18:56 +01:00
name : 'CodeChecker Static Analysis'
author : 'Whisperity'
description : 'Execute C/C++ static analysis of LLVM/Clang (Clang Static Analyzer and Clang-Tidy) driven via CodeChecker.'
2021-11-27 12:34:26 +01:00
branding :
icon : 'tool'
color : 'blue'
2021-11-27 11:18:56 +01:00
inputs :
2021-11-29 17:42:43 +01:00
install-custom :
description : 'Whether to download, check out, and build a CodeChecker package manually in the CI.'
required : true
default : 'false'
2021-11-27 11:23:14 +01:00
repository :
description : 'The CodeChecker repository to check out and build from.'
required : true
default : 'Ericsson/CodeChecker'
2021-11-27 11:18:56 +01:00
version :
2021-11-29 17:42:43 +01:00
description : 'The version of the CodeChecker suite to obtain and execute. Might be a Git commit SHA, a branch name, or a tag if building a custom package, or a release version if downloading from PyPI. If "master" and downloading from PyPI, fetch the latest release.'
2021-11-27 11:18:56 +01:00
required : true
default : 'master'
2021-11-27 12:34:26 +01:00
llvm-version :
description : 'The major version of LLVM to install and use. LLVM is installed from PPA. If "latest", automatically gather the latest version. If "ignore", do not install anything. (Not recommended)'
required : true
default : 'latest'
2021-11-28 10:34:05 +01:00
config :
description : 'The CodeChecker configuration JSON that contains for each CodeChecker action (analyze, parse, ...) the list of flags that should be appended to the invocation of the command.'
required : false
logfile :
description : 'The location of the JSON Compilation Database for the project. This file describes how the project is compiled, and thus how it should be analysed. Mutually exclusive with "build-command".'
required : false
build-command :
description : 'The build command to execute and log for the creation of a JSON Compilation Database. Mutually exclusive with "logfile".'
required : false
2021-11-28 14:31:07 +01:00
analyze-output :
description : 'The output directory where the raw analysis output should be stored. If left the default empty, the path will be generated automatically.'
required : false
2021-11-29 17:42:43 +01:00
default : ''
2021-11-28 14:31:07 +01:00
ctu :
description : 'Whether to enable Cross Translation Unit (CTU) analysis in the Clang Static Analyzer.'
required : true
2021-11-29 17:42:43 +01:00
default : 'false'
2021-11-28 14:31:07 +01:00
2021-11-29 16:22:28 +01:00
store :
2021-11-29 17:42:43 +01:00
description : 'Whether to enable storing the results to a CodeChecker server. If enabled, other flags, such as "store-url" must also be set.'
2021-11-29 16:22:28 +01:00
required : true
2021-11-29 17:42:43 +01:00
default : 'false'
2021-11-29 16:22:28 +01:00
store-url :
2021-11-29 17:42:43 +01:00
description : 'The CodeChecker product URL (usually in the format of http://example.com/ProductName) where the store should connect to. Mandatory if "store" is true.'
2021-11-29 16:22:28 +01:00
required : false
store-username :
description : 'If the server requires authentication, the username to authenticate with.'
required : false
store-password :
description : 'The password (or generated private access token) corresponding to the user.'
required : false
store-run-name :
description : 'An identifying name of the analysis run. A run usually correlates to a set of configuration, e.g. analysis mode, branch, etc. If left default, the name is automatically generated from the current repository and branch name.'
required : true
2021-11-29 17:42:43 +01:00
default : '__DEFAULT__'
2021-11-29 16:22:28 +01:00
2021-11-28 14:31:07 +01:00
outputs :
logfile :
description : 'The location of the JSON Compilation Database that was used for the analysis.'
value : ${{ steps.log.outputs.COMPILATION_DATABASE }}
analyze-output :
description : 'The output directory where the raw analysis output was stored to.'
value : ${{ steps.analyze.outputs.OUTPUT_DIR }}
2021-11-28 15:50:11 +01:00
warnings :
description : 'Whether the static analyser(s) reported any findings.'
value : ${{ steps.parse.outputs.HAS_FINDINGS }}
2021-11-28 15:59:18 +01:00
result-log :
description : 'The file where the output of CodeChecker parse is written to verbatim.'
value : ${{ steps.parse.outputs.OUTPUT_LOG }}
2021-11-28 15:50:11 +01:00
result-html-dir :
description : 'The output directory where the user-friendly HTML reports were stored to.'
value : ${{ steps.parse.outputs.HTML_DIR }}
2021-11-29 16:22:28 +01:00
store-run-name :
description : 'The name of the analysis run that the results were uploaded to.'
value : ${{ steps.store-pre.outputs.RUN_NAME }}
2021-11-30 15:10:38 +01:00
store-successful :
description : 'Whether storing the analysis results to the configured server was successful. Useful for breaking the build in a later step if the store action is deemed mandatory.'
value : ${{ steps.store.outputs.SUCCESS }}
2021-11-29 16:22:28 +01:00
2021-11-27 11:18:56 +01:00
runs :
using : "composite"
steps :
2021-11-27 11:23:14 +01:00
- name : "Check out repository ${{ inputs.repository }}"
uses : actions/checkout@v2
2021-11-29 17:42:43 +01:00
if : ${{ inputs.install-custom == 'true' }}
2021-11-27 11:23:14 +01:00
with :
path : CodeChecker
2021-11-29 17:42:43 +01:00
repository : ${{ inputs.repository }}
2021-11-27 11:23:14 +01:00
ref : ${{ inputs.version }}
2021-11-29 17:42:43 +01:00
- name : "Install LLVM (${{ inputs.llvm-version }})"
2021-11-27 12:34:26 +01:00
id : llvm
if : ${{ inputs.llvm-version != 'ignore' }}
env :
2021-11-29 17:42:43 +01:00
IN_LLVM_VERSION : ${{ inputs.llvm-version }}
2021-11-27 12:34:26 +01:00
shell : bash
2021-11-29 17:42:43 +01:00
run : ${{ github.action_path }}/src/get-llvm.sh
2021-11-27 12:34:26 +01:00
2021-11-27 11:23:14 +01:00
- name : "Build and Package CodeChecker"
2021-11-27 12:34:26 +01:00
id : codechecker
2021-11-27 11:23:14 +01:00
env :
2021-11-29 16:22:28 +01:00
CODECHECKER_WILL_USE_WEB_API : ${{ inputs.store == 'true' }}
2021-11-29 17:42:43 +01:00
IN_INSTALL_CUSTOM : ${{ inputs.install-custom }}
IN_VERSION : ${{ inputs.version }}
2021-11-27 11:23:14 +01:00
shell : bash
2021-11-27 11:18:56 +01:00
run : |
2021-11-29 17:42:43 +01:00
set -x
if [[ "$IN_INSTALL_CUSTOM" == "true" ]]; then
${{ github.action_path }}/src/build-codechecker.sh
2021-11-27 11:23:14 +01:00
else
2021-11-29 17:42:43 +01:00
${{ github.action_path }}/src/pip-codechecker.sh
2021-11-27 11:23:14 +01:00
fi
2021-11-28 10:34:05 +01:00
- name : "Prepare JSON Compilation Database"
2021-11-28 14:31:07 +01:00
id : log
2021-11-28 10:34:05 +01:00
env :
2021-11-28 14:31:07 +01:00
ACTION_NAME : ${{ github.action }}
2021-11-28 10:34:05 +01:00
CODECHECKER_PATH : ${{ steps.codechecker.outputs.PATH }}
IN_LOGFILE : ${{ inputs.logfile }}
IN_COMMAND : ${{ inputs.build-command }}
2021-11-28 14:31:07 +01:00
OUT_FILE : ${{ github.workspace }}/${{ github.action }}_codechecker_compilation_database.json
2021-11-28 10:34:05 +01:00
shell : bash
run : ${{ github.action_path }}/src/get-or-create-build-json.sh
2021-11-28 14:31:07 +01:00
- name : "Execute static analysis"
id : analyze
env :
ACTION_NAME : ${{ github.action }}
CODECHECKER_PATH : ${{ steps.codechecker.outputs.PATH }}
COMPILATION_DATABASE : ${{ steps.log.outputs.COMPILATION_DATABASE }}
IN_CONFIGFILE : ${{ inputs.config }}
IN_CTU : ${{ inputs.ctu }}
IN_FLAGS : ${{ inputs.analyze-options }}
IN_OUTPUT_DIR : ${{ inputs.analyze-output }}
shell : bash
run : ${{ github.action_path }}/src/execute-analysis.sh
2021-11-28 15:50:11 +01:00
- name : "Parse and convert results"
id : parse
env :
PROJECT_PATH : ${{ github.workspace }}
CODECHECKER_PATH : ${{ steps.codechecker.outputs.PATH }}
RAW_RESULT_DIR : ${{ steps.analyze.outputs.OUTPUT_DIR }}
IN_CONFIGFILE : ${{ inputs.config }}
IN_OUTPUT_DIR : ${{ inputs.analyze-output }}
shell : bash
run : ${{ github.action_path }}/src/parse-results.sh
2021-11-29 16:22:28 +01:00
- name : "Generate the configuration for uploading results"
id : store-pre
if : ${{ inputs.store == 'true' }}
env :
IN_STORE_URL : ${{ inputs.store-url }}
IN_STORE_USERNAME : ${{ inputs.store-username }}
IN_STORE_PASSWORD : ${{ inputs.store-password }}
IN_STORE_RUN_NAME : ${{ inputs.store-run-name }}
GITHUB_REPOSITORY : ${{ github.repository }}
GITHUB_REF_NAME : ${{ github.ref_name }}
GITHUB_REF_TYPE : ${{ github.ref_type }}
GITHUB_SHA : ${{ github.sha }}
shell : bash
run : ${{ github.action_path }}/src/store-pre.sh
- name : "Store analysis results to server"
id : store
if : ${{ steps.store-pre.outputs.STORE_CONFIGURED == 'true' }}
env :
PROJECT_PATH : ${{ github.workspace }}
CODECHECKER_PATH : ${{ steps.codechecker.outputs.PATH }}
CODECHECKER_STORE_RUN_NAME : ${{ steps.store-pre.outputs.RUN_NAME }}
CODECHECKER_STORE_RUN_TAG : ${{ steps.store-pre.outputs.RUN_TAG }}
RAW_RESULT_DIR : ${{ steps.analyze.outputs.OUTPUT_DIR }}
IN_CONFIGFILE : ${{ inputs.config }}
IN_STORE_URL : ${{ inputs.store-url }}
shell : bash
run : ${{ github.action_path }}/src/store.sh