Skip to content

Commit eca41d7

Browse files
authored
Revise how cache is computed (#220)
Fixes current CI build time issues resulting from cache misses.
1 parent c94336b commit eca41d7

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

.github/workflows/lint.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ jobs:
7171
working-directory: build
7272
run: |
7373
export CONAN_LLVM_GIT_CACHE="${{ runner.temp }}/llvm-project"
74-
conan install .. -pr:h default -pr:b default
75-
if [ $? -ne 0 ]
74+
build_requires=$(conan info .. -pr:h default -pr:b default --build=outdated 2>/dev/null)
75+
if [[ "$build_requires" == *"Outdated package!"* ]];
7676
then
77-
cache_hit=false
77+
all_in_cache=false
7878
else
79-
cache_hit=true
79+
all_in_cache=true
8080
fi
81-
echo "cache_hit=$cache_hit" >> $GITHUB_OUTPUT
82-
echo "Cache was hit: $cache_hit"
81+
echo "all_in_cache=$all_in_cache" >> $GITHUB_OUTPUT
82+
echo "Conan build requires: $build_requires"
83+
echo "Conan cache is complete: $all_in_cache"
8384
- name: Conan install
8485
id: conan_install
8586
working-directory: build

.github/workflows/test.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
# copyright notice, and modified files need to carry a notice indicating
1111
# that they have been altered from the originals.
1212
name: Build
13-
on: [push, pull_request]
13+
on:
14+
push:
15+
branches:
16+
- 'main'
17+
- 'release/**'
18+
- '**/release/**'
19+
pull_request:
20+
types: [opened, reopened, labeled, unlabeled, synchronize]
1421
jobs:
1522
Build:
1623
runs-on: ubuntu-latest
@@ -62,22 +69,22 @@ jobs:
6269
working-directory: build
6370
run: |
6471
export CONAN_LLVM_GIT_CACHE="${{ runner.temp }}/llvm-project"
65-
conan install .. -pr:h default -pr:b default
66-
if [ $? -ne 0 ]
72+
build_requires=$(conan info .. -pr:h default -pr:b default --build=outdated 2>/dev/null)
73+
if [[ "$build_requires" == *"Outdated package!"* ]];
6774
then
68-
cache_hit=false
75+
all_in_cache=false
6976
else
70-
cache_hit=true
77+
all_in_cache=true
7178
fi
72-
echo "cache_hit=$cache_hit" >> $GITHUB_OUTPUT
73-
echo "Cache was hit: $cache_hit"
79+
echo "all_in_cache=$all_in_cache" >> $GITHUB_OUTPUT
80+
echo "Conan build requires: $build_requires"
81+
echo "Conan cache is complete: $all_in_cache"
7482
# If we have a cache miss on 'main', clear the cache.
7583
# A dependency was updated, so we need to drop the old one
7684
# to prevent unbounded cache growth over time.
7785
- name : Clear Conan cache
78-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_conan_cache.outputs.cache_hit != 'true'
86+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_conan_cache.outputs.all_in_cache != 'true'
7987
run: |
80-
echo "Cache was hit: ${{ steps.check_conan_cache.outputs.cache_hit }}"
8188
rm -rf ./.conan
8289
- name: Conan install
8390
id: conan_install
@@ -98,7 +105,7 @@ jobs:
98105
# Note: we only update the cache from 'main' to avoid "cache thrashing", which would result in the 'main'
99106
# cache getting LRU-evicted for every PR, since a single run uses most of the 10GB repo limit.
100107
- uses: actions/cache/save@v3
101-
if: always() && (github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.conan_install.outcome == 'success' && steps.check_conan_cache.outputs.cache_hit != 'true')
108+
if: always() && (github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.conan_install.outcome == 'success' && steps.check_conan_cache.outputs.all_in_cache != 'true')
102109
with:
103110
path: .conan
104111
key: conan-${{ runner.os }}

0 commit comments

Comments
 (0)