feat: Grab CodeChecker release from PyPI by default

This commit is contained in:
Whisperity
2021-11-29 17:42:43 +01:00
parent 3c9baf21be
commit 995207439b
7 changed files with 121 additions and 82 deletions

View File

@@ -12,30 +12,39 @@ on:
- '**.md'
jobs:
# Fetch tests do not produce results, but test the functionality of the
# "grab LLVM" and "grab and build CodeChecker" features.
fetch_ubuntu-2004_latest-llvm:
name: "Fetch: Ubuntu Linux 20.04 (latest LLVM)"
runs-on: ubuntu-20.04
fetch-tests:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
install-custom: true
version: v6.16.0
llvm-version: '12'
- os: ubuntu-20.04
install-custom: false
version: 6.17.0
llvm-version: '13'
- os: ubuntu-20.04
install-custom: true
version: master
llvm-version: 'latest'
- os: ubuntu-20.04
install-custom: false
version: master
llvm-version: 'latest'
name: "Fetch: ${{ matrix.os }}, LLVM ${{ matrix.llvm-version }}, ${{ matrix.install-custom && 'repository' || 'pip' }} ${{ matrix.version }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ./
id: codechecker
with:
version: "master"
llvm-version: "latest"
logfile: "test/empty/compile_commands.json"
fetch_ubuntu-1804_12-llvm:
name: "Fetch: Ubuntu Linux 18.04 (LLVM 12.y)"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: ./
with:
version: "master"
llvm-version: 12
install-custom: ${{ matrix.install-custom }}
version: ${{ matrix.version }}
llvm-version: ${{ matrix.llvm-version }}
logfile: "test/empty/compile_commands.json"
# Test simple build and analysis configuration.
simple-analysis-tests:
strategy:
fail-fast: false
@@ -169,7 +178,7 @@ jobs:
id: codechecker
continue-on-error: true
with:
version: "v${{ env.CODECHECKER_VERSION }}"
version: "${{ env.CODECHECKER_VERSION }}"
logfile: 'test/simple/compile_commands.json'
store: true
store-url: 'http://0.0.0.0:8001/Default'
@@ -179,7 +188,7 @@ jobs:
id: test
continue-on-error: true
run: docker logs codechecker-server | grep "stored results"
- name: "Teardown CodeChecker server"
- name: "Tear down CodeChecker server"
run: |
set -x

View File

@@ -106,9 +106,10 @@ runs:
### Versions to install
| Variable | Default | Description |
|----------------|------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `repository` | [`Ericsson/CodeChecker`](http://github.com/Ericsson/CodeChecker) | The CodeChecker repository to check out and build |
| `version` | `master` | The branch, tag, or commit SHA in the `repository` to use. |
|------------------|------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `install-custom` | `false` | If set to `true`, opens the ability to locally clone and install CodeChecker from the specified `repository` and `version`. Otherwise, `version` is taken as a release version, and the [CodeChecker suite from PyPI](http://pypi.org/project/codechecker) is downloaded. |
| `repository` | [`Ericsson/CodeChecker`](http://github.com/Ericsson/CodeChecker) | The CodeChecker repository to check out and build, if `install-custom` is `true`. |
| `version` | `master` | If `install-custom` is `false`, the release version (e.g. `6.18.0`) to download from PyPI, or `master` to fetch the latest release. Otherwise, the branch (defaulting to `master`), tag, or commit SHA in the `repository` to check out. |
| `llvm-version` | `latest` | The major version of LLVM to install and use. LLVM is installed from [PPA](http://apt.llvm.org/). If `latest`, automatically gather the latest version. If `ignore`, don't install anything. (Not recommended) |
### Build log configuration

View File

@@ -6,12 +6,16 @@ branding:
color: 'blue'
inputs:
install-custom:
description: 'Whether to download, check out, and build a CodeChecker package manually in the CI.'
required: true
default: 'false'
repository:
description: 'The CodeChecker repository to check out and build from.'
required: true
default: 'Ericsson/CodeChecker'
version:
description: 'The version of the CodeChecker suite to obtain and execute. Might be a Git commit SHA, a branch name, or a tag.'
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.'
required: true
default: 'master'
llvm-version:
@@ -32,24 +36,24 @@ inputs:
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.'
default: ''
required: false
default: ''
ctu:
description: 'Whether to enable Cross Translation Unit (CTU) analysis in the Clang Static Analyzer.'
default: 'false'
required: true
default: 'false'
fail-build-if-reports:
description: 'Whether to fail the build if static analysis warnings are emitted.'
default: 'false'
required: true
default: 'false'
store:
description: 'Whether to enable storing the results to a CodeChecker server. If enabled, other flags, such as `store-url` must also be set.'
default: 'false'
description: 'Whether to enable storing the results to a CodeChecker server. If enabled, other flags, such as "store-url" must also be set.'
required: true
default: 'false'
store-url:
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.'
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.'
required: false
store-username:
description: 'If the server requires authentication, the username to authenticate with.'
@@ -59,8 +63,8 @@ inputs:
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.'
default: '__DEFAULT__'
required: true
default: '__DEFAULT__'
outputs:
logfile:
@@ -90,61 +94,36 @@ runs:
steps:
- name: "Check out repository ${{ inputs.repository }}"
uses: actions/checkout@v2
if: ${{ inputs.install-custom == 'true' }}
with:
repository: ${{ inputs.repository }}
path: CodeChecker
repository: ${{ inputs.repository }}
ref: ${{ inputs.version }}
- name: "Install dependencies of CodeChecker"
shell: bash
run: |
sudo apt-get -qy update
${{ github.action_path }}/src/apt-dependencies.sh
- name: "Install LLVM version"
- name: "Install LLVM (${{ inputs.llvm-version }})"
id: llvm
if: ${{ inputs.llvm-version != 'ignore' }}
env:
CONFIGURED_LLVM_VERSION: ${{ inputs.llvm-version }}
IN_LLVM_VERSION: ${{ inputs.llvm-version }}
shell: bash
run: |
${{ github.action_path }}/src/get-llvm.sh
echo "::set-output name=REAL_VERSION::$(clang --version | head -n 1 | cut -d' ' -f4-)"
run: ${{ github.action_path }}/src/get-llvm.sh
- name: "Build and Package CodeChecker"
id: codechecker
env:
CODECHECKER_WILL_USE_WEB_API: ${{ inputs.store == 'true' }}
IN_INSTALL_CUSTOM: ${{ inputs.install-custom }}
IN_VERSION: ${{ inputs.version }}
shell: bash
run: |
set -ex
if [[ "$CODECHECKER_WILL_USE_WEB_API" == "false" ]]; then
# If the job is only running analysis, do not spend time with building the API stuff!
echo "Building only 'analyzer' module..."
pushd CodeChecker/analyzer
set -x
if [[ "$IN_INSTALL_CUSTOM" == "true" ]]; then
${{ github.action_path }}/src/build-codechecker.sh
else
echo "Building full CodeChecker package..."
pushd CodeChecker
${{ github.action_path }}/src/pip-codechecker.sh
fi
make venv
source venv/bin/activate
BUILD_UI_DIST=NO make standalone_package
deactivate
./build/CodeChecker/bin/CodeChecker analyzer-version
if [[ "$CODECHECKER_WILL_USE_WEB_API" == "true" ]]; then
./build/CodeChecker/bin/CodeChecker web-version
else
echo "CodeChecker 'web' package not built."
fi
echo "::set-output name=PATH::$(readlink -f ./build/CodeChecker/bin)"
echo "::set-output name=VERSION::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')"
echo "::set-output name=GITSEVEN::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)"
popd
- name: "Prepare JSON Compilation Database"
id: log
env:

View File

@@ -1,9 +0,0 @@
#!/bin/bash
set -x
sudo apt-get -y --no-install-recommends install \
build-essential \
curl \
gcc-multilib \
python3-dev \
python3-venv

37
src/build-codechecker.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -ex
sudo apt-get -y update
sudo apt-get -y --no-install-recommends install \
build-essential \
curl \
gcc-multilib \
python3-dev \
python3-venv
if [[ "$CODECHECKER_WILL_USE_WEB_API" == "false" ]]; then
# If the job is only running analysis, do not spend time with building the API stuff!
echo "Building only 'analyzer' module..."
pushd CodeChecker/analyzer
else
echo "Building full CodeChecker package..."
pushd CodeChecker
fi
make venv
source venv/bin/activate
BUILD_UI_DIST=NO make standalone_package
deactivate
./build/CodeChecker/bin/CodeChecker analyzer-version
if [[ "$CODECHECKER_WILL_USE_WEB_API" == "true" ]]; then
./build/CodeChecker/bin/CodeChecker web-version
else
echo "CodeChecker 'web' package not built."
fi
echo "::set-output name=PATH::$(readlink -f ./build/CodeChecker/bin)"
echo "::set-output name=VERSION::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')"
echo "::set-output name=GITSEVEN::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)"
popd

View File

@@ -4,13 +4,13 @@ set -ex
export DISTRO_FANCYNAME="$(lsb_release -c | awk '{ print $2 }')"
curl -sL http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
if [[ "$CONFIGURED_LLVM_VERSION" == "latest" ]]; then
if [[ "$IN_LLVM_VERSION" == "latest" ]]; then
sudo add-apt-repository -y "deb http://apt.llvm.org/$DISTRO_FANCYNAME/ llvm-toolchain-$DISTRO_FANCYNAME main"
# Get the largest Clang package number available.
export LLVM_VER="$(apt-cache search --full 'clang-[[:digit:]]*$' | grep '^Package: clang' | cut -d ' ' -f 2 | sort -V | tail -n 1 | sed 's/clang-//')"
else
sudo add-apt-repository -y "deb http://apt.llvm.org/$DISTRO_FANCYNAME/ llvm-toolchain-$DISTRO_FANCYNAME-$CONFIGURED_LLVM_VERSION main"
export LLVM_VER="$CONFIGURED_LLVM_VERSION"
sudo add-apt-repository -y "deb http://apt.llvm.org/$DISTRO_FANCYNAME/ llvm-toolchain-$DISTRO_FANCYNAME-$IN_LLVM_VERSION main"
export LLVM_VER="$IN_LLVM_VERSION"
fi
sudo apt-get -y --no-install-recommends install \
@@ -21,3 +21,5 @@ sudo update-alternatives --install \
--slave \
/usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$LLVM_VER
update-alternatives --query clang
echo "::set-output name=REAL_VERSION::$(clang --version | head -n 1 | cut -d' ' -f4-)"

20
src/pip-codechecker.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
set -x
if [[ "$IN_VERSION" == "master" ]]; then
# The default branch name "master" is offered as a convenient shortcut for
# fetching the latest release.
pip3 install codechecker
else
pip3 install codechecker=="$IN_VERSION"
fi
pip3 show codechecker
which CodeChecker
CodeChecker analyzer-version
CodeChecker web-version
echo "::set-output name=PATH::$(dirname $(which CodeChecker))"
echo "::set-output name=VERSION::$(CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')"
echo "::set-output name=GITSEVEN::$(CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)"