# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: klocwork
on:
  # Manually run this workflow on any specified branch.
  workflow_dispatch:

env:
  PROJECT_NAME: hexl_github-ci

jobs:
  klocwork:
    name: klocwork scan
    runs-on: [self-hosted, Linux, X64, ice-lake]
    steps:
      - uses: actions/checkout@v2
      - name: Setup
        run: |
          mkdir build
          cmake -S . -B build

      - name: Build Klocwork Project
        run: |
          kwinject make

          # kwbuildproject may have non-zero exit
          # Build errors will be logged and accessible on server
          kwbuildproject --url ${{ secrets.KLOCWORK_SERVER }}/${{ env.PROJECT_NAME }} kwinject.out --tables-directory tables
        continue-on-error: true
        working-directory: ./build

      - name: Upload Klocwork Results
        run: |
          # Add checkerset
          kwadmin --url ${{ secrets.KLOCWORK_SERVER }} import-config ${{ env.PROJECT_NAME }} ~/KW21-1_Checker_Set.pconf
          kwadmin --url ${{ secrets.KLOCWORK_SERVER }} load ${{ env.PROJECT_NAME }} tables
        working-directory: ./build
