mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
[CONAN] Move caching steps into build/dependencies actions
This commit is contained in:
126
.github/actions/build/action.yml
vendored
126
.github/actions/build/action.yml
vendored
@@ -1,35 +1,111 @@
|
||||
name: build
|
||||
name: 'build'
|
||||
description: 'Builds the project with ccache integration'
|
||||
|
||||
inputs:
|
||||
generator:
|
||||
default: null
|
||||
configuration:
|
||||
description: 'CMake generator to use'
|
||||
required: true
|
||||
cmake-args:
|
||||
default: null
|
||||
# An implicit input is the environment variable `build_dir`.
|
||||
configuration:
|
||||
description: 'Build configuration (Debug, Release, etc.)'
|
||||
required: true
|
||||
build_dir:
|
||||
description: 'Directory to build in'
|
||||
required: false
|
||||
default: '.build'
|
||||
cc:
|
||||
description: 'C compiler to use'
|
||||
required: false
|
||||
default: ''
|
||||
cxx:
|
||||
description: 'C++ compiler to use'
|
||||
required: false
|
||||
default: ''
|
||||
compiler-id:
|
||||
description: 'Unique identifier for compiler/version combination used for cache keys'
|
||||
required: false
|
||||
default: ''
|
||||
cache_version:
|
||||
description: 'Cache version for invalidation'
|
||||
required: false
|
||||
default: '1'
|
||||
ccache_enabled:
|
||||
description: 'Whether to use ccache'
|
||||
required: false
|
||||
default: 'true'
|
||||
main_branch:
|
||||
description: 'Main branch name for restore keys'
|
||||
required: false
|
||||
default: 'dev'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: dependencies
|
||||
uses: ./.github/actions/dependencies
|
||||
# Generate a safe branch name for cache keys
|
||||
- name: Generate safe branch name
|
||||
if: inputs.ccache_enabled == 'true'
|
||||
id: safe-branch
|
||||
shell: bash
|
||||
run: |
|
||||
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
|
||||
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
|
||||
|
||||
# Restore ccache if enabled
|
||||
- name: Restore ccache directory
|
||||
if: inputs.ccache_enabled == 'true'
|
||||
id: ccache-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
configuration: ${{ inputs.configuration }}
|
||||
- name: configure
|
||||
path: ~/.ccache
|
||||
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ steps.safe-branch.outputs.name }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ inputs.main_branch }}
|
||||
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-
|
||||
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
|
||||
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-
|
||||
|
||||
# Configure and build the project
|
||||
- name: Configure project
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${build_dir}
|
||||
cmake \
|
||||
${{ inputs.generator && format('-G {0}', inputs.generator) || '' }} \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
|
||||
-DCMAKE_BUILD_TYPE=${{ inputs.configuration }} \
|
||||
${{ inputs.cmake-args }} \
|
||||
..
|
||||
- name: build
|
||||
mkdir -p ${{ inputs.build_dir }}
|
||||
cd ${{ inputs.build_dir }}
|
||||
|
||||
# Set up environment variables for compilers if provided
|
||||
if [ -n "${{ inputs.cc }}" ]; then
|
||||
if [ "${{ inputs.ccache_enabled }}" = "true" ]; then
|
||||
export CC="ccache ${{ inputs.cc }}"
|
||||
else
|
||||
export CC="${{ inputs.cc }}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${{ inputs.cxx }}" ]; then
|
||||
if [ "${{ inputs.ccache_enabled }}" = "true" ]; then
|
||||
export CXX="ccache ${{ inputs.cxx }}"
|
||||
else
|
||||
export CXX="${{ inputs.cxx }}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run CMake configure
|
||||
cmake .. -G "${{ inputs.generator }}" -DCMAKE_BUILD_TYPE=${{ inputs.configuration }} -DBoost_NO_BOOST_CMAKE=ON
|
||||
|
||||
- name: Build project
|
||||
shell: bash
|
||||
run: |
|
||||
cmake \
|
||||
--build ${build_dir} \
|
||||
--config ${{ inputs.configuration }} \
|
||||
--parallel ${NUM_PROCESSORS:-$(nproc)}
|
||||
cd ${{ inputs.build_dir }}
|
||||
cmake --build . --config ${{ inputs.configuration }} --parallel $(nproc)
|
||||
|
||||
# Show ccache statistics
|
||||
- name: Show ccache statistics
|
||||
if: inputs.ccache_enabled == 'true'
|
||||
shell: bash
|
||||
run: ccache -s
|
||||
|
||||
# Save ccache
|
||||
- name: Save ccache directory
|
||||
if: inputs.ccache_enabled == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
|
||||
31
.github/actions/configure-ccache/action.yml
vendored
Normal file
31
.github/actions/configure-ccache/action.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: 'Configure ccache'
|
||||
description: 'Sets up ccache with consistent configuration'
|
||||
|
||||
inputs:
|
||||
max_size:
|
||||
description: 'Maximum cache size'
|
||||
required: false
|
||||
default: '2G'
|
||||
hash_dir:
|
||||
description: 'Whether to include directory paths in hash'
|
||||
required: false
|
||||
default: 'true'
|
||||
compiler_check:
|
||||
description: 'How to check compiler for changes'
|
||||
required: false
|
||||
default: 'content'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Configure ccache
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ~/.ccache
|
||||
export CONF_PATH="${CCACHE_CONFIGPATH:-${CCACHE_DIR:-$HOME/.ccache}/ccache.conf}"
|
||||
mkdir -p $(dirname "$CONF_PATH")
|
||||
echo "max_size = ${{ inputs.max_size }}" > "$CONF_PATH"
|
||||
echo "hash_dir = ${{ inputs.hash_dir }}" >> "$CONF_PATH"
|
||||
echo "compiler_check = ${{ inputs.compiler_check }}" >> "$CONF_PATH"
|
||||
ccache -p # Print config for verification
|
||||
ccache -z # Zero statistics before the build
|
||||
80
.github/actions/dependencies/action.yml
vendored
80
.github/actions/dependencies/action.yml
vendored
@@ -1,23 +1,91 @@
|
||||
name: dependencies
|
||||
description: 'Installs build dependencies with caching'
|
||||
|
||||
inputs:
|
||||
configuration:
|
||||
description: 'Build configuration (Debug, Release, etc.)'
|
||||
required: true
|
||||
# An implicit input is the environment variable `build_dir`.
|
||||
build_dir:
|
||||
description: 'Directory to build dependencies in'
|
||||
required: false
|
||||
default: '.build-deps'
|
||||
compiler-id:
|
||||
description: 'Unique identifier for compiler/version combination used for cache keys'
|
||||
required: false
|
||||
default: ''
|
||||
cache_version:
|
||||
description: 'Cache version for invalidation'
|
||||
required: false
|
||||
default: '1'
|
||||
cache_enabled:
|
||||
description: 'Whether to use caching'
|
||||
required: false
|
||||
default: 'true'
|
||||
main_branch:
|
||||
description: 'Main branch name for restore keys'
|
||||
required: false
|
||||
default: 'dev'
|
||||
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: 'Whether there was a cache hit'
|
||||
value: ${{ steps.cache-restore-conan.outputs.cache-hit }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: export custom recipes
|
||||
# Generate a safe branch name for cache keys
|
||||
- name: Generate safe branch name
|
||||
if: inputs.cache_enabled == 'true'
|
||||
id: safe-branch
|
||||
shell: bash
|
||||
run: |
|
||||
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
|
||||
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
|
||||
|
||||
# Restore Conan cache
|
||||
- name: Restore Conan cache
|
||||
if: inputs.cache_enabled == 'true'
|
||||
id: cache-restore-conan
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
~/.conan
|
||||
~/.conan2
|
||||
key: ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-${{ inputs.configuration }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-
|
||||
${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
|
||||
${{ runner.os }}-conan-v${{ inputs.cache_version }}-
|
||||
|
||||
# Export custom recipes
|
||||
- name: Export custom recipes
|
||||
shell: bash
|
||||
run: |
|
||||
conan export external/snappy snappy/1.1.9@
|
||||
conan export external/soci soci/4.0.3@
|
||||
- name: install dependencies
|
||||
|
||||
# Install dependencies
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ${build_dir} # TODO:CONAN
|
||||
cd ${build_dir}
|
||||
# Create build directory
|
||||
mkdir -p ${{ inputs.build_dir }}
|
||||
cd ${{ inputs.build_dir }}
|
||||
|
||||
# Install dependencies using conan
|
||||
conan install \
|
||||
--output-folder . \
|
||||
--build missing \
|
||||
--settings build_type=${{ inputs.configuration }} \
|
||||
..
|
||||
|
||||
# Save Conan cache if we installed dependencies
|
||||
- name: Save Conan cache
|
||||
if: inputs.cache_enabled == 'true' && steps.cache-restore-conan.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: |
|
||||
~/.conan
|
||||
~/.conan2
|
||||
key: ${{ steps.cache-restore-conan.outputs.cache-primary-key }}
|
||||
138
.github/workflows/macos-ga.yml
vendored
138
.github/workflows/macos-ga.yml
vendored
@@ -2,11 +2,11 @@
|
||||
name: MacOS Development - GA Runner
|
||||
|
||||
on:
|
||||
# Triggers on pushes and pull requests targeting the 'jshooks' branch
|
||||
# Use GA runners on pushes and pull requests targeting feature branches
|
||||
push:
|
||||
branches: [ jshooks ]
|
||||
branches: [ jshooks ] # and other feature branches
|
||||
pull_request:
|
||||
branches: [ jshooks ]
|
||||
branches: [ jshooks ] # and other feature branches
|
||||
|
||||
# Concurrency control: Cancels older in-progress runs for the same branch (github.ref)
|
||||
# when a new push occurs. This saves runner minutes on superseded commits.
|
||||
@@ -29,8 +29,6 @@ jobs:
|
||||
env:
|
||||
# Build directory relative to the workspace root
|
||||
build_dir: .build
|
||||
# Separate directory for building dependencies
|
||||
deps_dir: .build-deps
|
||||
# Manual cache version control. Bump this number to invalidate all caches globally.
|
||||
CACHE_VERSION: 1
|
||||
# Default branch name used for prioritizing ccache restores. Adjust if needed.
|
||||
@@ -47,36 +45,18 @@ jobs:
|
||||
# Add Conan 1 to the PATH for this job
|
||||
echo "$(brew --prefix conan@1)/bin" >> $GITHUB_PATH
|
||||
|
||||
# 3. Conan Cache Handling
|
||||
# Restores the Conan package cache (~/.conan). Key includes OS, version, dependency file hashes, and build configuration.
|
||||
- name: Restore Conan cache
|
||||
id: cache-restore-conan
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
~/.conan
|
||||
~/.conan2
|
||||
# Primary key: Requires exact match for OS, version, dependencies, and config.
|
||||
key: ${{ runner.os }}-conan-v${{ env.CACHE_VERSION }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-${{ matrix.configuration }}
|
||||
# Restore keys: Fallback hierarchy if primary key misses.
|
||||
# 1. Match OS, version, dependencies (ignore config).
|
||||
# 2. Match OS, version (broad fallback).
|
||||
restore-keys: |
|
||||
${{ runner.os }}-conan-v${{ env.CACHE_VERSION }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-
|
||||
${{ runner.os }}-conan-v${{ env.CACHE_VERSION }}-
|
||||
|
||||
# 4. Install Coreutils (for 'nproc')
|
||||
# 3. Install Coreutils (for 'nproc')
|
||||
- name: Install Coreutils
|
||||
run: |
|
||||
brew install coreutils
|
||||
echo "Num proc: $(nproc)"
|
||||
|
||||
# 5. Install Ninja (if needed by generator)
|
||||
# 4. Install Ninja (if needed by generator)
|
||||
- name: Install Ninja
|
||||
if: matrix.generator == 'Ninja'
|
||||
run: brew install ninja
|
||||
|
||||
# 6. Install Python (if needed)
|
||||
# 5. Install Python (if needed)
|
||||
- name: Install Python
|
||||
run: |
|
||||
if which python3 > /dev/null 2>&1; then
|
||||
@@ -90,7 +70,7 @@ jobs:
|
||||
sudo ln -sf $(which python3) /usr/local/bin/python
|
||||
fi
|
||||
|
||||
# 7. Install CMake (if needed)
|
||||
# 6. Install CMake (if needed)
|
||||
- name: Install CMake
|
||||
run: |
|
||||
if which cmake > /dev/null 2>&1; then
|
||||
@@ -100,18 +80,17 @@ jobs:
|
||||
brew install cmake
|
||||
fi
|
||||
|
||||
# 8. Install and Configure ccache
|
||||
- name: Install and configure ccache
|
||||
run: |
|
||||
brew install ccache
|
||||
mkdir -p ~/.ccache
|
||||
export CONF_PATH="${CCACHE_CONFIGPATH:-${CCACHE_DIR:-$HOME/.ccache}/ccache.conf}"
|
||||
mkdir -p $(dirname "$CONF_PATH")
|
||||
echo "max_size = 2G" > "$CONF_PATH"
|
||||
echo "hash_dir = true" >> "$CONF_PATH"
|
||||
echo "compiler_check = content" >> "$CONF_PATH"
|
||||
ccache -p # Print config for verification
|
||||
ccache -z # Zero statistics before the build
|
||||
# 7. Install ccache
|
||||
- name: Install ccache
|
||||
run: brew install ccache
|
||||
|
||||
# 8. Configure ccache (add this action)
|
||||
- name: Configure ccache
|
||||
uses: ./.github/actions/configure-ccache
|
||||
with:
|
||||
max_size: 2G
|
||||
hash_dir: true
|
||||
compiler_check: content
|
||||
|
||||
# 9. Environment Verification (Optional but Recommended)
|
||||
- name: Check environment
|
||||
@@ -132,85 +111,28 @@ jobs:
|
||||
conan profile new default --detect || true # Ignore error if profile exists
|
||||
conan profile update settings.compiler.cppstd=20 default
|
||||
|
||||
# 11. Install Conan Dependencies (Conditional)
|
||||
# Skips if the Conan cache was fully restored (exact primary key match).
|
||||
# 11. Install dependencies using the action
|
||||
- name: Install dependencies
|
||||
if: steps.cache-restore-conan.outputs.cache-hit != 'true'
|
||||
uses: ./.github/actions/dependencies
|
||||
with:
|
||||
configuration: ${{ matrix.configuration }}
|
||||
env:
|
||||
build_dir: ${{ env.deps_dir }}
|
||||
build_dir: ${{ env.build_dir }}
|
||||
compiler-id: clang
|
||||
cache_version: ${{ env.CACHE_VERSION }}
|
||||
main_branch: ${{ env.MAIN_BRANCH_NAME }}
|
||||
|
||||
# 12. Save Conan Cache (Conditional)
|
||||
# Saves only if the cache was modified/created in the 'Install dependencies' step.
|
||||
- name: Save Conan cache
|
||||
if: steps.cache-restore-conan.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: |
|
||||
~/.conan
|
||||
~/.conan2
|
||||
# Use the exact primary key generated in the restore step.
|
||||
key: ${{ steps.cache-restore-conan.outputs.cache-primary-key }}
|
||||
|
||||
# 13. Prepare Branch Name for Cache Key
|
||||
- name: Generate safe branch name
|
||||
id: safe-branch
|
||||
run: |
|
||||
# Cleans the branch name to be safe for use in cache keys.
|
||||
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
|
||||
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
|
||||
|
||||
# 14. ccache Cache Handling
|
||||
# Restores the ccache compilation cache (~/.ccache). Key includes OS, version, config, and branch.
|
||||
- name: Restore ccache directory
|
||||
id: ccache-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
# Primary key: Exact match for OS, version, config, specific branch.
|
||||
key: ${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.configuration }}-${{ steps.safe-branch.outputs.name }}
|
||||
# Restore keys: Fallback hierarchy.
|
||||
# 1. Tries main branch cache (same OS/version/config) - good for PRs.
|
||||
# 2. Tries any branch cache (same OS/version/config).
|
||||
# 3. Tries any config/branch cache (same OS/version).
|
||||
# 4. Tries any OS cache (very broad).
|
||||
restore-keys: |
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.configuration }}-${{ env.MAIN_BRANCH_NAME }}
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.configuration }}-
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-
|
||||
${{ runner.os }}-ccache-
|
||||
|
||||
# 15. Build Project
|
||||
# Leverages ccache automatically if it's in the PATH.
|
||||
# 12. Build Project using the action
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
with:
|
||||
generator: ${{ matrix.generator }}
|
||||
configuration: ${{ matrix.configuration }}
|
||||
build_dir: ${{ env.build_dir }}
|
||||
compiler-id: clang
|
||||
cache_version: ${{ env.CACHE_VERSION }}
|
||||
main_branch: ${{ env.MAIN_BRANCH_NAME }}
|
||||
|
||||
# 16. ccache Statistics
|
||||
# Display hit/miss stats. Essential for confirming cache effectiveness.
|
||||
- name: Show ccache statistics
|
||||
run: ccache -s
|
||||
|
||||
# 17. Save ccache Directory
|
||||
# Saves ~/.ccache using the primary key.
|
||||
# NOTE: If a cache with the exact key + internal version (derived from path, not content)
|
||||
# already exists from a prior run, the action logs a warning and skips the upload,
|
||||
# completing successfully. This is expected; the remote cache blob is not updated.
|
||||
# You can clear caches via api, e.g:
|
||||
# gh api --method DELETE /repos/Xahau/xahaud/actions/caches\?key='macos-15-ccache-v1-Debug-jshooks'
|
||||
- name: Save ccache directory
|
||||
id: save-ccache
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
# Use the exact primary key from the restore step.
|
||||
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
|
||||
|
||||
# 18. Run Tests
|
||||
# 13. Run Tests
|
||||
- name: Test
|
||||
run: |
|
||||
${build_dir}/rippled --unittest --unittest-jobs $(nproc)
|
||||
${{ env.build_dir }}/rippled --unittest --unittest-jobs $(nproc)
|
||||
148
.github/workflows/nix-ga.yml
vendored
148
.github/workflows/nix-ga.yml
vendored
@@ -2,11 +2,11 @@
|
||||
name: Nix Development - GA Runner
|
||||
|
||||
on:
|
||||
# Triggers on pushes and pull requests targeting the 'jshooks' branch
|
||||
# Use GA runners on pushes and pull requests targeting feature branches
|
||||
push:
|
||||
branches: [jshooks]
|
||||
branches: [jshooks] # and other feature branches
|
||||
pull_request:
|
||||
branches: [jshooks]
|
||||
branches: [jshooks] # and other feature branches
|
||||
|
||||
# Concurrency control: Cancels older in-progress runs for the same branch (github.ref)
|
||||
# when a new push occurs. This saves runner minutes on superseded commits.
|
||||
@@ -50,14 +50,14 @@ jobs:
|
||||
- compiler: gcc
|
||||
cc: gcc-11
|
||||
cxx: g++-11
|
||||
compiler_id: gcc-11
|
||||
# - compiler: clang
|
||||
# cc: clang-14
|
||||
# cxx: clang++-14
|
||||
# compiler_id: clang-14
|
||||
env:
|
||||
# Build directory relative to the workspace root
|
||||
build_dir: .build
|
||||
# Separate directory for building dependencies
|
||||
deps_dir: .build-deps
|
||||
# Manual cache version control. Bump this number to invalidate all caches globally.
|
||||
CACHE_VERSION: 1
|
||||
# Default branch name used for prioritizing ccache restores. Adjust if needed.
|
||||
@@ -76,34 +76,14 @@ jobs:
|
||||
pip install --upgrade "conan<2"
|
||||
|
||||
# 2.3. Configure ccache
|
||||
- name: Configure CCache
|
||||
run: |
|
||||
mkdir -p ~/.ccache
|
||||
export CONF_PATH="${CCACHE_CONFIGPATH:-${CCACHE_DIR:-$HOME/.ccache}/ccache.conf}"
|
||||
mkdir -p $(dirname "$CONF_PATH")
|
||||
echo "max_size = 2G" > "$CONF_PATH"
|
||||
echo "hash_dir = true" >> "$CONF_PATH"
|
||||
echo "compiler_check = content" >> "$CONF_PATH"
|
||||
ccache -p # Print config for verification
|
||||
ccache -z # Zero statistics before the build
|
||||
|
||||
# 2.4. Conan Cache Handling - Restore
|
||||
# Restores the Conan package cache. Key includes OS, version, compiler, dependency files, and build configuration.
|
||||
- name: Restore Conan cache
|
||||
id: cache-restore-conan
|
||||
uses: actions/cache/restore@v4
|
||||
- name: Configure ccache
|
||||
uses: ./.github/actions/configure-ccache
|
||||
with:
|
||||
path: ~/.conan # Conan 1 path
|
||||
# Primary key: Requires exact match for OS, version, compiler, dependencies, and config.
|
||||
key: ${{ runner.os }}-conan-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-${{ matrix.configuration }}
|
||||
# Restore keys: Fallback hierarchy.
|
||||
# 1. Match OS, version, compiler, dependencies (ignore config).
|
||||
# 2. Match OS, version, compiler (broad fallback for compiler).
|
||||
restore-keys: |
|
||||
${{ runner.os }}-conan-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-
|
||||
${{ runner.os }}-conan-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-
|
||||
max_size: 2G
|
||||
hash_dir: true
|
||||
compiler_check: content
|
||||
|
||||
# 2.5. Configure Conan Profile
|
||||
# 2.4. Configure Conan Profile
|
||||
# Sets up the Conan profile specifically for the compiler specified in the matrix.
|
||||
- name: Configure Conan
|
||||
run: |
|
||||
@@ -124,27 +104,7 @@ jobs:
|
||||
# Display profile for verification
|
||||
conan profile show default
|
||||
|
||||
# 2.6. Install Conan Dependencies (Conditional)
|
||||
# Skips if the Conan cache was fully restored (exact primary key match).
|
||||
- name: Install dependencies
|
||||
if: steps.cache-restore-conan.outputs.cache-hit != 'true'
|
||||
uses: ./.github/actions/dependencies
|
||||
with:
|
||||
configuration: ${{ matrix.configuration }}
|
||||
env:
|
||||
build_dir: ${{ env.deps_dir }} # Build deps in separate dir
|
||||
|
||||
# 2.7. Save Conan Cache (Conditional)
|
||||
# Saves only if the cache was modified/created in the 'Install dependencies' step.
|
||||
- name: Save Conan cache
|
||||
if: steps.cache-restore-conan.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ~/.conan
|
||||
# Use the exact primary key generated in the restore step.
|
||||
key: ${{ steps.cache-restore-conan.outputs.cache-primary-key }}
|
||||
|
||||
# 2.8. Environment Verification (Optional but Recommended)
|
||||
# 2.5. Environment Verification (Optional but Recommended)
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "PATH:"
|
||||
@@ -157,69 +117,30 @@ jobs:
|
||||
echo "---- Full Environment ----"
|
||||
env
|
||||
|
||||
# 2.9. Prepare Branch Name for Cache Key
|
||||
- name: Generate safe branch name
|
||||
id: safe-branch
|
||||
run: |
|
||||
# Cleans the branch name to be safe for use in cache keys.
|
||||
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
|
||||
# Output name needs to match usage below (outputs.name)
|
||||
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
|
||||
|
||||
# 2.10. ccache Cache Handling - Restore
|
||||
# Restores the ccache compilation cache. Key includes OS, version, compiler, config, and branch.
|
||||
- name: Restore ccache directory
|
||||
id: ccache-restore
|
||||
uses: actions/cache/restore@v4
|
||||
# 2.6. Install Dependencies using the action
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/dependencies
|
||||
with:
|
||||
path: ~/.ccache
|
||||
# Primary key: Exact match for OS, version, compiler, config, specific branch.
|
||||
key: ${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-${{ matrix.configuration }}-${{ steps.safe-branch.outputs.name }}
|
||||
# Restore keys: Fallback hierarchy.
|
||||
# 1. Tries main branch cache (same OS/version/compiler/config) - good for PRs.
|
||||
# 2. Tries any branch cache (same OS/version/compiler/config).
|
||||
# 3. Tries any config/branch cache (same OS/version/compiler).
|
||||
# 4. Tries any compiler/config/branch cache (same OS/version).
|
||||
# 5. Tries any OS cache (very broad).
|
||||
restore-keys: |
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-${{ matrix.configuration }}-${{ env.MAIN_BRANCH_NAME }}
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-${{ matrix.configuration }}-
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-
|
||||
${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-
|
||||
${{ runner.os }}-ccache-
|
||||
configuration: ${{ matrix.configuration }}
|
||||
build_dir: ${{ env.build_dir }}
|
||||
compiler-id: ${{ matrix.compiler_id }}
|
||||
cache_version: ${{ env.CACHE_VERSION }}
|
||||
main_branch: ${{ env.MAIN_BRANCH_NAME }}
|
||||
|
||||
# 2.11. Build Project
|
||||
# Leverages ccache automatically if it's in the PATH.
|
||||
# 2.7. Build Project using the action
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
with:
|
||||
generator: Ninja # Using Ninja based on apt install
|
||||
generator: Ninja
|
||||
configuration: ${{ matrix.configuration }}
|
||||
env:
|
||||
# Pass build_dir explicitly if the action needs it
|
||||
build_dir: ${{ env.build_dir }}
|
||||
cc: ${{ matrix.cc }}
|
||||
cxx: ${{ matrix.cxx }}
|
||||
compiler-id: ${{ matrix.compiler_id }}
|
||||
cache_version: ${{ env.CACHE_VERSION }}
|
||||
main_branch: ${{ env.MAIN_BRANCH_NAME }}
|
||||
|
||||
# 2.12. ccache Statistics
|
||||
# Display hit/miss stats. Essential for confirming cache effectiveness.
|
||||
- name: Show ccache statistics
|
||||
run: ccache -s
|
||||
|
||||
# 2.13. Save ccache Directory (Primary Attempt)
|
||||
# Saves ~/.ccache using the primary key.
|
||||
# NOTE: If a cache with the exact key + internal version (derived from path, not content)
|
||||
# already exists from a prior run, the action logs a warning and skips the upload,
|
||||
# completing successfully. This is expected; the remote cache blob is not updated.
|
||||
# You can clear caches via api, e.g:
|
||||
# gh api --method DELETE /repos/{owner}/{repo}/actions/caches\?key=${{ runner.os }}-ccache-v${{ env.CACHE_VERSION }}-${{ matrix.compiler }}-${{ matrix.configuration }}-${{ steps.safe-branch.outputs.name }}
|
||||
- name: Save ccache directory
|
||||
id: save-ccache
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
# Use the exact primary key from the restore step.
|
||||
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
|
||||
|
||||
# 2.14. Set Artifact Name (Based on Matrix)
|
||||
# 2.8. Set Artifact Name (Based on Matrix)
|
||||
- name: Set artifact name
|
||||
id: set-artifact-name
|
||||
run: |
|
||||
@@ -227,22 +148,13 @@ jobs:
|
||||
echo "artifact_name=${ARTIFACT_NAME}" >> "$GITHUB_OUTPUT"
|
||||
echo "Using artifact name: ${ARTIFACT_NAME}"
|
||||
|
||||
# 2.15. Debug Build Directory Contents (Optional)
|
||||
# 2.9. Debug Build Directory Contents (Optional)
|
||||
- name: Debug build directory
|
||||
run: |
|
||||
echo "Checking build directory contents: ${{ env.build_dir }}"
|
||||
ls -la ${{ env.build_dir }} || echo "Build directory not found or empty"
|
||||
|
||||
# 2.16. Upload Build Artifacts (Currently Disabled)
|
||||
# - name: Upload build artifacts
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: ${{ steps.set-artifact-name.outputs.artifact_name }}
|
||||
# path: ${{ env.build_dir }}
|
||||
# retention-days: 1
|
||||
# include-hidden-files: true
|
||||
|
||||
# 2.17. Run Tests
|
||||
# 2.10. Run Tests
|
||||
- name: Run tests
|
||||
run: |
|
||||
# Ensure the binary exists before trying to run
|
||||
|
||||
Reference in New Issue
Block a user