Skip to content

Commit 6423e67

Browse files
committed
ci: Add a GitHub Actions build
1 parent 3cc3898 commit 6423e67

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed

.github/workflows/build.yml

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
# cancel already running builds of the same branch or pull request
13+
concurrency:
14+
group: ci-${{ github.head_ref }} || concat(${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
MATE_PANEL_DEP: 1.27.1
19+
CONFIGURE_FLAGS: --enable-compile-warnings=maximum
20+
CFLAGS: -g -O2 -Werror=pointer-arith -Werror=implicit-function-declaration
21+
JOBS: 2
22+
DEBUG: 1
23+
# Useful URL: https://github.com/mate-desktop/debian-packages
24+
# Useful URL: https://salsa.debian.org/debian-mate-team/mate-panel
25+
DEB_LIBRARY_DEPS: |
26+
libcaja-extension-dev
27+
libglib2.0-dev
28+
libgtk-3-dev
29+
libjson-glib-dev
30+
libmagic-dev
31+
DEB_BUILD_DEPS: |
32+
ccache
33+
autoconf-archive
34+
autopoint
35+
git
36+
gettext
37+
make
38+
mate-common
39+
yelp-tools
40+
# Useful URL: https://git.archlinux.org/svntogit/community.git/tree/mate-panel
41+
ARCH_BUILD_DEPS: |
42+
ccache
43+
autoconf-archive
44+
caja
45+
clang
46+
file
47+
gcc
48+
git
49+
glib2-devel
50+
gtk3
51+
json-glib
52+
make
53+
mate-common
54+
which
55+
yelp-tools
56+
57+
jobs:
58+
build:
59+
name: Build on ${{matrix.container}} (using ${{matrix.cc}})
60+
runs-on: ubuntu-latest
61+
container: ${{matrix.container}}
62+
63+
strategy:
64+
fail-fast: false # don't cancel other jobs in the matrix if one fails
65+
matrix:
66+
container: ['debian:testing', 'ubuntu:rolling', 'archlinux:latest']
67+
cc: ['gcc']
68+
cxx: ['g++']
69+
include:
70+
# test with clang on archlinux:latest
71+
- container: 'archlinux:latest'
72+
cc: 'clang'
73+
cxx: 'clang++'
74+
75+
env:
76+
# Speed up build with ccache
77+
CC: ccache ${{matrix.cc}}
78+
CXX: ccache ${{matrix.cxx}}
79+
80+
steps:
81+
# For Debian and Ubuntu (apt-based with reasonably compatible packages)
82+
- name: Install dependencies
83+
if: ${{ startsWith(matrix.container, 'debian:') || startsWith(matrix.container, 'ubuntu:') }}
84+
run: |
85+
apt-get update -qq
86+
apt-get install --assume-yes --no-install-recommends \
87+
${DEB_BUILD_DEPS} ${DEB_LIBRARY_DEPS}
88+
89+
# For ArchLinux
90+
- name: Install dependencies
91+
if: ${{ startsWith(matrix.container, 'archlinux:') }}
92+
# don't upgrade, although told otherwise (see link below), because
93+
# apparently in the container it doesn't quit work...
94+
# https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported
95+
run: |
96+
pacman --noconfirm -Syu
97+
pacman --noconfirm -S ${ARCH_BUILD_DEPS}
98+
99+
# Checkout the repository
100+
- uses: actions/checkout@v3
101+
with:
102+
path: engrampa
103+
submodules: true
104+
105+
# Setup ccache cache
106+
- name: ccache
107+
uses: hendrikmuhs/[email protected]
108+
109+
# Follows regular build and test steps
110+
111+
- name: Configure
112+
run: |
113+
cd engrampa
114+
NOCONFIGURE=1 ./autogen.sh
115+
{ ./configure ${CONFIGURE_FLAGS} || { cat config.log; exit 1; } ; }
116+
117+
- name: Build
118+
run: make -C engrampa -j ${{ env.JOBS }}
119+
120+
- name: Run Tests
121+
run: make -C engrampa -j ${{ env.JOBS }} check
122+
123+
- name: Run distcheck
124+
# We only run distcheck on one container, because it takes time and
125+
# doesn't seem so useful to repeat everywhere -- it mostly checks the
126+
# build system itself, rather than the build.
127+
if: ${{ startsWith(matrix.container, 'debian:') }}
128+
run: make -C engrampa -j ${{ env.JOBS }} distcheck
129+
130+
# Do we need the real build for cppcheck run? I don't think so
131+
cppcheck:
132+
name: Run cppcheck
133+
runs-on: ubuntu-latest
134+
135+
steps:
136+
- uses: actions/checkout@v3
137+
with:
138+
submodules: true
139+
140+
# Install code dependencies so that cppcheck has more info
141+
- name: Install dependencies
142+
run: |
143+
sudo apt-get update -qq
144+
sudo apt-get install --assume-yes --no-install-recommends \
145+
cppcheck ${DEB_LIBRARY_DEPS}
146+
147+
# - define relevant configuration I can think of
148+
# - X11-related stuff
149+
# - Wayland-related stuff
150+
# - in-process for Wayland
151+
# - optional features
152+
# - _Noreturn: this is to avoid false positive with functions that
153+
# don't return, like g_assert(false). Here, we rely on G_NORETURN
154+
# (GLib 2.68+) using _Noreturn C11 attribute if __STDC_VERSION__ is
155+
# high enough (cppcheck sets it for us in newer versions, but not on
156+
# here yet); but the version of cppcheck we run on don't know about
157+
# the C11 attribute, so map it to the GCC one it does know.
158+
# This is a tad over-specific, but it removes some spurious warnings,
159+
# and defining e.g. __GNUC__=12 is simpler, but is a *lot* slower
160+
# (more than 3 times slower), and doesn't seem to yield other
161+
# benefits for the moment.
162+
# - -I flags from pkg-config (grepped from configure.ac)
163+
# - ignore non-source directories
164+
- name: cppcheck
165+
env:
166+
checks: warning,style,performance,portability,information,missingInclude
167+
defines: >
168+
-DGETTEXT_PACKAGE="engrampa"
169+
-D__STDC_VERSION__=201112 -D_Noreturn=__attribute__((__noreturn__))
170+
packages: >
171+
gio-2.0
172+
gio-unix-2.0
173+
gtk+-3.0
174+
ice
175+
json-glib-1.0
176+
libcaja-extension
177+
sm
178+
run: |
179+
cppcheck --enable="$checks" \
180+
-j $JOBS \
181+
$defines \
182+
$(pkg-config --cflags-only-I $packages) \
183+
-i engrampa/mate-submodules/ \
184+
.

0 commit comments

Comments
 (0)