Share ccache across linux and docker workflows

This commit is contained in:
Francesco Borzì 2025-10-26 16:49:30 +01:00
parent ab8afbb3ec
commit 60a88f674e
6 changed files with 58 additions and 7 deletions

View file

@ -37,7 +37,13 @@ runs:
push: ${{ inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
target: ${{ inputs.component-name }}
cache-from: type=gha,scope=acore-linux
cache-to: type=gha,scope=acore-linux,mode=max
build-args: |
USER_ID=1000
GROUP_ID=1000
DOCKER_USER=acore
CCACHE_COMPRESS=1
CCACHE_COMPRESSLEVEL=9
CCACHE_COMPILERCHECK=content
CCACHE_MAXSIZE=5G

View file

@ -39,18 +39,12 @@ inputs:
runs:
using: composite
steps:
- name: echo cache key
shell: bash
run: echo "Cache key -> ccache:${{ runner.os }}:${{ inputs.CC }}_${{ inputs.CXX }}:${{ inputs.modules }}:pch=${{ inputs.pch }}:${{ github.ref_name }}"
- name: Cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/var/ccache
key: ccache:${{ runner.os }}:${{ inputs.CC }}_${{ inputs.CXX }}:${{ inputs.modules }}:pch=${{ inputs.pch }}:${{ github.ref_name }}
key: ccache:${{ runner.os }}:${{ inputs.CC }}_${{ inputs.CXX }}:${{ github.ref_name }}
restore-keys: |
ccache:${{ runner.os }}:${{ inputs.CC }}_${{ inputs.CXX }}:${{ inputs.modules }}:pch=${{ inputs.pch }}
ccache:${{ runner.os }}:${{ inputs.CC }}_${{ inputs.CXX }}:${{ inputs.modules }}
ccache:${{ runner.os }}:${{ inputs.CC }}_${{ inputs.CXX }}
# This script moves sql files from "data/sql/updates/pending_$DB" to the

View file

@ -22,6 +22,13 @@ jobs:
name: ${{ matrix.os }}
env:
BOOST_ROOT: C:\local\boost_1_82_0
AC_CCACHE: true
CCACHE_DIR: ${{ github.workspace }}/var/ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_HASHDIR: 1
CCACHE_COMPRESS: 1
CCACHE_COMPRESSLEVEL: 9
CCACHE_COMPILERCHECK: content
if: |
github.repository == 'azerothcore/azerothcore-wotlk'
&& !github.event.pull_request.draft
@ -30,14 +37,34 @@ jobs:
- uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.13
with:
key: windows:${{ github.ref_name }}
max-size: 5G
- name: Prepare ccache directory
shell: bash
run: |
mkdir -p "${CCACHE_DIR}" "${CCACHE_DIR}/tmp"
- name: Configure OS
shell: bash
env:
CONTINUOUS_INTEGRATION: true
run: |
./acore.sh install-deps
- name: ccache config snapshot
shell: bash
run: |
echo "==== Effective ccache configuration ===="
ccache -p | egrep 'base_dir|hash_dir|compiler_check|sloppiness|max_size' || true
echo
echo "==== Previous cache stats ===="
ccache -s || true
- name: Build
shell: bash
run: |
set -x
export CTOOLS_BUILD=all
./acore.sh compiler build
- name: ccache stats
shell: bash
run: ccache -s || true

View file

@ -25,6 +25,14 @@ function comp_clean() {
function comp_ccacheEnable() {
[ "$AC_CCACHE" != true ] && return
local default_ccache_dir="${CCACHE_DIR:-"$AC_PATH_VAR/ccache"}"
mkdir -p "$default_ccache_dir" "$default_ccache_dir/tmp"
export CCACHE_DIR="$default_ccache_dir"
export CCACHE_TEMPDIR=${CCACHE_TEMPDIR:-"$default_ccache_dir/tmp"}
export CCACHE_BASEDIR=${CCACHE_BASEDIR:-"$AC_PATH_ROOT"}
export CCACHE_HASHDIR=${CCACHE_HASHDIR:-1}
export CCACHE_MAXSIZE=${CCACHE_MAXSIZE:-'1000MB'}
#export CCACHE_DEPEND=true
export CCACHE_SLOPPINESS=${CCACHE_SLOPPINESS:-pch_defines,time_macros,include_file_mtime}

View file

@ -61,6 +61,20 @@ ARG CCACHE_COMPRESS=""
ARG CCACHE_COMPRESSLEVEL="9"
ARG CCACHE_COMPILERCHECK="content"
ARG CCACHE_LOGFILE=""
ARG CCACHE_BASEDIR="/azerothcore"
ARG CCACHE_HASHDIR="1"
ENV CCACHE_DIR="$CCACHE_DIR" \
CCACHE_TEMPDIR="$CCACHE_DIR/tmp" \
CCACHE_BASEDIR="$CCACHE_BASEDIR" \
CCACHE_HASHDIR="$CCACHE_HASHDIR" \
CCACHE_CPP2="$CCACHE_CPP2" \
CCACHE_MAXSIZE="$CCACHE_MAXSIZE" \
CCACHE_SLOPPINESS="$CCACHE_SLOPPINESS" \
CCACHE_COMPRESS="$CCACHE_COMPRESS" \
CCACHE_COMPRESSLEVEL="$CCACHE_COMPRESSLEVEL" \
CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" \
CCACHE_LOGFILE="$CCACHE_LOGFILE"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@ -88,6 +102,7 @@ RUN --mount=type=cache,target=/ccache,sharing=locked \
# of git repo into the container.
--mount=type=bind,target=/azerothcore/.git,source=.git \
git config --global --add safe.directory /azerothcore \
&& mkdir -p "$CCACHE_DIR" "$CCACHE_TEMPDIR" \
&& cmake /azerothcore \
-DCMAKE_INSTALL_PREFIX="/azerothcore/env/dist" \
-DAPPS_BUILD="all" \

View file

@ -27,3 +27,4 @@ choco install -y --skip-checksums "${INSTALL_ARGS[@]}" visualstudio2022-workloa
choco install -y --skip-checksums "${INSTALL_ARGS[@]}" openssl --force --version=3.5.4
choco install -y --skip-checksums "${INSTALL_ARGS[@]}" boost-msvc-14.3 --force --version=1.87.0
choco install -y --skip-checksums "${INSTALL_ARGS[@]}" mysql --force --version=8.4.6
choco install -y --skip-checksums "${INSTALL_ARGS[@]}" ccache