github: Use separate caches for custom-built dependencies

These are shared by many tests, in particular the "all", "coverage",
"no-dbg" and "no-testable-ke" tests, which each would otherwise require
their own large cache.

Similarly, the "codeql" and "sonarcloud" tests rely on the same
dependencies but only the latter uses ccache for the strongSwan build.

Also reduce the maximum size per cache for all workflows to keep them
in check over time (some could even be set lower, we'll have to see
how this develops).
This commit is contained in:
Tobias Brunner
2026-05-12 16:34:22 +02:00
parent 821ba89961
commit 3b902ea59b
6 changed files with 166 additions and 57 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ permissions:
env: env:
CCACHE_BASEDIR: ${{ github.workspace }} CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 400M CCACHE_MAXSIZE: 150M
CC: gcc CC: gcc
OS_NAME: linux OS_NAME: linux
+40 -8
View File
@@ -7,6 +7,7 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
env: env:
CCACHE_BASEDIR: ${{ github.workspace }}
OS_NAME: linux OS_NAME: linux
jobs: jobs:
@@ -30,7 +31,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
language: [ 'cpp', 'python', 'ruby' ] language: [ 'python', 'ruby' ]
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- name: Initialize CodeQL - name: Initialize CodeQL
@@ -40,16 +41,47 @@ jobs:
config-file: ./.github/codeql/config.yml config-file: ./.github/codeql/config.yml
trap-caching: false trap-caching: false
- if: matrix.language == 'python' || matrix.language == 'ruby' - name: Autobuild
name: Autobuild
uses: github/codeql-action/autobuild@v4 uses: github/codeql-action/autobuild@v4
- if: matrix.language == 'cpp'
env:
TEST: codeql
uses: ./.github/actions/default
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4 uses: github/codeql-action/analyze@v4
with: with:
category: "/language:${{matrix.language}}" category: "/language:${{matrix.language}}"
analyze-cpp:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
permissions:
actions: write
security-events: write
env:
TEST: codeql
steps:
- uses: actions/checkout@v6
- run: ./scripts/test.sh deps
- uses: actions/cache/restore@v5
with:
path: ~/.cache/ccache
key: ccache-deps-ubuntu-latest-gcc-all
- run: |
sudo apt-get install -qq ccache
echo "OLD_PATH=$PATH" >> $GITHUB_ENV
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- run: ./scripts/test.sh build-deps
- run: ccache -sv
- run: echo "PATH=$OLD_PATH" >> $GITHUB_ENV
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: cpp
config-file: ./.github/codeql/config.yml
trap-caching: false
- run: ./scripts/test.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:cpp"
+108 -40
View File
@@ -16,7 +16,7 @@ env:
TESTS_REDUCED_KEYLENGTHS: yes TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_BASEDIR: ${{ github.workspace }} CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M CCACHE_MAXSIZE: 100M
OS_NAME: linux OS_NAME: linux
jobs: jobs:
@@ -67,18 +67,21 @@ jobs:
TEST: ${{ matrix.test }} TEST: ${{ matrix.test }}
# as several jobs use the same key, make sure we only store the cache for # as several jobs use the same key, make sure we only store the cache for
# one specific config in case there is a race # one specific config in case there is a race
STORE_DEPS_CACHE: >-
${{
github.event_name == 'push' &&
matrix.test == 'all' &&
matrix.monolithic == 'no'
}}
STORE_CACHE: >- STORE_CACHE: >-
${{ ${{
github.event_name == 'push' && github.event_name == 'push' &&
!contains(fromJSON('["apidoc"]'), matrix.test) && !contains(fromJSON('["apidoc"]'), matrix.test) &&
(!contains(fromJSON('["all", "default", "printf-builtin"]'), (!contains(fromJSON('["all", "default", "printf-builtin"]'),
matrix.test) || matrix.test) || matrix.monolithic == 'no')
((!matrix.leak-detective || matrix.leak-detective == 'no') &&
matrix.monolithic == 'no'))
}} }}
# with regards to ccache, monolithic builds don't differ from regular # with regards to ccache, monolithic builds don't differ from regular builds.
# builds; but some tests build different dependencies or use different # but most tests use different compiler flags, so we use separate caches
# compiler flags, so we use different caches for these
CACHE_KEY: >- CACHE_KEY: >-
${{ case(contains(fromJSON('["apidoc"]'), matrix.test), ${{ case(contains(fromJSON('["apidoc"]'), matrix.test),
'ccache-ubuntu-latest-gcc-default', 'ccache-ubuntu-latest-gcc-default',
@@ -86,16 +89,37 @@ jobs:
matrix.test)) }} matrix.test)) }}
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- run: ./scripts/test.sh deps
- uses: actions/cache/restore@v5
id: deps-cache-restore
with:
path: ~/.cache/ccache
key: ccache-deps-ubuntu-latest-${{ env.CC }}-all
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- run: ./scripts/test.sh build-deps
- run: ccache -sv
# delete old cache entry as we currently can't update it any other way
- env:
GH_TOKEN: ${{ github.token }}
if: steps.deps-cache-restore.outputs.cache-hit && fromJSON(env.STORE_DEPS_CACHE)
continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.deps-cache-restore.outputs.cache-primary-key }}
- if: fromJSON(env.STORE_DEPS_CACHE)
uses: actions/cache/save@v5
with:
path: ~/.cache/ccache
key: ${{ steps.deps-cache-restore.outputs.cache-primary-key }}
- run: rm -rf ~/.cache/ccache
- uses: actions/cache/restore@v5 - uses: actions/cache/restore@v5
id: cache-restore id: cache-restore
with: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ${{ env.CACHE_KEY }} key: ${{ env.CACHE_KEY }}
- run: | - run: ccache -z
sudo apt-get install -qq ccache - run: ./scripts/test.sh
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -sv - run: ccache -sv
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
@@ -151,29 +175,58 @@ jobs:
ACTIVE_TRANSFORMS_REF: .github/active-transforms/${{ matrix.test }} ACTIVE_TRANSFORMS_REF: .github/active-transforms/${{ matrix.test }}
# only store a cache for some tests as the others have a minimal diff (if # only store a cache for some tests as the others have a minimal diff (if
# any) compared to the 'all' build # any) compared to the 'all' build
STORE_CACHE: >- STORE_DEPS_CACHE: >-
${{ github.event_name == 'push' && ${{
contains(fromJSON('["openssl-4", "openssl-awslc"]'), matrix.test) && github.event_name == 'push' &&
(!matrix.leak-detective || matrix.leak-detective == 'no') }} contains(fromJSON('["openssl-4", "openssl-awslc"]'), matrix.test)
}}
DEPS_CACHE_KEY: >-
${{
case(contains(fromJSON('["openssl-4", "openssl-awslc"]'), matrix.test),
format('ccache-deps-{0}-gcc-{1}', matrix.os, matrix.test),
format('ccache-deps-{0}-gcc-all', matrix.os))
}}
CACHE_KEY: >- CACHE_KEY: >-
${{ case(contains(fromJSON('["openssl-4", "openssl-awslc"]'), matrix.test), ${{
format('ccache-{0}-gcc-{1}', matrix.os, matrix.test), case(matrix.os == 'ubuntu-latest' && matrix.test == 'openssl-sys',
matrix.os == 'ubuntu-latest' && matrix.test == 'openssl-sys', format('ccache-{0}-gcc-default', matrix.os),
format('ccache-{0}-gcc-default', matrix.os), format('ccache-{0}-gcc-all', matrix.os))
format('ccache-{0}-gcc-all', matrix.os)) }} }}
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- run: ./scripts/test.sh deps
- uses: actions/cache/restore@v5 - uses: actions/cache/restore@v5
id: cache-restore id: deps-cache-restore
with: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ${{ env.CACHE_KEY }} key: ${{ env.DEPS_CACHE_KEY }}
- run: | - run: |
sudo apt-get install -qq ccache sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z ccache -z
echo "TESTS_ACTIVE_TRANSFORMS=$HOME/active-transforms.log" >> $GITHUB_ENV echo "TESTS_ACTIVE_TRANSFORMS=$HOME/active-transforms.log" >> $GITHUB_ENV
- uses: ./.github/actions/default - run: ./scripts/test.sh build-deps
- run: ccache -sv
# delete old cache entry as we currently can't update it any other way
- env:
GH_TOKEN: ${{ github.token }}
if: steps.deps-cache-restore.outputs.cache-hit && fromJSON(env.STORE_DEPS_CACHE)
continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.deps-cache-restore.outputs.cache-primary-key }}
- if: fromJSON(env.STORE_DEPS_CACHE)
uses: actions/cache/save@v5
with:
path: ~/.cache/ccache
key: ${{ steps.deps-cache-restore.outputs.cache-primary-key }}
- run: rm -rf ~/.cache/ccache
- uses: actions/cache/restore@v5
id: cache-restore
with:
path: ~/.cache/ccache
key: ${{ env.CACHE_KEY }}
- run: ccache -z
- run: ./scripts/test.sh
- run: ccache -sv
- name: Upload active transforms - name: Upload active transforms
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v6
with: with:
@@ -184,17 +237,6 @@ jobs:
run: | run: |
test ! -f $ACTIVE_TRANSFORMS_REF || diff -us --color=always $ACTIVE_TRANSFORMS_REF $TESTS_ACTIVE_TRANSFORMS test ! -f $ACTIVE_TRANSFORMS_REF || diff -us --color=always $ACTIVE_TRANSFORMS_REF $TESTS_ACTIVE_TRANSFORMS
- run: ccache -sv - run: ccache -sv
# delete old cache entry as we currently can't update it any other way
- env:
GH_TOKEN: ${{ github.token }}
if: steps.cache-restore.outputs.cache-hit && fromJSON(env.STORE_CACHE)
continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }}
- if: fromJSON(env.STORE_CACHE)
uses: actions/cache/save@v5
with:
path: ~/.cache/ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- if: ${{ failure() }} - if: ${{ failure() }}
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v6
with: with:
@@ -218,18 +260,44 @@ jobs:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }} LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
CC: ${{ matrix.compiler || 'gcc' }} CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }} TEST: ${{ matrix.test }}
STORE_DEPS_CACHE: >-
${{
github.event_name == 'push' &&
matrix.test == 'all'
}}
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- run: ./scripts/test.sh deps
- uses: actions/cache/restore@v5
id: deps-cache-restore
with:
path: ~/.cache/ccache
key: ccache-deps-${{ matrix.os }}-${{ env.CC }}-all
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- run: ./scripts/test.sh build-deps
- run: ccache -sv
# delete old cache entry as we currently can't update it any other way
- env:
GH_TOKEN: ${{ github.token }}
if: steps.deps-cache-restore.outputs.cache-hit && fromJSON(env.STORE_DEPS_CACHE)
continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.deps-cache-restore.outputs.cache-primary-key }}
- if: fromJSON(env.STORE_DEPS_CACHE)
uses: actions/cache/save@v5
with:
path: ~/.cache/ccache
key: ${{ steps.deps-cache-restore.outputs.cache-primary-key }}
- run: rm -rf ~/.cache/ccache
- uses: actions/cache/restore@v5 - uses: actions/cache/restore@v5
id: cache-restore id: cache-restore
with: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ccache-${{ matrix.os }}-${{ env.CC }}-${{ matrix.test }} key: ccache-${{ matrix.os }}-${{ env.CC }}-${{ matrix.test }}
- run: | - run: ccache -z
sudo apt-get install -qq ccache - run: ./scripts/test.sh
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -sv - run: ccache -sv
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
+15 -6
View File
@@ -12,7 +12,7 @@ permissions:
env: env:
CCACHE_BASEDIR: ${{ github.workspace }} CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M CCACHE_MAXSIZE: 100M
OS_NAME: linux OS_NAME: linux
jobs: jobs:
@@ -36,19 +36,28 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- run: ./scripts/test.sh deps
- uses: actions/cache/restore@v5
with:
path: ~/.cache/ccache
key: ccache-deps-ubuntu-latest-gcc-all
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- run: ./scripts/test.sh build-deps
- run: ccache -sv
- run: rm -rf ~/.cache/ccache
- uses: actions/cache/restore@v5 - uses: actions/cache/restore@v5
id: cache-restore id: cache-restore
with: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ccache-sonarcloud key: ccache-sonarcloud
- run: | - run: ccache -z
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: SonarSource/sonarqube-scan-action/[email protected] - uses: SonarSource/sonarqube-scan-action/[email protected]
- run: | - run: |
echo "BUILD_WRAPPER_OUT_DIR=$HOME/bw-output" >> $GITHUB_ENV echo "BUILD_WRAPPER_OUT_DIR=$HOME/bw-output" >> $GITHUB_ENV
- uses: ./.github/actions/default - run: ./scripts/test.sh
- uses: SonarSource/[email protected] - uses: SonarSource/[email protected]
env: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+1 -1
View File
@@ -14,7 +14,7 @@ env:
CCACHE_CONTAINER: /root/.ccache CCACHE_CONTAINER: /root/.ccache
CCACHE_COMPILERCHECK: content CCACHE_COMPILERCHECK: content
CCACHE_COMPRESS: true CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M CCACHE_MAXSIZE: 100M
jobs: jobs:
pre-check: pre-check:
+1 -1
View File
@@ -12,7 +12,7 @@ permissions:
env: env:
TESTS_REDUCED_KEYLENGTHS: yes TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_COMPRESS: true CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M CCACHE_MAXSIZE: 100M
# since the compilers are newly installed every time, we have to use this to # since the compilers are newly installed every time, we have to use this to
# avoid cache misses # avoid cache misses
CCACHE_COMPILERCHECK: content CCACHE_COMPILERCHECK: content