name: cppcheck-premium

on:
  push:
    branches:
      - 'main'
      - 'releases/**'
    tags:
      - '2.*'
  pull_request:

permissions:
  contents: read

jobs:

  build:
    runs-on: ubuntu-22.04 # run on the latest image only

    env:
      PREMIUM_VERSION: devdrop-20231105

    steps:
      - uses: actions/checkout@v3

      - name: Download cppcheckpremium
        run: |
          wget https://files.cppchecksolutions.com/cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
          tar xzf cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz

      - name: Generate a license file
        run: |
          echo cppcheck > cppcheck.lic
          echo 231231 >> cppcheck.lic
          echo 80000 >> cppcheck.lic
          echo 57e08c39523ab54d >> cppcheck.lic
          echo path:lib >> cppcheck.lic

      - name: Check
        run: |
          cppcheckpremium-${{ env.PREMIUM_VERSION }}/premiumaddon --check-loc-license cppcheck.lic > cppcheck-premium-loc
          cppcheckpremium-${{ env.PREMIUM_VERSION }}/cppcheck -j$(nproc) -D__GNUC__ -D__CPPCHECK__ --suppressions-list=cppcheckpremium-suppressions --platform=unix64 --enable=style --premium=misra-c++-2008 --premium=cert-c++-2016 --error-exitcode=1 lib