From b8b5b216527ff18d4986ff10353ea7c2701fe011 Mon Sep 17 00:00:00 2001 From: Nicola Sella Date: Thu, 7 Sep 2023 15:15:00 +0200 Subject: [PATCH] Add ccache Github workflow --- .github/workflows/ccache-build.yaml | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/ccache-build.yaml diff --git a/.github/workflows/ccache-build.yaml b/.github/workflows/ccache-build.yaml new file mode 100644 index 0000000000..cbdc182a3a --- /dev/null +++ b/.github/workflows/ccache-build.yaml @@ -0,0 +1,57 @@ +--- +name: DNF 5 Build +on: + pull_request: + workflow_dispatch: + +jobs: + build-with-ccache: + name: Build with CCache + runs-on: ubuntu-latest + container: + image: fedora:rawhide + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # this step needs to be incorporated in our container that we use for testing + - name: Install dependencies + run: | + dnf install -y ccache && dnf builddep -y ./dnf5.spec + + - name: Prepare CCache timestamp + id: ccache_cache_timestamp + run: + echo "timestamp=$(date +%Y-%m-%d-%H:%M:%S)-UTC" >> "$GITHUB_OUTPUT" + + - name: Cache CCache files + uses: actions/cache@v3 + with: + path: ~/.cache/ccache + key: ${{ github.event.repository.name }}-ccache-pr-${{ github.base_ref }}-${{ github.event.number }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ github.event.repository.name }}-ccache-pr-${{ github.base_ref }}-${{ github.event.number }}- + ${{ github.event.repository.name }}-ccache-pr-${{ github.base_ref }}- + ${{ github.event.repository.name }}-ccache-pr- + ${{ github.event.repository.name }}- + + - name: Create CCache symlinks to prioritize it over GCC + run: | + ln -s /usr/bin/ccache /usr/local/bin/gcc + ln -s /usr/bin/ccache /usr/local/bin/g++ + ln -s /usr/bin/ccache /usr/local/bin/cc + ln -s /usr/bin/ccache /usr/local/bin/c++ + + - name: Zero CCache statistics + run: ccache -z + + - name: Configure DNF5 with CMake + run: cmake -S . -B build + + - name: Build DNF5 + run: cmake --build build + + - name: Display CCache statistics + run: ccache -s