Wire in downloading and installing LLVM from PPA

This commit is contained in:
Whisperity
2021-11-27 12:34:26 +01:00
parent d8995ef956
commit dda589380f
5 changed files with 84 additions and 21 deletions

View File

@@ -8,11 +8,21 @@ on:
- 'releases/*'
jobs:
ubuntu_2004:
name: "Ubuntu Linux 20.04"
ubuntu_2004_latestllvm:
name: "Ubuntu Linux 20.04 (latest LLVM)"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./
with:
version: "master"
llvm-version: "latest"
ubuntu_1804_12llvm:
name: "Ubuntu Linux 18.04 (LLVM 12.y)"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: ./
with:
version: "master"
llvm-version: 12

View File

@@ -6,14 +6,20 @@ Objective-C) using the [Clang](http://clang.llvm.org/) infrastructure and
## Overview
:warning: **This action has been written with commands that target Ubuntu-based distributions!**
⚠️ **CAUTION! This action has been written with commands that target Ubuntu-based distributions!**
This single action composite script encompasses the following steps:
1. Obtain a package of the LLVM Clang suite's analysers, and CodeChecker.
## Action configuration
### Installing versions
### 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. |
| `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) |

View File

@@ -1,6 +1,10 @@
name: 'CodeChecker Static Analysis'
author: 'Whisperity'
description: 'Execute C/C++ static analysis of LLVM/Clang (Clang Static Analyzer and Clang-Tidy) driven via CodeChecker.'
branding:
icon: 'tool'
color: 'blue'
inputs:
repository:
description: 'The CodeChecker repository to check out and build from.'
@@ -10,6 +14,11 @@ inputs:
description: 'The version of the CodeChecker suite to obtain and execute. Might be a Git commit SHA, a branch name, or a tag.'
required: true
default: 'master'
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'
runs:
using: "composite"
steps:
@@ -20,23 +29,29 @@ runs:
path: CodeChecker
ref: ${{ inputs.version }}
- name: "Install dependencies of CodeChecker"
shell: bash
run: |
sudo apt-get -qy update
sudo apt-get -y --no-install-recommends install \
build-essential \
curl \
gcc-multilib \
python3-dev \
python3-venv
- name: "Build and Package CodeChecker"
id: codechecker_build
${{ github.action_path }}/src/apt-dependencies.sh
- name: "Install LLVM version"
id: llvm
if: ${{ inputs.llvm-version != 'ignore' }}
env:
CODECHECKER_WILL_USE_WEB_API: false
CONFIGURED_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-)"
- name: "Build and Package CodeChecker"
id: codechecker
env:
CODECHECKER_WILL_USE_WEB_API: false # TODO: Add support for this later.
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..."
@@ -58,8 +73,8 @@ runs:
echo "CodeChecker 'web' package not built."
fi
echo "::set-output name=CODECHECKER_PATH::$(readlink -f ./build/CodeChecker/bin)"
echo "::set-output name=CODECHECKER_VERSION::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Base package' | cut -d'|' -f 2 | tr -d ' ')"
echo "::set-output name=CODECHECKER_GITSEVEN::$(./build/CodeChecker/bin/CodeChecker analyzer-version | grep 'Git commit' | cut -d'|' -f 2 | cut -c 2-8)"
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

9
src/apt-dependencies.sh Executable file
View File

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

23
src/get-llvm.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
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
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"
fi
sudo apt-get -y --no-install-recommends install \
clang-$LLVM_VER \
clang-tidy-$LLVM_VER
sudo update-alternatives --install \
/usr/bin/clang clang /usr/bin/clang-$LLVM_VER 1000 \
--slave \
/usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$LLVM_VER
update-alternatives --query clang