From f0314cd86e9ce1b8bc644e1bec75ccd170f8b86d Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 12 Sep 2016 12:38:52 -0700 Subject: [PATCH] Parallelize Docker builds Log output to docker/logs. --- docker/.gitignore | 3 ++ docker/launch.sh | 56 ++++++++++++++++++++++---------------- docker/unstable/.gitignore | 1 - 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 docker/.gitignore delete mode 100644 docker/unstable/.gitignore diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 000000000..bb538ed89 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1,3 @@ +logs/*.log +packages/ +unstable/*/bootstrap.ps1 diff --git a/docker/launch.sh b/docker/launch.sh index 71430f0a6..91c8329ad 100755 --- a/docker/launch.sh +++ b/docker/launch.sh @@ -21,31 +21,39 @@ if [[ -z $DISTROS ]]; then fi for build in $BUILDS; do - # cd so $distro is only the distro name - pushd "$build" + # each distro can be done in parallel; but stable must be done before unstable for distro in $DISTROS; do - image="powershell/powershell:$build-$distro" - if [[ "$TEST" -eq 1 ]]; then - echo "Testing $image" - command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester -powershell powershell -Pester ./src/Modules/Shared/Pester" - # clone repo for stable images because it's not already done - if [[ "$build" = stable ]]; then - command="git clone --recursive https://github.com/$FORK/PowerShell -b $BRANCH; $command" + logfile="$build-$distro.log" + if [[ "$TEST" -eq 1 ]]; then logfile="test-$logfile"; fi + mkdir -p logs + logfile="logs/$logfile" + echo "Logging to docker/$logfile" + ( + image="powershell/powershell:$build-$distro" + cd "$build" + if [[ "$TEST" -eq 1 ]]; then + echo "LOG: testing $image" + command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester -powershell powershell -Pester ./src/Modules/Shared/Pester" + # clone repo for stable images because it's not already done + if [[ "$build" = stable ]]; then + command="git clone --recursive https://github.com/$FORK/PowerShell -b $BRANCH; $command" + fi + # run Pester tests inside container + # RUNARGS can be set in the environment + docker run $RUNARGS "$image" -c "$command" + else + echo "LOG: building $image" + # copy the common script because it lives outside the docker build context + if [[ "$build" = unstable ]]; then + cp bootstrap.ps1 "$distro" + buildargs="--build-arg fork=$FORK --build-arg branch=$BRANCH" + fi + # build and tag the image so they can be derived from + # BUILDARGS can be set in the environment + docker build $buildargs $BUILDARGS -t "$image" "$distro" fi - # run Pester tests inside container - # RUNARGS can be set in the environment - docker run -it $RUNARGS "$image" -c "$command" - else - echo "Building $image" - # copy the common script because it lives outside the docker build context - if [[ "$build" = unstable ]]; then - cp bootstrap.ps1 "$distro" - buildargs="--build-arg fork=$FORK --build-arg branch=$BRANCH" - fi - # build and tag the image so they can be derived from - # BUILDARGS can be set in the environment - docker build $buildargs $BUILDARGS -t "$image" "$distro" - fi + ) &>> "$logfile" & done - popd + echo "Waiting for $build containers to finish; tail the logs for more information." + wait done diff --git a/docker/unstable/.gitignore b/docker/unstable/.gitignore deleted file mode 100644 index c1ce1f3f4..000000000 --- a/docker/unstable/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*/bootstrap.ps1