mirror of
https://github.com/azerothcore/azerothcore-wotlk.git
synced 2025-11-10 12:24:22 +08:00
feat(CI): enable cache in dashboard checks (#23432)
This commit is contained in:
parent
9dd5407525
commit
48736cfc89
123
.github/workflows/dashboard-ci.yml
vendored
123
.github/workflows/dashboard-ci.yml
vendored
@ -19,6 +19,10 @@ concurrency:
|
||||
group: ${{ github.head_ref }} || concat(${{ github.ref_name }}, ${{ github.workflow }})
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
|
||||
env:
|
||||
CONTINUOUS_INTEGRATION: true
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
@ -72,6 +76,113 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install ccache
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ccache
|
||||
ccache --version
|
||||
|
||||
# Detect the compilers that acore.sh / CMake will end up using.
|
||||
# We record both the binary name and a short version tag for the cache key.
|
||||
- name: Detect compiler
|
||||
id: detect
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
CC_BIN="${CC:-}"
|
||||
CXX_BIN="${CXX:-}"
|
||||
[[ -z "$CC_BIN" ]] && CC_BIN="$(command -v clang || command -v gcc)"
|
||||
[[ -z "$CXX_BIN" ]] && CXX_BIN="$(command -v clang++ || command -v g++)"
|
||||
|
||||
make_ver_id() {
|
||||
local bin="$1"; local base="$(basename "$bin")"
|
||||
case "$base" in
|
||||
clang)
|
||||
maj="$("$bin" -dumpversion 2>/dev/null | cut -d. -f1)"; [[ -z "$maj" ]] && maj="$( "$bin" --version | sed -n 's/.*version \([0-9][0-9]*\).*/\1/p' | head -1 )"
|
||||
echo "clang-${maj:-unknown}"
|
||||
;;
|
||||
clang++)
|
||||
maj="$("$bin" -dumpversion 2>/dev/null | cut -d. -f1)"; [[ -z "$maj" ]] && maj="$( "$bin" --version | sed -n 's/.*version \([0-9][0-9]*\).*/\1/p' | head -1 )"
|
||||
echo "clang++-${maj:-unknown}"
|
||||
;;
|
||||
gcc)
|
||||
maj="$("$bin" -dumpfullversion -dumpversion 2>/dev/null || "$bin" -dumpversion 2>/dev/null)"; maj="${maj%%.*}"
|
||||
echo "gcc-${maj:-unknown}"
|
||||
;;
|
||||
g++)
|
||||
maj="$("$bin" -dumpfullversion -dumpversion 2>/dev/null || "$bin" -dumpversion 2>/dev/null)"; maj="${maj%%.*}"
|
||||
echo "g++-${maj:-unknown}"
|
||||
;;
|
||||
*)
|
||||
echo "$base"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
echo "cc_id=$(make_ver_id "$CC_BIN")" >> "$GITHUB_OUTPUT"
|
||||
echo "cxx_id=$(make_ver_id "$CXX_BIN")" >> "$GITHUB_OUTPUT"
|
||||
echo "Detected: $CC_BIN, $CXX_BIN"
|
||||
|
||||
- name: Prepare ccache dir
|
||||
shell: bash
|
||||
run: mkdir -p "${{ github.workspace }}/var/ccache"
|
||||
|
||||
- name: Echo cache key
|
||||
shell: bash
|
||||
run: echo "Cache key -> ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}"
|
||||
|
||||
- name: Restore ccache
|
||||
id: restore_ccache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/var/ccache
|
||||
key: ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}
|
||||
restore-keys: |
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:true:pch=false:
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:false:pch=false:
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:true:pch=true:
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:false:pch=true:
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:true:
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:false:
|
||||
ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:
|
||||
|
||||
- name: Setup ccache env
|
||||
shell: bash
|
||||
env:
|
||||
CCACHE_DIR: ${{ github.workspace }}/var/ccache
|
||||
run: |
|
||||
mkdir -p "$CCACHE_DIR"
|
||||
cat <<EOF >> "$GITHUB_ENV"
|
||||
CCACHE_BASEDIR=${{ github.workspace }}
|
||||
CCACHE_DIR=${{ github.workspace }}/var/ccache
|
||||
CCACHE_HASHDIR=1
|
||||
CCACHE_MAXSIZE=5G
|
||||
CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime
|
||||
CCACHE_COMPRESS=1
|
||||
CCACHE_COMPRESSLEVEL=9
|
||||
CCACHE_COMPILERCHECK=content
|
||||
CCACHE_LOGFILE=${{ github.workspace }}/var/ccache/cache.debug
|
||||
CMAKE_C_COMPILER_LAUNCHER=ccache
|
||||
CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
EOF
|
||||
|
||||
- name: ccache snapshot (before)
|
||||
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
|
||||
echo
|
||||
echo "==== Top cache results (from prior runs) ===="
|
||||
grep -o 'result: .*' "${{ github.workspace }}/var/ccache/cache.debug" 2>/dev/null | sort | uniq -c | sort -nr | head || true
|
||||
|
||||
- name: Reset ccache stats
|
||||
shell: bash
|
||||
run: ccache -z || true
|
||||
|
||||
- name: Configure AzerothCore settings
|
||||
run: |
|
||||
touch conf/config.sh
|
||||
@ -154,3 +265,15 @@ jobs:
|
||||
./acore.sh sm delete authserver
|
||||
timeout-minutes: 30
|
||||
continue-on-error: false
|
||||
|
||||
# save only if we didn't hit the cache
|
||||
- name: Save ccache
|
||||
if: steps.restore_ccache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/var/ccache
|
||||
key: ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}
|
||||
|
||||
- name: ccache stats (after)
|
||||
shell: bash
|
||||
run: ccache -s || true
|
||||
Loading…
x
Reference in New Issue
Block a user