Skip to content

Commit ab0eef0

Browse files
authored
Speed up CI builds (#16)
* Speed up CI builds * Reduce Fedora dependency setup work
1 parent 5409d2f commit ab0eef0

3 files changed

Lines changed: 63 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ concurrency:
1313
group: ci-${{ github.ref }}
1414
cancel-in-progress: true
1515

16+
env:
17+
CCACHE_DIR: ${{ github.workspace }}/.ccache
18+
CCACHE_MAXSIZE: 500M
19+
1620
jobs:
1721
ubuntu-build:
1822
name: Ubuntu build and tests
@@ -22,65 +26,83 @@ jobs:
2226
- name: Check out source
2327
uses: actions/checkout@v4
2428

29+
- name: Restore compiler cache
30+
uses: actions/cache@v4
31+
with:
32+
path: .ccache
33+
key: ${{ runner.os }}-${{ github.job }}-ccache-${{ github.sha }}
34+
restore-keys: |
35+
${{ runner.os }}-${{ github.job }}-ccache-
36+
2537
- name: Install dependencies
2638
run: |
2739
sudo apt-get update
2840
sudo apt-get install -y --no-install-recommends \
2941
build-essential \
42+
ccache \
3043
cmake \
44+
ninja-build \
3145
libx11-dev \
3246
libssl-dev \
3347
pkg-config \
3448
zlib1g-dev
3549
3650
- name: Configure
37-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
51+
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
3852

3953
- name: Build
4054
run: cmake --build build --parallel
4155

4256
- name: Test
4357
run: ctest --test-dir build --output-on-failure
4458

59+
- name: Compiler cache stats
60+
run: ccache --show-stats
61+
4562
fedora-build:
4663
name: Fedora build and tests
4764
runs-on: ubuntu-latest
4865
container:
4966
image: fedora:latest
5067

5168
steps:
52-
- name: Install Git for checkout
53-
run: dnf install -y git
54-
55-
- name: Check out source
56-
uses: actions/checkout@v4
57-
5869
- name: Install dependencies
5970
run: |
60-
dnf install -y \
71+
dnf install -y --setopt=install_weak_deps=False \
72+
ccache \
6173
cmake \
6274
gcc-c++ \
75+
git \
6376
gtk3-devel \
6477
libayatana-appindicator3-devel \
6578
libX11-devel \
6679
make \
80+
ninja-build \
6781
openssl-devel \
6882
pkgconf-pkg-config \
6983
rpm-build \
7084
systemd-rpm-macros \
7185
zlib-devel
7286
73-
- name: Validate RPM packaging skeleton
74-
run: MWB_VALIDATE_RPM_BUILD=1 scripts/validate-rpm-packaging.sh
87+
- name: Check out source
88+
uses: actions/checkout@v4
7589

76-
- name: Configure
77-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
90+
- name: Restore compiler cache
91+
uses: actions/cache@v4
92+
with:
93+
path: .ccache
94+
key: ${{ runner.os }}-${{ github.job }}-ccache-${{ github.sha }}
95+
restore-keys: |
96+
${{ runner.os }}-${{ github.job }}-ccache-
7897
79-
- name: Build
80-
run: cmake --build build --parallel
98+
- name: Validate RPM packaging, build, and tests
99+
run: |
100+
MWB_VALIDATE_RPM_BUILD=1 \
101+
MWB_RPM_CMAKE_EXTRA_ARGS="-G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" \
102+
scripts/validate-rpm-packaging.sh
81103
82-
- name: Test
83-
run: ctest --test-dir build --output-on-failure
104+
- name: Compiler cache stats
105+
run: ccache --show-stats
84106

85107
sanitizers:
86108
name: ASan and UBSan
@@ -90,26 +112,39 @@ jobs:
90112
- name: Check out source
91113
uses: actions/checkout@v4
92114

115+
- name: Restore compiler cache
116+
uses: actions/cache@v4
117+
with:
118+
path: .ccache
119+
key: ${{ runner.os }}-${{ github.job }}-ccache-${{ github.sha }}
120+
restore-keys: |
121+
${{ runner.os }}-${{ github.job }}-ccache-
122+
93123
- name: Install dependencies
94124
run: |
95125
sudo apt-get update
96126
sudo apt-get install -y --no-install-recommends \
97127
build-essential \
128+
ccache \
98129
cmake \
130+
ninja-build \
99131
libx11-dev \
100132
libssl-dev \
101133
pkg-config \
102134
zlib1g-dev
103135
104136
- name: Configure
105-
run: cmake -S . -B build-sanitize -DCMAKE_BUILD_TYPE=Debug -DMWB_ENABLE_SANITIZERS=ON
137+
run: cmake -S . -B build-sanitize -G Ninja -DCMAKE_BUILD_TYPE=Debug -DMWB_ENABLE_SANITIZERS=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
106138

107139
- name: Build
108140
run: cmake --build build-sanitize --parallel
109141

110142
- name: Test
111143
run: ctest --test-dir build-sanitize --output-on-failure
112144

145+
- name: Compiler cache stats
146+
run: ccache --show-stats
147+
113148
static-checks:
114149
name: Static checks
115150
runs-on: ubuntu-latest

packaging/rpm/inputflow.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ retain the mwb-client naming for compatibility.
3636
%autosetup -n %{name}-%{version}
3737

3838
%build
39-
%cmake -DMWB_BUILD_TRAY=ON
39+
%cmake -DMWB_BUILD_TRAY=ON %{?mwb_cmake_extra_args}
4040
%cmake_build
4141

4242
%install
@@ -52,6 +52,9 @@ install -Dpm0644 packaging/usr/lib/systemd/user/mwb-client.service %{buildroot}%
5252
install -Dpm0644 packaging/usr/share/applications/inputflow.desktop %{buildroot}%{_datadir}/applications/inputflow.desktop
5353
install -Dpm0644 assets/icons/inputflow-desktop.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/inputflow.svg
5454

55+
%check
56+
ctest --test-dir %{_vpath_builddir} --output-on-failure
57+
5558
%pre
5659
%sysusers_create %{_sysusersdir}/mwb-client.conf
5760

scripts/validate-rpm-packaging.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ grep -Eq 'install -Dpm0755 mwb-desktop-ui\.sh .+%\{_libexecdir\}/inputflow/mwb-d
104104
grep -Eq 'install -Dpm0755 scripts/inputflow-diagnostics-bundle\.sh .+%\{_libexecdir\}/inputflow/scripts/inputflow-diagnostics-bundle\.sh' "$spec_file" || fail "spec must install the diagnostics bundle executable"
105105
grep -Eq 'install -Dpm0644 packaging/usr/share/applications/inputflow\.desktop .+%\{_datadir\}/applications/inputflow\.desktop' "$spec_file" || fail "spec must install the desktop entry"
106106
grep -Eq 'install -Dpm0644 assets/icons/inputflow-desktop\.svg .+%\{_datadir\}/icons/hicolor/scalable/apps/inputflow\.svg' "$spec_file" || fail "spec must install the application icon"
107+
grep -Eq '^%check$' "$spec_file" || fail "spec must run package build tests in %check"
108+
grep -Eq 'ctest --test-dir .*\{_vpath_builddir\} --output-on-failure' "$spec_file" || fail "spec %check must run ctest"
107109

108110
if command -v desktop-file-validate >/dev/null 2>&1; then
109111
run_quiet "desktop-file-validate" desktop-file-validate packaging/usr/share/applications/inputflow.desktop
@@ -142,7 +144,11 @@ if command -v rpmbuild >/dev/null 2>&1; then
142144
--transform "s#^\\./#${package_name}-${package_version}/#" \
143145
-czf "$topdir/SOURCES/${package_name}-${package_version}.tar.gz"
144146

145-
run_quiet "rpmbuild -bb" rpmbuild -bb --define "_topdir $topdir" "$spec_file"
147+
rpm_args=(--define "_topdir $topdir")
148+
if [[ -n "${MWB_RPM_CMAKE_EXTRA_ARGS:-}" ]]; then
149+
rpm_args+=(--define "mwb_cmake_extra_args ${MWB_RPM_CMAKE_EXTRA_ARGS}")
150+
fi
151+
run_quiet "rpmbuild -bb" rpmbuild -bb "${rpm_args[@]}" "$spec_file"
146152
fi
147153
fi
148154

0 commit comments

Comments
 (0)