mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
ci: Improve cache implementation (#2780)
This commit is contained in:
36
.github/actions/cache-key/action.yml
vendored
Normal file
36
.github/actions/cache-key/action.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: Cache key
|
||||||
|
description: Generate cache key for ccache
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
conan_profile:
|
||||||
|
description: Conan profile name
|
||||||
|
required: true
|
||||||
|
build_type:
|
||||||
|
description: Current build type (e.g. Release, Debug)
|
||||||
|
required: true
|
||||||
|
default: Release
|
||||||
|
code_coverage:
|
||||||
|
description: Whether code coverage is on
|
||||||
|
required: true
|
||||||
|
default: "false"
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
key:
|
||||||
|
description: Generated cache key for ccache
|
||||||
|
value: ${{ steps.key_without_commit.outputs.key }}-${{ steps.git_common_ancestor.outputs.commit }}
|
||||||
|
restore_keys:
|
||||||
|
description: Cache restore keys for fallback
|
||||||
|
value: ${{ steps.key_without_commit.outputs.key }}
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Find common commit
|
||||||
|
id: git_common_ancestor
|
||||||
|
uses: ./.github/actions/git-common-ancestor
|
||||||
|
|
||||||
|
- name: Set cache key without commit
|
||||||
|
id: key_without_commit
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "key=clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-${{ inputs.conan_profile }}-develop" >> "${GITHUB_OUTPUT}"
|
||||||
38
.github/actions/restore-cache/action.yml
vendored
38
.github/actions/restore-cache/action.yml
vendored
@@ -1,38 +0,0 @@
|
|||||||
name: Restore cache
|
|
||||||
description: Find and restores ccache cache
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
conan_profile:
|
|
||||||
description: Conan profile name
|
|
||||||
required: true
|
|
||||||
ccache_dir:
|
|
||||||
description: Path to .ccache directory
|
|
||||||
required: true
|
|
||||||
build_type:
|
|
||||||
description: Current build type (e.g. Release, Debug)
|
|
||||||
required: true
|
|
||||||
default: Release
|
|
||||||
code_coverage:
|
|
||||||
description: Whether code coverage is on
|
|
||||||
required: true
|
|
||||||
default: "false"
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
ccache_cache_hit:
|
|
||||||
description: True if ccache cache has been downloaded
|
|
||||||
value: ${{ steps.ccache_cache.outputs.cache-hit }}
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- name: Find common commit
|
|
||||||
id: git_common_ancestor
|
|
||||||
uses: ./.github/actions/git-common-ancestor
|
|
||||||
|
|
||||||
- name: Restore ccache cache
|
|
||||||
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
||||||
id: ccache_cache
|
|
||||||
if: ${{ env.CCACHE_DISABLE != '1' }}
|
|
||||||
with:
|
|
||||||
path: ${{ inputs.ccache_dir }}
|
|
||||||
key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-${{ inputs.conan_profile }}-develop-${{ steps.git_common_ancestor.outputs.commit }}
|
|
||||||
38
.github/actions/save-cache/action.yml
vendored
38
.github/actions/save-cache/action.yml
vendored
@@ -1,38 +0,0 @@
|
|||||||
name: Save cache
|
|
||||||
description: Save ccache cache for develop branch
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
conan_profile:
|
|
||||||
description: Conan profile name
|
|
||||||
required: true
|
|
||||||
ccache_dir:
|
|
||||||
description: Path to .ccache directory
|
|
||||||
required: true
|
|
||||||
build_type:
|
|
||||||
description: Current build type (e.g. Release, Debug)
|
|
||||||
required: true
|
|
||||||
default: Release
|
|
||||||
code_coverage:
|
|
||||||
description: Whether code coverage is on
|
|
||||||
required: true
|
|
||||||
default: "false"
|
|
||||||
|
|
||||||
ccache_cache_hit:
|
|
||||||
description: Whether ccache cache has been downloaded
|
|
||||||
required: true
|
|
||||||
ccache_cache_miss_rate:
|
|
||||||
description: How many ccache cache misses happened
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- name: Find common commit
|
|
||||||
id: git_common_ancestor
|
|
||||||
uses: ./.github/actions/git-common-ancestor
|
|
||||||
|
|
||||||
- name: Save ccache cache
|
|
||||||
if: ${{ inputs.ccache_cache_hit != 'true' || inputs.ccache_cache_miss_rate == '100.0' }}
|
|
||||||
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
||||||
with:
|
|
||||||
path: ${{ inputs.ccache_dir }}
|
|
||||||
key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-${{ inputs.conan_profile }}-develop-${{ steps.git_common_ancestor.outputs.commit }}
|
|
||||||
15
.github/dependabot.yml
vendored
15
.github/dependabot.yml
vendored
@@ -105,20 +105,7 @@ updates:
|
|||||||
target-branch: develop
|
target-branch: develop
|
||||||
|
|
||||||
- package-ecosystem: github-actions
|
- package-ecosystem: github-actions
|
||||||
directory: .github/actions/restore-cache/
|
directory: .github/actions/cache-key/
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
day: monday
|
|
||||||
time: "04:00"
|
|
||||||
timezone: Etc/GMT
|
|
||||||
reviewers:
|
|
||||||
- XRPLF/clio-dev-team
|
|
||||||
commit-message:
|
|
||||||
prefix: "ci: [DEPENDABOT] "
|
|
||||||
target-branch: develop
|
|
||||||
|
|
||||||
- package-ecosystem: github-actions
|
|
||||||
directory: .github/actions/save-cache/
|
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
day: monday
|
day: monday
|
||||||
|
|||||||
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -83,7 +83,7 @@ jobs:
|
|||||||
conan_profile: gcc
|
conan_profile: gcc
|
||||||
build_type: Debug
|
build_type: Debug
|
||||||
download_ccache: true
|
download_ccache: true
|
||||||
upload_ccache: false
|
upload_ccache: true
|
||||||
code_coverage: true
|
code_coverage: true
|
||||||
static: true
|
static: true
|
||||||
upload_clio_server: false
|
upload_clio_server: false
|
||||||
|
|||||||
7
.github/workflows/clang-tidy.yml
vendored
7
.github/workflows/clang-tidy.yml
vendored
@@ -48,13 +48,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
disable_ccache: true
|
disable_ccache: true
|
||||||
|
|
||||||
- name: Restore cache
|
|
||||||
uses: ./.github/actions/restore-cache
|
|
||||||
id: restore_cache
|
|
||||||
with:
|
|
||||||
conan_profile: ${{ env.CONAN_PROFILE }}
|
|
||||||
ccache_dir: ${{ env.CCACHE_DIR }}
|
|
||||||
|
|
||||||
- name: Run conan
|
- name: Run conan
|
||||||
uses: ./.github/actions/conan
|
uses: ./.github/actions/conan
|
||||||
with:
|
with:
|
||||||
|
|||||||
37
.github/workflows/reusable-build.yml
vendored
37
.github/workflows/reusable-build.yml
vendored
@@ -107,16 +107,24 @@ jobs:
|
|||||||
if: ${{ runner.os == 'macOS' }}
|
if: ${{ runner.os == 'macOS' }}
|
||||||
run: ./.github/scripts/conan/init.sh
|
run: ./.github/scripts/conan/init.sh
|
||||||
|
|
||||||
- name: Restore cache
|
- name: Generate cache key
|
||||||
if: ${{ inputs.download_ccache }}
|
uses: ./.github/actions/cache-key
|
||||||
uses: ./.github/actions/restore-cache
|
id: cache_key
|
||||||
id: restore_cache
|
|
||||||
with:
|
with:
|
||||||
conan_profile: ${{ inputs.conan_profile }}
|
conan_profile: ${{ inputs.conan_profile }}
|
||||||
ccache_dir: ${{ env.CCACHE_DIR }}
|
|
||||||
build_type: ${{ inputs.build_type }}
|
build_type: ${{ inputs.build_type }}
|
||||||
code_coverage: ${{ inputs.code_coverage }}
|
code_coverage: ${{ inputs.code_coverage }}
|
||||||
|
|
||||||
|
- name: Restore ccache cache
|
||||||
|
if: ${{ inputs.download_ccache }}
|
||||||
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
|
id: restore_cache
|
||||||
|
with:
|
||||||
|
path: ${{ env.CCACHE_DIR }}
|
||||||
|
key: ${{ steps.cache_key.outputs.key }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ steps.cache_key.outputs.restore_keys }}
|
||||||
|
|
||||||
- name: Run conan
|
- name: Run conan
|
||||||
uses: ./.github/actions/conan
|
uses: ./.github/actions/conan
|
||||||
with:
|
with:
|
||||||
@@ -161,6 +169,13 @@ jobs:
|
|||||||
echo "miss_rate=${miss_rate}" >> $GITHUB_OUTPUT
|
echo "miss_rate=${miss_rate}" >> $GITHUB_OUTPUT
|
||||||
cat /tmp/ccache.stats
|
cat /tmp/ccache.stats
|
||||||
|
|
||||||
|
- name: Save ccache cache
|
||||||
|
if: ${{ inputs.upload_ccache && github.ref == 'refs/heads/develop' && (steps.restore_cache.outputs.cache-hit != 'true' || steps.ccache_stats.outputs.miss_rate == '100.0') }}
|
||||||
|
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
|
with:
|
||||||
|
path: ${{ env.CCACHE_DIR }}
|
||||||
|
key: ${{ steps.cache_key.outputs.key }}
|
||||||
|
|
||||||
- name: Strip unit_tests
|
- name: Strip unit_tests
|
||||||
if: ${{ !endsWith(inputs.conan_profile, 'san') && !inputs.code_coverage && !inputs.analyze_build_time }}
|
if: ${{ !endsWith(inputs.conan_profile, 'san') && !inputs.code_coverage && !inputs.analyze_build_time }}
|
||||||
run: strip build/clio_tests
|
run: strip build/clio_tests
|
||||||
@@ -197,18 +212,6 @@ jobs:
|
|||||||
name: clio_deb_package_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
|
name: clio_deb_package_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
|
||||||
path: build/*.deb
|
path: build/*.deb
|
||||||
|
|
||||||
- name: Save cache
|
|
||||||
if: ${{ inputs.upload_ccache && github.ref == 'refs/heads/develop' }}
|
|
||||||
uses: ./.github/actions/save-cache
|
|
||||||
with:
|
|
||||||
conan_profile: ${{ inputs.conan_profile }}
|
|
||||||
ccache_dir: ${{ env.CCACHE_DIR }}
|
|
||||||
build_type: ${{ inputs.build_type }}
|
|
||||||
code_coverage: ${{ inputs.code_coverage }}
|
|
||||||
|
|
||||||
ccache_cache_hit: ${{ steps.restore_cache.outputs.ccache_cache_hit }}
|
|
||||||
ccache_cache_miss_rate: ${{ steps.ccache_stats.outputs.miss_rate }}
|
|
||||||
|
|
||||||
# This is run as part of the build job, because it requires the following:
|
# This is run as part of the build job, because it requires the following:
|
||||||
# - source code
|
# - source code
|
||||||
# - conan packages
|
# - conan packages
|
||||||
|
|||||||
Reference in New Issue
Block a user