summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: 1d54b6583e4f8939c47e20b278301ed38d607317 (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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
name: CI Build

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
  workflow_dispatch:

# cancel already running builds of the same branch or pull request
concurrency:
  group: ci-${{ github.head_ref }} || concat(${{ github.ref }}
  cancel-in-progress: true

env:
  MATE_PANEL_DEP: 1.27.1
  CONFIGURE_FLAGS: --enable-compile-warnings=maximum
  CFLAGS: -g -O2 -Werror=pointer-arith -Werror=implicit-function-declaration
  JOBS: 2
  DEBUG: 1
  # Useful URL: https://github.com/mate-desktop/debian-packages
  # Useful URL: https://salsa.debian.org/debian-mate-team/mate-panel
  DEB_LIBRARY_DEPS: |
    libatk1.0-dev
    libcairo2-dev
    libdconf-dev
    libgirepository1.0-dev
    libglib2.0-dev
    libgtk-3-dev
    libgtk-layer-shell-dev
    libice-dev
    libmate-desktop-dev
    libmate-menu-dev
    libmateweather-dev
    libpango1.0-dev
    libsm-dev
    libsoup2.4-dev
    libwnck-3-dev
    libx11-dev
    libxrandr-dev
  # mate-desktop dependencies
  DEB_LIBRARY_DEPS_MATE_DESKTOP: |
    libgirepository1.0-dev
  DEB_BUILD_DEPS: |
    ccache
    autoconf-archive
    autopoint
    gir1.2-freedesktop
    git
    gobject-introspection
    gtk-doc-tools
    lsb-release
    make
    mate-common
    meson
    yelp-tools
  # mate-desktop dependencies
  DEB_BUILD_DEPS_MATE_DESKTOP: |
    iso-codes
    gobject-introspection
  # TODO
  DEB_SCAN_BUILD_DEPS: |
    clang
    clang-tools
  # Useful URL: https://git.archlinux.org/svntogit/community.git/tree/mate-panel
  ARCH_BUILD_DEPS: |
    ccache
    autoconf-archive
    clang
    gcc
    git
    gobject-introspection
    gtk-layer-shell
    itstool
    libcanberra
    libmateweather
    libsm
    libwnck3
    make
    mate-common
    mate-desktop
    mate-menus
    meson
    which
    yelp-tools
  # mate-desktop dependencies
  ARCH_BUILD_DEPS_MATE_DESKTOP: |
    iso-codes
    gobject-introspection

jobs:
  build:
    name: Build on ${{matrix.container}} with in-process=${{matrix.in-process}} (using ${{matrix.cc}})
    runs-on: ubuntu-latest
    container: ${{matrix.container}}

    strategy:
      fail-fast: false  # don't cancel other jobs in the matrix if one fails
      matrix:
        in-process: [all, none]
        container: ['debian:testing', 'ubuntu:rolling', 'archlinux:latest']
        cc: ['gcc']
        cxx: ['g++']
        include:
          # test with clang on archlinux:latest
          - container: 'archlinux:latest'
            cc: 'clang'
            cxx: 'clang++'
            in-process: all
          - container: 'archlinux:latest'
            cc: 'clang'
            cxx: 'clang++'
            in-process: none

    env:
      # Speed up build with ccache
      CC: ccache ${{matrix.cc}}
      CXX: ccache ${{matrix.cxx}}
      # root install path for the mate-desktop dependency
      MATE_DESKTOP_INSTALL_PATH: ${{github.workspace}}/mate-desktop-install

    steps:
      # We can't *extend* the environment in 'env' directly, so use GITHUB_ENV
      # output variable to do so.
      - name: Setup environment
        run: |
          echo "PATH=${MATE_DESKTOP_INSTALL_PATH}/bin:${PATH}" >> "$GITHUB_ENV"
          echo "PKG_CONFIG_PATH=${MATE_DESKTOP_INSTALL_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}" >> "$GITHUB_ENV"

      # Debugging
      - name: Show environment
        run: env | sort
        if: ${{ env.DEBUG == '1' }}

      # For Debian and Ubuntu (apt-based with reasonably compatible packages)
      - name: Install dependencies
        if: ${{ startsWith(matrix.container, 'debian:') || startsWith(matrix.container, 'ubuntu:') }}
        run: |
          apt-get update -qq
          apt-get install --assume-yes --no-install-recommends \
            ${DEB_BUILD_DEPS} ${DEB_BUILD_DEPS_MATE_DESKTOP} \
            ${DEB_LIBRARY_DEPS} ${DEB_LIBRARY_DEPS_MATE_DESKTOP}

      # For ArchLinux
      - name: Install dependencies
        if: ${{ startsWith(matrix.container, 'archlinux:') }}
        # don't upgrade, although told otherwise (see link below), because
        # apparently in the container it doesn't quit work...
        # https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported
        run: |
          pacman --noconfirm -Syu
          pacman --noconfirm -S ${ARCH_BUILD_DEPS} ${ARCH_BUILD_DEPS_MATE_DESKTOP}

      # Checkout the repository
      - uses: actions/checkout@v3
        with:
          path: mate-panel
          submodules: true

      # Setup ccache cache
      - name: ccache
        uses: hendrikmuhs/ccache-action@v1.2

      # Cache the build of the mate-desktop dependency
      - name: Cache mate-desktop v${{env.MATE_PANEL_DEP}} dependency
        uses: actions/cache@v3
        id: cache-mate-desktop
        with:
          path: ${{env.MATE_DESKTOP_INSTALL_PATH}}
          # We try and be as specific as possible not to use the wrongly cached
          # build, as this is a *binary*.
          key: ${{runner.os}}-${{runner.arch}}-${{matrix.container}}-build-mate-desktop-${{env.MATE_PANEL_DEP}}

      # Checkout mate-desktop dep, if not already cached
      - name: Checkout mate-desktop v${{env.MATE_PANEL_DEP}}
        uses: actions/checkout@v3
        if: ${{ steps.cache-mate-desktop.outputs.cache-hit != 'true' }}
        with:
          repository: mate-desktop/mate-desktop
          ref: v${{env.MATE_PANEL_DEP}}
          path: mate-desktop
          submodules: true

      # Build and install mate-desktop dep, if not already cached
      - name: Install mate-desktop v${{env.MATE_PANEL_DEP}}
        if: ${{ steps.cache-mate-desktop.outputs.cache-hit != 'true' }}
        run: |
          cd mate-desktop
          NOCONFIGURE=1 ./autogen.sh
          { ./configure --prefix="${MATE_DESKTOP_INSTALL_PATH}" || { cat config.log; exit 1; } ; }
          make -j ${{ env.JOBS }}
          make -j ${{ env.JOBS }} install

      # Follows regular mate-panel build and test steps

      - name: Configure
        run: |
          cd mate-panel
          NOCONFIGURE=1 ./autogen.sh
          { ./configure ${CONFIGURE_FLAGS} --with-in-process-applets=${{matrix.in-process}} || { cat config.log; exit 1; } ; }

      - name: Build
        run: make -C mate-panel -j ${{ env.JOBS }}

      - name: Run Tests
        run: make -C mate-panel -j ${{ env.JOBS }} check

      - name: Run distcheck
        # We only run distcheck on one container, because it takes time and
        # doesn't seem so useful to repeat everywhere -- it mostly checks the
        # build system itself, rather than the build.
        if: ${{ startsWith(matrix.container, 'debian:') }}
        run: make -C mate-panel -j ${{ env.JOBS }} distcheck

  # Do we need the real build for cppcheck run?  I don't think so
  cppcheck:
    name: Run cppcheck
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true

      # Install code dependencies so that cppcheck has more info
      - name: Install dependencies
        run: |
          sudo apt-get update -qq
          sudo apt-get install --assume-yes --no-install-recommends \
            cppcheck ${DEB_LIBRARY_DEPS} ${DEB_LIBRARY_DEPS_MATE_DESKTOP}

      # - define relevant configuration I can think of
      #   - X11-related stuff
      #   - Wayland-related stuff
      #   - in-process for Wayland
      #   - optional features
      #   - _Noreturn: this is to avoid false positive with functions that
      #     don't return, like g_assert(false).  Here, we rely on G_NORETURN
      #     (GLib 2.68+) using _Noreturn C11 attribute if __STDC_VERSION__ is
      #     high enough (cppcheck sets it for us in newer versions, but not on
      #     here yet); but the version of cppcheck we run on don't know about
      #     the C11 attribute, so map it to the GCC one it does know.
      #     This is a tad over-specific, but it removes some spurious warnings,
      #     and defining e.g. __GNUC__=12 is simpler, but is a *lot* slower
      #     (more than 3 times slower), and doesn't seem to yield other
      #     benefits for the moment.
      # - -I flags from pkg-config (grepped from configure.ac)
      # - ignore non-source directories
      - name: cppcheck
        env:
          checks: warning,style,performance,portability,information,missingInclude
          defines: >
            -DHAVE_X11 -DHAVE_RANDR
            -DHAVE_WAYLAND
            -DCLOCK_INPROCESS -DFISH_INPROCESS -DNOTIFICATION_AREA_INPROCESS -DWNCKLET_INPROCESS
            -DHAVE_WINDOW_PREVIEWS
            -DHAVE_LANGINFO_H -DHAVE_NL_LANGINFO
            -DGETTEXT_PACKAGE="mate-panel"
            -D__STDC_VERSION__=201112 -D_Noreturn=__attribute__((__noreturn__))
          packages: >
            gdk-pixbuf-2.0
            gio-unix-2.0
            gmodule-2.0
            gtk+-3.0
            ice
            libwnck-3.0
            mate-desktop-2.0
            sm
        run: |
          cppcheck --enable="$checks"                       \
            -j $JOBS                                        \
            $defines                                        \
            $(pkg-config --cflags-only-I $packages)         \
            -i gtk-layer-shell-build                        \
            -i mate-panel/mate-submodules/                  \
            .