Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to perform a weekly coverity scan build. #143

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/coverity-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Coverity Scan

on:
workflow_dispatch:
schedule:
- cron: '0 4 * * 1' ## every Monday morning

env:
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
COVERITY_SCAN_EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }}
COVERITY_PROJECT: GNS3/dynamips
COV_TOOLS_DIR: ${{ github.workspace }}/cov-analysis-linux64
COV_BUILD_DIR: ${{ github.workspace }}/coverity-build
COV_RESULTS_DIR: cov-int
COV_RESULTS_FILE: analysis-results.tgz

jobs:
coverity_scan:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Set up environment
run: |
sudo apt-get -yq update
sudo apt-get -yq install libelf-dev libpcap0.8-dev

- name: Download and install Coverity Build Tool
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 \
--post-data "token=${COVERITY_SCAN_TOKEN}&project=${COVERITY_PROJECT}" \
-O cov-analysis-linux64.tar.gz
mkdir ${COV_TOOLS_DIR}
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C ${COV_TOOLS_DIR}

- name: Prepare CMake build
run: |
mkdir ${COV_BUILD_DIR}
cd ${COV_BUILD_DIR}
cmake ${CMAKE_BUILD_OPTIONS} ..
env:
CMAKE_BUILD_OPTIONS: "-DCMAKE_BUILD_TYPE=Release -DDYNAMIPS_CODE=both"

- name: Run Coverity Scan Analysis Tool
run: |
export PATH=${COV_TOOLS_DIR}/bin:$PATH
cd ${COV_BUILD_DIR}
cov-build --dir ${COV_RESULTS_DIR} make -j 2
cov-import-scm --dir ${COV_RESULTS_DIR} --scm git --log ${COV_RESULTS_DIR}/scm-log.txt 2>&1

- name: Upload Coverity Scan Analysis results
run: |
cd ${COV_BUILD_DIR}
tar czf ${COV_RESULTS_FILE} ${COV_RESULTS_DIR}
curl \
--form project=${COVERITY_PROJECT} \
--form token=${COVERITY_SCAN_TOKEN} \
--form email=${COVERITY_SCAN_EMAIL} \
--form file=@${COV_RESULTS_FILE} \
--form version=${GITHUB_SHA} \
--form description="GitHub Action - Coverity Scan" \
https://scan.coverity.com/builds?project=${COVERITY_PROJECT}

- name: Upload scan logs as artifacts
uses: actions/upload-artifact@v2
with:
name: scan-logs
path: |
${{ env.COV_BUILD_DIR }}/${{ env.COV_RESULTS_DIR }}/scm-log.txt
${{ env.COV_BUILD_DIR }}/${{ env.COV_RESULTS_DIR }}/build-log.txt
Loading