summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 60f296b1db177e062411b3d35659b7d416b15d2c (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: CI

on:
  push:
  pull_request:
  schedule:
    - cron: '22 9 * * 2'

env:
  WEECHAT_DEPENDENCIES: >-
    asciidoctor
    cmake
    curl
    devscripts
    equivs
    flake8
    gem2deb
    guile-3.0-dev
    lcov
    libargon2-dev
    libaspell-dev
    libcjson-dev
    libcpputest-dev
    libcurl4-gnutls-dev
    libgcrypt20-dev
    libgnutls28-dev
    liblua5.3-dev
    libncurses-dev
    libperl-dev
    libphp-embed
    libsodium-dev
    libv8-dev
    libzstd-dev
    ninja-build
    php-dev
    pkg-config
    pylint
    python3-bandit
    python3-dev
    python3-pip
    ruby-pygments.rb
    shellcheck
    tcl8.6-dev
    zlib1g-dev

jobs:

  tests_linux:

    strategy:
      matrix:
        os:
          - ubuntu-22.04
        config:
          - { name: "gcc", cc: "gcc", cxx: "g++", buildargs: "" }
          - { name: "gcc_ninja", cc: "gcc", cxx: "g++", buildargs: "-G Ninja" }
          - { name: "gcc_no_nls", cc: "gcc", cxx: "g++", buildargs: "-DENABLE_NLS=OFF -DENABLE_DOC=OFF" }
          - { name: "gcc_no_zstd", cc: "gcc", cxx: "g++", buildargs: "-DENABLE_ZSTD=OFF -DENABLE_DOC=OFF" }
          - { name: "gcc_no_cjson", cc: "gcc", cxx: "g++", buildargs: "-DENABLE_CJSON=OFF -DENABLE_DOC=OFF" }
          - { name: "gcc_coverage", cc: "gcc", cxx: "g++", buildargs: "-DENABLE_CODE_COVERAGE=ON" }
          - { name: "clang", cc: "clang", cxx: "clang++", buildargs: "" }

    name: "Tests: ${{ matrix.config.name }} on ${{ matrix.os }}"
    runs-on: ${{ matrix.os }}

    steps:

    - uses: actions/checkout@v2

    - name: Install dependencies
      run: |
        sudo apt-get update -qq
        sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPENDENCIES }}
        # uninstall php imagick as is causes a crash when loading php plugin (see #2009)
        sudo apt-get --yes purge php8.1-imagick
        sudo -H pip3 install --ignore-installed msgcheck

    - name: Check gettext files
      run: msgcheck po/*.po

    - name: Check shell and Python scripts
      run: ./tools/check_scripts.sh

    - name: Check Python stub file
      run: ./tools/generate_python_stub.py | diff src/plugins/python/weechat.pyi -

    - name: Check Curl symbols
      run: curl --silent --show-error --fail --retry 10 https://raw.githubusercontent.com/curl/curl/master/docs/libcurl/symbols-in-versions | ./tools/check_curl_symbols.py

    - name: Build and run tests
      env:
        CC: ${{ matrix.config.cc }}
        CXX: ${{ matrix.config.cxx }}
        BUILDARGS: ${{ matrix.config.buildargs }}
      run: ./tools/build_test.sh

    - name: Run WeeChat
      env:
        TERM: xterm-256color
      run: |
        weechat --help
        weechat-curses --help
        weechat --colors
        weechat --license
        weechat --version
        weechat --run-command "/debug dirs;/debug libs" --run-command "/quit"

    - name: Code coverage
      if: ${{ matrix.config.name == 'gcc_coverage' }}
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      run: |
        cd build-tmp-*
        lcov --directory . --capture --output-file coverage.info
        lcov --remove coverage.info '/usr/*' --output-file coverage.info
        lcov --list coverage.info
        bash <(curl -s https://codecov.io/bash) -f coverage.info || echo 'Codecov error'

  tests_macos:

    strategy:
      matrix:
        os:
          - macos-12
        config:
          - { name: "gcc", cc: "gcc", cxx: "g++" }
          - { name: "clang", cc: "clang", cxx: "clang++" }

    name: "Tests: ${{ matrix.config.name }} on ${{ matrix.os }}"
    runs-on: ${{ matrix.os }}

    steps:

    - name: Setup Homebrew
      id: setup-homebrew
      uses: Homebrew/actions/setup-homebrew@master

    - name: Install dependencies
      run: |
        brew update
        # temporary fix, see: https://github.com/actions/setup-python/issues/577
        rm -f \
          /usr/local/bin/2to3 \
          /usr/local/bin/idle3 \
          /usr/local/bin/pydoc3 \
          /usr/local/bin/python3 \
          /usr/local/bin/python3-config \
          /usr/local/bin/2to3-3.11 \
          /usr/local/bin/idle3.11 \
          /usr/local/bin/pydoc3.11 \
          /usr/local/bin/python3.11 \
          /usr/local/bin/python3.11-config \
        ;
        brew install asciidoctor cjson guile lua pkg-config ruby

    - uses: actions/checkout@v2

    - name: Build
      env:
        CC: ${{ matrix.config.cc }}
        CXX: ${{ matrix.config.cxx }}
      run: |
        mkdir build-tmp && cd build-tmp
        cmake .. -DENABLE_MAN=ON -DENABLE_DOC=ON -DENABLE_DOC_INCOMPLETE=ON -DENABLE_PHP=OFF
        make VERBOSE=1 -j2
        sudo make install

    - name: Run WeeChat
      env:
        TERM: xterm-256color
      run: |
        weechat --help
        weechat-curses --help
        weechat --colors
        weechat --license
        weechat --version
        weechat --run-command "/debug dirs;/debug libs" --run-command "/quit"

  build_debian:

    strategy:
      matrix:
        os:
          - ubuntu-22.04

    name: "Build Debian on ${{ matrix.os }}"
    runs-on: ${{ matrix.os }}

    steps:

    - uses: actions/checkout@v2

    - name: Install dependencies
      run: |
        sudo apt-get update -qq
        sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPENDENCIES }}

    - name: Test Debian patches
      run: ./tools/build_debian.sh test-patches

    - name: Build Debian packages
      run: ./tools/build_debian.sh devel ubuntu/jammy

    - name: Install Debian packages
      run: sudo dpkg -i ../weechat-devel*.deb

    - name: Run WeeChat
      env:
        TERM: xterm-256color
      run: |
        weechat --help
        weechat-curses --help
        weechat --version
        weechat --run-command "/debug dirs;/debug libs" --run-command "/quit"

  codeql-analysis:

    name: CodeQL
    runs-on: ubuntu-latest

    permissions:
      actions: read
      contents: read
      security-events: write

    steps:

    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Install dependencies
      run: |
        sudo apt-get update -qq
        sudo apt-get --yes --no-install-recommends install ${{ env.WEECHAT_DEPENDENCIES }}
        # uninstall php imagick as is causes a crash when loading php plugin (see #2009)
        sudo apt-get --yes purge php8.1-imagick
        sudo -H pip3 install --ignore-installed msgcheck

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: cpp

    - name: Autobuild
      uses: github/codeql-action/autobuild@v3

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v3
      with:
        category: "/language:cpp"