Skip to content

Commit

Permalink
Merge pull request #823 from nextcloud/maintenance/no-build-on-ci
Browse files Browse the repository at this point in the history
Speed up CI build by using docker cache
  • Loading branch information
christianlupus committed Oct 21, 2021
2 parents 7332153 + cf24b6c commit 790dfe7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/actions/run-tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.1"
version: "3.2"

services:
mysql:
Expand All @@ -18,6 +18,8 @@ services:
dut: &dut
build:
context: ./tests
cache_from:
- cookbook_unittesting_dut
#args:
#PHPVERSION: 7
#UID: 1000
Expand Down
36 changes: 32 additions & 4 deletions .github/actions/run-tests/run-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ list_env_dumps() {
pull_images() {
echo 'Pulling pre-built images.'
docker-compose pull --quiet

toc

if docker pull "nextcloudcookbook/testci:php$PHP_VERSION"; then
if docker pull --quiet "nextcloudcookbook/testci:php$PHP_VERSION"; then
docker tag "nextcloudcookbook/testci:php$PHP_VERSION" cookbook_unittesting_dut
fi

toc

echo 'Pulling images finished.'
}

build_images() {
pull_images

echo 'Building the images.'
local PROGRESS=''
if [ -n "$CI" ]; then
Expand Down Expand Up @@ -192,6 +194,7 @@ shutdown_helpers(){

setup_server(){
echo 'Setup of the server environment.'
toc

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

toc

echo 'Creating cookbook folder for later bind-merge'
pushd volumes/nextcloud > /dev/null
mkdir -p custom_apps/cookbook data
Expand Down Expand Up @@ -773,15 +778,27 @@ printCI() {
fi
}

tic() {
TIC=$(date +%s.%3N)
}

toc() {
local TOC=$(date +%s.3N)
local diff=$(echo "scale=3; $TOC - $TIC" | bc)
# return "$diff"
printCI "Elapsed time: $diff seconds"
}

echo 'Starting process'

printCI "::group::Prepare docker"
tic

if [ -n "$COPY_ENV_SRC" ]; then
copy_environment
fi

if [ $DOCKER_PULL = 'y' ]; then
if [ $DOCKER_PULL = 'y' -o $CREATE_IMAGES = 'y' -o $CREATE_IMAGES_IF_NEEDED = 'y' ]; then
pull_images
fi

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

printCI "::endgroup::"
toc
printCI "::group::Preparing environment"
tic

create_file_structure

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

printCI "::endgroup::"
toc
printCI "::group::Environment dump handling"
tic

if [ $DROP_ENV_DUMP = 'y' ]; then
drop_env_dump
Expand All @@ -842,24 +863,31 @@ if [ $RESTORE_ENV_DUMP = 'y' ]; then
fi

printCI "::endgroup::"
toc
printCI "::group::Postprocessing environemnt preparation"
tic

if [ $START_HELPERS = 'y' ]; then
start_helpers_post
fi

printCI "::endgroup::"
toc

tic
if [ $RUN_UNIT_TESTS = 'y' -o $RUN_INTEGRATION_TESTS = 'y' ]; then
run_tests "$@"
fi
toc

printCI "::group::Clean-Up"
tic

if [ $SHUTDOWN_HELPERS = 'y' ]; then
shutdown_helpers
fi

printCI "::endgroup::"
toc

echo "Processing finished"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Unreleased]

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


## 0.9.6 - 2021-10-18

Expand Down

0 comments on commit 790dfe7

Please sign in to comment.