Skip to content

Commit 790dfe7

Browse files
Merge pull request #823 from nextcloud/maintenance/no-build-on-ci
Speed up CI build by using docker cache
2 parents 7332153 + cf24b6c commit 790dfe7

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

.github/actions/run-tests/docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.1"
1+
version: "3.2"
22

33
services:
44
mysql:
@@ -18,6 +18,8 @@ services:
1818
dut: &dut
1919
build:
2020
context: ./tests
21+
cache_from:
22+
- cookbook_unittesting_dut
2123
#args:
2224
#PHPVERSION: 7
2325
#UID: 1000

.github/actions/run-tests/run-locally.sh

+32-4
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@ list_env_dumps() {
6767
pull_images() {
6868
echo 'Pulling pre-built images.'
6969
docker-compose pull --quiet
70+
71+
toc
7072

71-
if docker pull "nextcloudcookbook/testci:php$PHP_VERSION"; then
73+
if docker pull --quiet "nextcloudcookbook/testci:php$PHP_VERSION"; then
7274
docker tag "nextcloudcookbook/testci:php$PHP_VERSION" cookbook_unittesting_dut
7375
fi
76+
77+
toc
7478

7579
echo 'Pulling images finished.'
7680
}
7781

7882
build_images() {
79-
pull_images
80-
8183
echo 'Building the images.'
8284
local PROGRESS=''
8385
if [ -n "$CI" ]; then
@@ -192,6 +194,7 @@ shutdown_helpers(){
192194

193195
setup_server(){
194196
echo 'Setup of the server environment.'
197+
toc
195198

196199
echo "Checking out nextcloud server repository"
197200
git clone --depth=1 --branch "$ENV_BRANCH" https://github.com/nextcloud/server volumes/nextcloud
@@ -201,6 +204,8 @@ setup_server(){
201204
git submodule update --init
202205
popd > /dev/null
203206

207+
toc
208+
204209
echo 'Creating cookbook folder for later bind-merge'
205210
pushd volumes/nextcloud > /dev/null
206211
mkdir -p custom_apps/cookbook data
@@ -773,15 +778,27 @@ printCI() {
773778
fi
774779
}
775780

781+
tic() {
782+
TIC=$(date +%s.%3N)
783+
}
784+
785+
toc() {
786+
local TOC=$(date +%s.3N)
787+
local diff=$(echo "scale=3; $TOC - $TIC" | bc)
788+
# return "$diff"
789+
printCI "Elapsed time: $diff seconds"
790+
}
791+
776792
echo 'Starting process'
777793

778794
printCI "::group::Prepare docker"
795+
tic
779796

780797
if [ -n "$COPY_ENV_SRC" ]; then
781798
copy_environment
782799
fi
783800

784-
if [ $DOCKER_PULL = 'y' ]; then
801+
if [ $DOCKER_PULL = 'y' -o $CREATE_IMAGES = 'y' -o $CREATE_IMAGES_IF_NEEDED = 'y' ]; then
785802
pull_images
786803
fi
787804

@@ -804,7 +821,9 @@ if [ $PUSH_IMAGES = 'y' ]; then
804821
fi
805822

806823
printCI "::endgroup::"
824+
toc
807825
printCI "::group::Preparing environment"
826+
tic
808827

809828
create_file_structure
810829

@@ -827,7 +846,9 @@ if [ $SETUP_ENVIRONMENT = 'y' ]; then
827846
fi
828847

829848
printCI "::endgroup::"
849+
toc
830850
printCI "::group::Environment dump handling"
851+
tic
831852

832853
if [ $DROP_ENV_DUMP = 'y' ]; then
833854
drop_env_dump
@@ -842,24 +863,31 @@ if [ $RESTORE_ENV_DUMP = 'y' ]; then
842863
fi
843864

844865
printCI "::endgroup::"
866+
toc
845867
printCI "::group::Postprocessing environemnt preparation"
868+
tic
846869

847870
if [ $START_HELPERS = 'y' ]; then
848871
start_helpers_post
849872
fi
850873

851874
printCI "::endgroup::"
875+
toc
852876

877+
tic
853878
if [ $RUN_UNIT_TESTS = 'y' -o $RUN_INTEGRATION_TESTS = 'y' ]; then
854879
run_tests "$@"
855880
fi
881+
toc
856882

857883
printCI "::group::Clean-Up"
884+
tic
858885

859886
if [ $SHUTDOWN_HELPERS = 'y' ]; then
860887
shutdown_helpers
861888
fi
862889

863890
printCI "::endgroup::"
891+
toc
864892

865893
echo "Processing finished"

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
### Fixed
4+
- CI build always builds docker images from scratch
5+
[#823](https://github.com/nextcloud/cookbook/pull/823) @christianlupus
6+
37

48
## 0.9.6 - 2021-10-18
59

0 commit comments

Comments
 (0)