mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
refactor: simplify ccache to single directory with restore-keys fallback
Removed split ccache configuration (~/.ccache-main + ~/.ccache-current). The split had an edge case: building a feature branch before main branch cache is primed results in double ccache disk usage: - Feature branch builds first → populates ~/.ccache-current (2G max_size) - Main branch builds later → populates ~/.ccache-main (2G max_size) - Next feature branch build → restores both caches (4G total) This doubles ccache disk usage unnecessarily on GitHub-hosted runners. New single-directory approach: - Single ~/.ccache directory for all branches - Branch-specific keys with restore-keys fallback to main branch - Cache actions handle cross-branch sharing via partial-match mode - Simpler and prevents double disk usage edge case Changes: - xahau-configure-ccache: Single cache_dir input, removed branch logic - xahau-ga-build: Single restore/save step, uses restore-keys for fallback - xahau-ga-nix: Removed is_main_branch parameter Disk usage: 2G max (vs 4G worst case with split)
This commit is contained in:
@@ -2,6 +2,10 @@ name: 'Configure ccache'
|
|||||||
description: 'Sets up ccache with consistent configuration'
|
description: 'Sets up ccache with consistent configuration'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
|
cache_dir:
|
||||||
|
description: 'Path to ccache directory'
|
||||||
|
required: false
|
||||||
|
default: '~/.ccache'
|
||||||
max_size:
|
max_size:
|
||||||
description: 'Maximum cache size'
|
description: 'Maximum cache size'
|
||||||
required: false
|
required: false
|
||||||
@@ -14,18 +18,6 @@ inputs:
|
|||||||
description: 'How to check compiler for changes'
|
description: 'How to check compiler for changes'
|
||||||
required: false
|
required: false
|
||||||
default: 'content'
|
default: 'content'
|
||||||
is_main_branch:
|
|
||||||
description: 'Whether the current branch is the main branch'
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
main_cache_dir:
|
|
||||||
description: 'Path to the main branch cache directory'
|
|
||||||
required: false
|
|
||||||
default: '~/.ccache-main'
|
|
||||||
current_cache_dir:
|
|
||||||
description: 'Path to the current branch cache directory'
|
|
||||||
required: false
|
|
||||||
default: '~/.ccache-current'
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
@@ -33,31 +25,20 @@ runs:
|
|||||||
- name: Configure ccache
|
- name: Configure ccache
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Create cache directories
|
# Create cache directory
|
||||||
mkdir -p ${{ inputs.main_cache_dir }} ${{ inputs.current_cache_dir }}
|
mkdir -p ${{ inputs.cache_dir }}
|
||||||
|
|
||||||
# Set compiler check globally
|
# Configure ccache settings
|
||||||
ccache -o compiler_check=${{ inputs.compiler_check }}
|
ccache --set-config=cache_dir="${{ inputs.cache_dir }}"
|
||||||
|
ccache --set-config=max_size=${{ inputs.max_size }}
|
||||||
# Use a single config file location
|
ccache --set-config=hash_dir=${{ inputs.hash_dir }}
|
||||||
mkdir -p ~/.ccache
|
ccache --set-config=compiler_check=${{ inputs.compiler_check }}
|
||||||
export CONF_PATH="$HOME/.ccache/ccache.conf"
|
|
||||||
|
# Export for use by build tools
|
||||||
# Apply common settings
|
echo "CCACHE_DIR=${{ inputs.cache_dir }}" >> $GITHUB_ENV
|
||||||
echo "max_size = ${{ inputs.max_size }}" > "$CONF_PATH"
|
|
||||||
echo "hash_dir = ${{ inputs.hash_dir }}" >> "$CONF_PATH"
|
# Print config for verification
|
||||||
echo "compiler_check = ${{ inputs.compiler_check }}" >> "$CONF_PATH"
|
ccache -p
|
||||||
|
|
||||||
if [ "${{ inputs.is_main_branch }}" == "true" ]; then
|
# Zero statistics before the build
|
||||||
# Main branch: use main branch cache
|
ccache -z
|
||||||
ccache --set-config=cache_dir="${{ inputs.main_cache_dir }}"
|
|
||||||
echo "CCACHE_DIR=${{ inputs.main_cache_dir }}" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
# Feature branch: use current branch cache with main as secondary
|
|
||||||
ccache --set-config=cache_dir="${{ inputs.current_cache_dir }}"
|
|
||||||
ccache --set-config=secondary_storage="file:${{ inputs.main_cache_dir }}"
|
|
||||||
echo "CCACHE_DIR=${{ inputs.current_cache_dir }}" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
ccache -p # Print config for verification
|
|
||||||
ccache -z # Zero statistics before the build
|
|
||||||
32
.github/actions/xahau-ga-build/action.yml
vendored
32
.github/actions/xahau-ga-build/action.yml
vendored
@@ -65,25 +65,12 @@ runs:
|
|||||||
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
|
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
|
||||||
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
|
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Restore ccache directory for default branch
|
- name: Restore ccache directory
|
||||||
if: inputs.ccache_enabled == 'true'
|
if: inputs.ccache_enabled == 'true'
|
||||||
id: ccache-restore
|
id: ccache-restore
|
||||||
uses: ./.github/actions/xahau-actions-cache-restore
|
uses: ./.github/actions/xahau-actions-cache-restore
|
||||||
with:
|
with:
|
||||||
path: ~/.ccache-main
|
path: ~/.ccache
|
||||||
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ inputs.main_branch }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-
|
|
||||||
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
|
|
||||||
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
|
||||||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
|
||||||
|
|
||||||
- name: Restore ccache directory for current branch
|
|
||||||
if: inputs.ccache_enabled == 'true' && steps.safe-branch.outputs.name != inputs.main_branch
|
|
||||||
id: ccache-restore-current-branch
|
|
||||||
uses: ./.github/actions/xahau-actions-cache-restore
|
|
||||||
with:
|
|
||||||
path: ~/.ccache-current
|
|
||||||
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ steps.safe-branch.outputs.name }}
|
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ steps.safe-branch.outputs.name }}
|
||||||
restore-keys: |
|
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 }}-${{ inputs.main_branch }}
|
||||||
@@ -169,20 +156,11 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: ccache -s
|
run: ccache -s
|
||||||
|
|
||||||
- name: Save ccache directory for default branch
|
- name: Save ccache directory
|
||||||
if: always() && inputs.ccache_enabled == 'true' && steps.safe-branch.outputs.name == inputs.main_branch
|
if: always() && inputs.ccache_enabled == 'true'
|
||||||
uses: ./.github/actions/xahau-actions-cache-save
|
uses: ./.github/actions/xahau-actions-cache-save
|
||||||
with:
|
with:
|
||||||
path: ~/.ccache-main
|
path: ~/.ccache
|
||||||
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ inputs.main_branch }}
|
|
||||||
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
|
||||||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
|
||||||
|
|
||||||
- name: Save ccache directory for current branch
|
|
||||||
if: always() && inputs.ccache_enabled == 'true' && steps.safe-branch.outputs.name != inputs.main_branch
|
|
||||||
uses: ./.github/actions/xahau-actions-cache-save
|
|
||||||
with:
|
|
||||||
path: ~/.ccache-current
|
|
||||||
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ steps.safe-branch.outputs.name }}
|
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ steps.safe-branch.outputs.name }}
|
||||||
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
||||||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
||||||
|
|||||||
1
.github/workflows/xahau-ga-nix.yml
vendored
1
.github/workflows/xahau-ga-nix.yml
vendored
@@ -237,7 +237,6 @@ jobs:
|
|||||||
max_size: 2G
|
max_size: 2G
|
||||||
hash_dir: true
|
hash_dir: true
|
||||||
compiler_check: content
|
compiler_check: content
|
||||||
is_main_branch: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
|
|
||||||
|
|
||||||
- name: Configure Conan
|
- name: Configure Conan
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user