From 4275f57d4b6902fc3e46b9b83625dcb8c0b79187 Mon Sep 17 00:00:00 2001 From: Jan Kolarik Date: Mon, 13 Jan 2025 13:29:34 +0100 Subject: [PATCH] GitHub workflows: Add Coverity Scan and refactoring --- .github/workflows/build-and-tests.yml | 28 ++++++++++++++++++ .github/workflows/build-prepare.yml | 22 ++++++++++++++ .github/workflows/cmake-workflow.yml | 28 ------------------ .github/workflows/coverity-scan.yml | 41 +++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/build-and-tests.yml create mode 100644 .github/workflows/build-prepare.yml delete mode 100644 .github/workflows/cmake-workflow.yml create mode 100644 .github/workflows/coverity-scan.yml diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml new file mode 100644 index 0000000..16f6f3e --- /dev/null +++ b/.github/workflows/build-and-tests.yml @@ -0,0 +1,28 @@ +name: CMake Build And Tests + +on: + pull_request: + branches: [ "main" ] + workflow_dispatch: + inputs: + build_type: + description: 'Build type (e.g., Debug, Release)' + required: true + default: 'Release' + +jobs: + prepare: + uses: ./.github/workflows/build-prepare.yml + with: + build_type: ${{ inputs.build_type }} + + build: + runs-on: ubuntu-24.04 + needs: prepare + steps: + - name: Build + run: cmake --build build --config ${{ inputs.build_type }} + + - name: Tests + working-directory: ${{ github.workspace }}/build + run: ctest -V --test-dir test diff --git a/.github/workflows/build-prepare.yml b/.github/workflows/build-prepare.yml new file mode 100644 index 0000000..7979628 --- /dev/null +++ b/.github/workflows/build-prepare.yml @@ -0,0 +1,22 @@ +# This reusable workflow prepares the build environment and can be invoked by other workflows. +name: CMake Build Prepare + +on: + workflow_call: + inputs: + build_type: + type: string + required: true + description: 'Type of the build. Default is Release.' + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Install Dependencies + run: sudo apt install libgmock-dev libgtest-dev libyaml-cpp-dev swig -y + + - name: Configure + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} diff --git a/.github/workflows/cmake-workflow.yml b/.github/workflows/cmake-workflow.yml deleted file mode 100644 index 91566b6..0000000 --- a/.github/workflows/cmake-workflow.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: CMake Build And Tests - -on: - pull_request: - branches: [ "main" ] - -env: - BUILD_TYPE: Release - -jobs: - build: - runs-on: ubuntu-24.04 - - steps: - - uses: actions/checkout@v4 - - - name: Install Dependencies - run: sudo apt install libgmock-dev libgtest-dev libyaml-cpp-dev swig -y - - - name: Configure - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Tests - working-directory: ${{github.workspace}}/build - run: ctest -V --test-dir test diff --git a/.github/workflows/coverity-scan.yml b/.github/workflows/coverity-scan.yml new file mode 100644 index 0000000..1299d51 --- /dev/null +++ b/.github/workflows/coverity-scan.yml @@ -0,0 +1,41 @@ +name: Coverity Scan + +on: + workflow_dispatch: + inputs: + build_type: + description: 'Build type (e.g., Debug, Release)' + required: true + default: 'Release' + +jobs: + prepare: + uses: ./.github/workflows/build-prepare.yml + with: + build_type: ${{ inputs.build_type }} + + coverity-scan: + runs-on: ubuntu-24.04 + needs: prepare + env: + COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }} + steps: + - name: Set up Coverity Scan + run: | + wget https://scan.coverity.com/download/linux64 --post-data "token=${COVERITY_TOKEN}&project=rpm-software-management%2Flibpkgmanifest" -O coverity_tool.tgz + tar -xzvf coverity_tool.tgz + + - name: Build with Coverity + run: | + cd ${{ github.workspace }}/build + ../cov-analysis-*/bin/cov-build --dir cov-int make -j$(nproc) + + - name: Upload Coverity results + run: | + tar czvf cov-int.tgz cov-int + curl --form token=${COVERITY_TOKEN} \ + --form email=jkolarik@redhat.com \ + --form file=@cov-int.tgz \ + --form version=`git log --oneline -1 | awk '{ print $1;}'` \ + --form description="libpkgmanifest - Library for working with RPM manifests" \ + https://scan.coverity.com/builds?project=rpm-software-management%2Flibpkgmanifest