Skip to content

Commit 08c8975

Browse files
committed
Make ci-build.sh idempotent
save build to cache before check-test-tx-meta to maximize hits comment Remove matrix scenario to get most cache hits in expense of slightly longer CI run edit
1 parent 42549ca commit 08c8975

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,24 @@ jobs:
142142
echo Build with $CC and $CXX
143143
echo "Running first scenario"
144144
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }}
145-
echo "Running second scenario with --check-test-tx-meta flag"
146-
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }} --check-test-tx-meta
147145
148146
# We only _save_ to the cache when we had a cache miss and are running on master.
149-
- uses: actions/cache/save@v4
147+
- name: Save cache after first build
148+
uses: actions/cache/save@v4
150149
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.ref_name == 'master' }}
151150
with:
152151
path: ${{ env.CACHED_PATHS }}
153-
key: ${{ steps.cache.outputs.cache-primary-key }}
152+
key: ${{ steps.cache.outputs.cache-primary-key }}
153+
154+
- name: Build for check-test-tx-meta scenario
155+
if: steps.cache.outputs.cache-hit != 'true'
156+
run: |
157+
if test "${{ matrix.toolchain }}" = "gcc" ; then
158+
export CC='gcc'
159+
export CXX='g++'
160+
else
161+
export CC='clang'
162+
export CXX='clang++'
163+
fi
164+
echo "Running second scenario with --check-test-tx-meta flag"
165+
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }} --check-test-tx-meta

ci-build.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ echo "Found $NPROCS processors"
6969
date
7070

7171
# Try to ensure we're using the real g++ and clang++ versions we want
72-
mkdir bin
72+
mkdir -p bin
7373

7474
export PATH=`pwd`/bin:$PATH
7575
echo "PATH is $PATH"
@@ -80,19 +80,19 @@ if test $CXX = 'clang++'; then
8080
# Use CLANG_VERSION environment variable if set, otherwise default to 12
8181
CLANG_VER=${CLANG_VERSION:-12}
8282
which clang-${CLANG_VER}
83-
ln -s `which clang-${CLANG_VER}` bin/clang
83+
ln -sf `which clang-${CLANG_VER}` bin/clang
8484
which clang++-${CLANG_VER}
85-
ln -s `which clang++-${CLANG_VER}` bin/clang++
85+
ln -sf `which clang++-${CLANG_VER}` bin/clang++
8686
which llvm-symbolizer-${CLANG_VER}
87-
ln -s `which llvm-symbolizer-${CLANG_VER}` bin/llvm-symbolizer
87+
ln -sf `which llvm-symbolizer-${CLANG_VER}` bin/llvm-symbolizer
8888
clang -v
8989
llvm-symbolizer --version || true
9090
elif test $CXX = 'g++'; then
9191
RUN_PARTITIONS=$(seq $NPROCS $((2*NPROCS-1)))
9292
which gcc-10
93-
ln -s `which gcc-10` bin/gcc
93+
ln -sf `which gcc-10` bin/gcc
9494
which g++-10
95-
ln -s `which g++-10` bin/g++
95+
ln -sf `which g++-10` bin/g++
9696
which g++
9797
g++ -v
9898
fi
@@ -165,13 +165,15 @@ if [ $WITH_TESTS -eq 0 ] ; then
165165
fi
166166

167167
if [ $TEMP_POSTGRES -eq 0 ] ; then
168-
# Create postgres databases
168+
# Create postgres databases (drop first if they exist to ensure clean state)
169169
export PGUSER=postgres
170+
psql -c "drop database if exists test;" 2>/dev/null || true
170171
psql -c "create database test;"
171172
# we run NPROCS jobs in parallel
172173
for j in $(seq 0 $((NPROCS-1))); do
173174
base_instance=$((j*50))
174175
for i in $(seq $base_instance $((base_instance+15))); do
176+
psql -c "drop database if exists test$i;" 2>/dev/null || true
175177
psql -c "create database test$i;"
176178
done
177179
done

0 commit comments

Comments
 (0)