diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb929e1..03288f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,10 @@ concurrency: group: ci-${{ github.ref }} cancel-in-progress: true +env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + CCACHE_MAXSIZE: 500M + jobs: ubuntu-build: name: Ubuntu build and tests @@ -22,19 +26,29 @@ jobs: - name: Check out source uses: actions/checkout@v4 + - name: Restore compiler cache + uses: actions/cache@v4 + with: + path: .ccache + key: ${{ runner.os }}-${{ github.job }}-ccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-ccache- + - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ build-essential \ + ccache \ cmake \ + ninja-build \ libx11-dev \ libssl-dev \ pkg-config \ zlib1g-dev - name: Configure - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: cmake --build build --parallel @@ -42,6 +56,9 @@ jobs: - name: Test run: ctest --test-dir build --output-on-failure + - name: Compiler cache stats + run: ccache --show-stats + fedora-build: name: Fedora build and tests runs-on: ubuntu-latest @@ -49,38 +66,43 @@ jobs: image: fedora:latest steps: - - name: Install Git for checkout - run: dnf install -y git - - - name: Check out source - uses: actions/checkout@v4 - - name: Install dependencies run: | - dnf install -y \ + dnf install -y --setopt=install_weak_deps=False \ + ccache \ cmake \ gcc-c++ \ + git \ gtk3-devel \ libayatana-appindicator3-devel \ libX11-devel \ make \ + ninja-build \ openssl-devel \ pkgconf-pkg-config \ rpm-build \ systemd-rpm-macros \ zlib-devel - - name: Validate RPM packaging skeleton - run: MWB_VALIDATE_RPM_BUILD=1 scripts/validate-rpm-packaging.sh + - name: Check out source + uses: actions/checkout@v4 - - name: Configure - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + - name: Restore compiler cache + uses: actions/cache@v4 + with: + path: .ccache + key: ${{ runner.os }}-${{ github.job }}-ccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-ccache- - - name: Build - run: cmake --build build --parallel + - name: Validate RPM packaging, build, and tests + run: | + MWB_VALIDATE_RPM_BUILD=1 \ + MWB_RPM_CMAKE_EXTRA_ARGS="-G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" \ + scripts/validate-rpm-packaging.sh - - name: Test - run: ctest --test-dir build --output-on-failure + - name: Compiler cache stats + run: ccache --show-stats sanitizers: name: ASan and UBSan @@ -90,19 +112,29 @@ jobs: - name: Check out source uses: actions/checkout@v4 + - name: Restore compiler cache + uses: actions/cache@v4 + with: + path: .ccache + key: ${{ runner.os }}-${{ github.job }}-ccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-ccache- + - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ build-essential \ + ccache \ cmake \ + ninja-build \ libx11-dev \ libssl-dev \ pkg-config \ zlib1g-dev - name: Configure - run: cmake -S . -B build-sanitize -DCMAKE_BUILD_TYPE=Debug -DMWB_ENABLE_SANITIZERS=ON + run: cmake -S . -B build-sanitize -G Ninja -DCMAKE_BUILD_TYPE=Debug -DMWB_ENABLE_SANITIZERS=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: cmake --build build-sanitize --parallel @@ -110,6 +142,9 @@ jobs: - name: Test run: ctest --test-dir build-sanitize --output-on-failure + - name: Compiler cache stats + run: ccache --show-stats + static-checks: name: Static checks runs-on: ubuntu-latest diff --git a/packaging/rpm/inputflow.spec b/packaging/rpm/inputflow.spec index df4c264..55db056 100644 --- a/packaging/rpm/inputflow.spec +++ b/packaging/rpm/inputflow.spec @@ -36,7 +36,7 @@ retain the mwb-client naming for compatibility. %autosetup -n %{name}-%{version} %build -%cmake -DMWB_BUILD_TRAY=ON +%cmake -DMWB_BUILD_TRAY=ON %{?mwb_cmake_extra_args} %cmake_build %install @@ -52,6 +52,9 @@ install -Dpm0644 packaging/usr/lib/systemd/user/mwb-client.service %{buildroot}% install -Dpm0644 packaging/usr/share/applications/inputflow.desktop %{buildroot}%{_datadir}/applications/inputflow.desktop install -Dpm0644 assets/icons/inputflow-desktop.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/inputflow.svg +%check +ctest --test-dir %{_vpath_builddir} --output-on-failure + %pre %sysusers_create %{_sysusersdir}/mwb-client.conf diff --git a/scripts/validate-rpm-packaging.sh b/scripts/validate-rpm-packaging.sh index 1a0bb09..ad83b17 100755 --- a/scripts/validate-rpm-packaging.sh +++ b/scripts/validate-rpm-packaging.sh @@ -104,6 +104,8 @@ grep -Eq 'install -Dpm0755 mwb-desktop-ui\.sh .+%\{_libexecdir\}/inputflow/mwb-d 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" grep -Eq 'install -Dpm0644 packaging/usr/share/applications/inputflow\.desktop .+%\{_datadir\}/applications/inputflow\.desktop' "$spec_file" || fail "spec must install the desktop entry" 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" +grep -Eq '^%check$' "$spec_file" || fail "spec must run package build tests in %check" +grep -Eq 'ctest --test-dir .*\{_vpath_builddir\} --output-on-failure' "$spec_file" || fail "spec %check must run ctest" if command -v desktop-file-validate >/dev/null 2>&1; then 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 --transform "s#^\\./#${package_name}-${package_version}/#" \ -czf "$topdir/SOURCES/${package_name}-${package_version}.tar.gz" - run_quiet "rpmbuild -bb" rpmbuild -bb --define "_topdir $topdir" "$spec_file" + rpm_args=(--define "_topdir $topdir") + if [[ -n "${MWB_RPM_CMAKE_EXTRA_ARGS:-}" ]]; then + rpm_args+=(--define "mwb_cmake_extra_args ${MWB_RPM_CMAKE_EXTRA_ARGS}") + fi + run_quiet "rpmbuild -bb" rpmbuild -bb "${rpm_args[@]}" "$spec_file" fi fi