aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/linters.yml
blob: c6a238fd230edc199330cf7e88453ec767fb8ac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: linters

on:
  push:
    branches: [ 3.6.x ]
  pull_request:
    branches: [ 3.6.x ]

jobs:
  shellcheck:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install linters on ubuntu
        run: |
          sudo apt-get update -q -y
          sudo apt-get install shellcheck

      - name: run Shellcheck
        run: |
          find . -name "*.sh" | xargs shellcheck -e SC1004,SC2010,SC2035,SC2086

  cppcheck:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install linters on ubuntu
        run: |
          sudo apt-get update -q -y
          sudo apt-get install cppcheck

      - name: run cppcheck
        run: |
          # cppcheck
          if ! [ -x "$(command -v cppcheck)" ]; then
            echo 'Error: cppcheck is not installed.' >&2
            exit 1
          fi
          CPPCHECK_OPTS='--error-exitcode=0 --force --quiet --suppressions-list=./static-analysis-suppressions'
          # we exclude some external projects
          CPPCHECK_EXCLUDES='-i ./nx-X11/extras/ -i nx-X11/programs/Xserver/GL/mesa* -i ./.pc -i ./nx-X11/.build-exports -i ./nx-X11/exports -i ./doc'
          echo "$(cppcheck --version):";
          cppcheck $CPPCHECK_OPTS $CPPCHECK_EXCLUDES .;
  pvs:
    environment: pvs
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install linters on ubuntu
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          sudo apt-get update -qq -y
          # compiler
          sudo apt-get install -qq -y gcc g++
          # basic packages
          sudo apt-get install -qq -y \
            autoconf libtool make pkg-config
          # imake deps
          sudo apt-get install -qq -y \
            libxkbfile-dev xfonts-utils xutils-dev
          # X11 libraries deps
          sudo apt-get install -qq -y \
            libpixman-1-dev libjpeg-dev libxcomposite-dev libxdamage-dev \
            libxml2-dev libxfont-dev libxinerama-dev libxpm-dev libxrandr-dev \
            libxtst-dev x11proto-fonts-dev
          # soft requirements
          sudo apt-get install -qq -y \
            quilt x11-xkb-utils
          # PVS
          sudo wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -
          sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list
          sudo apt-get update -qq
          sudo apt-get install -qq pvs-studio

      - name: Run PVS-Studio Analyzer
        shell: bash
        env:
          PVS_USERNAME: ${{ secrets.PVS_USERNAME }}
          PVS_KEY: ${{ secrets.PVS_KEY }}
        run: |
          # check environment variables
          if [[ -z "${PVS_USERNAME}" ]]; then
            echo '"PVS_USERNAME" environment variable not set'
            exit 0
          elif [[ -z "${PVS_KEY}" ]]; then
            echo '"PVS_KEY" environment variable not set'
            exit 0
          else
            pvs-studio-analyzer credentials -o "PVS-Studio.lic" "${PVS_USERNAME}" "${PVS_KEY}"
            pvs-studio-analyzer trace -- make
            pvs-studio-analyzer analyze --quiet --lic-file "PVS-Studio.lic" --output-file "PVS-Studio-${CC}.log"
            plog-converter -a "GA:1,2" -t tasklist -o "PVS-Studio-${CC}.tasks" "PVS-Studio-${CC}.log"
            cat "PVS-Studio-${CC}.tasks"
          fi