Merge pull request #206 from dnephin/why-cross-so-slow

Faster CI
This commit is contained in:
Vincent Demeester 2017-07-13 09:36:18 +02:00 committed by GitHub
commit e3746d388e
4 changed files with 54 additions and 63 deletions

View File

@ -7,7 +7,9 @@ jobs:
docker: [{image: 'docker:17.05-git'}] docker: [{image: 'docker:17.05-git'}]
steps: steps:
- checkout - checkout
- setup_remote_docker - setup_remote_docker:
reusable: true
exclusive: false
- run: - run:
command: docker version command: docker version
- run: - run:
@ -15,23 +17,32 @@ jobs:
command: | command: |
dockerfile=dockerfiles/Dockerfile.lint dockerfile=dockerfiles/Dockerfile.lint
echo "COPY . ." >> $dockerfile echo "COPY . ." >> $dockerfile
docker build -f $dockerfile --tag cli-linter . docker build -f $dockerfile --tag cli-linter:$CIRCLE_BUILD_NUM .
docker run cli-linter docker run --rm cli-linter:$CIRCLE_BUILD_NUM
cross: cross:
working_directory: /work working_directory: /work
docker: [{image: 'docker:17.05-git'}] docker: [{image: 'docker:17.05-git'}]
parallelism: 3
steps: steps:
- checkout - checkout
- setup_remote_docker - setup_remote_docker:
reusable: true
exclusive: false
- run: - run:
name: "Cross" name: "Cross"
command: | command: |
dockerfile=dockerfiles/Dockerfile.cross dockerfile=dockerfiles/Dockerfile.cross
echo "COPY . ." >> $dockerfile echo "COPY . ." >> $dockerfile
docker build -f $dockerfile --tag cli-builder . docker build -f $dockerfile --tag cli-builder:$CIRCLE_BUILD_NUM .
docker run --name cross cli-builder make cross name=cross-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX
docker cp cross:/go/src/github.com/docker/cli/build /work/build docker run \
-e CROSS_GROUP=$CIRCLE_NODE_INDEX \
--name $name cli-builder:$CIRCLE_BUILD_NUM \
make cross
docker cp \
$name:/go/src/github.com/docker/cli/build \
/work/build
- store_artifacts: - store_artifacts:
path: /work/build path: /work/build
@ -40,19 +51,25 @@ jobs:
docker: [{image: 'docker:17.05-git'}] docker: [{image: 'docker:17.05-git'}]
steps: steps:
- checkout - checkout
- setup_remote_docker - setup_remote_docker:
reusable: true
exclusive: false
- run: - run:
name: "Unit Test with Coverage" name: "Unit Test with Coverage"
command: | command: |
dockerfile=dockerfiles/Dockerfile.dev dockerfile=dockerfiles/Dockerfile.dev
echo "COPY . ." >> $dockerfile echo "COPY . ." >> $dockerfile
docker build -f $dockerfile --tag cli-builder . docker build -f $dockerfile --tag cli-builder:$CIRCLE_BUILD_NUM .
docker run --name test cli-builder make test-coverage docker run --name \
test-$CIRCLE_BUILD_NUM cli-builder:$CIRCLE_BUILD_NUM \
make test-coverage
- run: - run:
name: "Upload to Codecov" name: "Upload to Codecov"
command: | command: |
docker cp test:/go/src/github.com/docker/cli/coverage.txt coverage.txt docker cp \
test-$CIRCLE_BUILD_NUM:/go/src/github.com/docker/cli/coverage.txt \
coverage.txt
apk add -U bash curl apk add -U bash curl
curl -s https://codecov.io/bash | bash curl -s https://codecov.io/bash | bash
@ -60,16 +77,20 @@ jobs:
working_directory: /work working_directory: /work
docker: [{image: 'docker:17.05-git'}] docker: [{image: 'docker:17.05-git'}]
steps: steps:
- run: apk add -U git openssh
- checkout - checkout
- setup_remote_docker - setup_remote_docker:
reusable: true
exclusive: false
- run: - run:
name: "Validate Vendor, Docs, and Code Generation" name: "Validate Vendor, Docs, and Code Generation"
command: | command: |
dockerfile=dockerfiles/Dockerfile.dev dockerfile=dockerfiles/Dockerfile.dev
echo "COPY . ." >> $dockerfile echo "COPY . ." >> $dockerfile
rm -f .dockerignore # include .git rm -f .dockerignore # include .git
docker build -f $dockerfile --tag cli-builder . docker build -f $dockerfile --tag cli-builder-with-git:$CIRCLE_BUILD_NUM .
docker run cli-builder make -B vendor compose-jsonschema manpages yamldocs docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \
make -B vendor compose-jsonschema manpages yamldocs
workflows: workflows:
version: 2 version: 2

View File

@ -1,18 +1,2 @@
FROM dockercore/golang-cross@sha256:d24e7affa3a85d460d2303c2549f03fc866f2b97d771ccf07b0e6e2b411dd207
FROM golang:1.8.3
# allow replacing httpredir or deb mirror
ARG APT_MIRROR=deb.debian.org
RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
RUN apt-get update -qq && apt-get install -y -q \
libltdl-dev \
gcc-mingw-w64 \
parallel \
;
COPY dockerfiles/osx-cross.sh /tmp/
RUN /tmp/osx-cross.sh
ENV PATH /osxcross/target/bin:$PATH
WORKDIR /go/src/github.com/docker/cli WORKDIR /go/src/github.com/docker/cli

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
#
# Install dependencies required to cross compile osx, then cleanup
#
# TODO: this should be a separate build stage when CI supports it
set -eu -o pipefail
PKG_DEPS="patch xz-utils clang"
apt-get update -qq
apt-get install -y -q $PKG_DEPS
OSX_SDK=MacOSX10.11.sdk
OSX_CROSS_COMMIT=a9317c18a3a457ca0a657f08cc4d0d43c6cf8953
OSXCROSS_PATH="/osxcross"
echo "Cloning osxcross"
time git clone https://github.com/tpoechtrager/osxcross.git $OSXCROSS_PATH
cd $OSXCROSS_PATH
git checkout -q $OSX_CROSS_COMMIT
echo "Downloading OSX SDK"
time curl -sSL https://s3.dockerproject.org/darwin/v2/${OSX_SDK}.tar.xz \
-o "${OSXCROSS_PATH}/tarballs/${OSX_SDK}.tar.xz"
echo "Building osxcross"
UNATTENDED=yes OSX_VERSION_MIN=10.6 ${OSXCROSS_PATH}/build.sh > /dev/null

View File

@ -6,13 +6,28 @@
set -eu -o pipefail set -eu -o pipefail
BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export SHELL=bash
echo "Building binaries for all platforms" jobs=(
SHELL=/bin/bash parallel ::: \
"$BUILDDIR/windows" \ "$BUILDDIR/windows" \
"$BUILDDIR/osx" \ "$BUILDDIR/osx" \
"GOOS=linux GOARCH=amd64 $BUILDDIR/binary" \ "GOOS=linux GOARCH=amd64 $BUILDDIR/binary" \
"GOOS=linux GOARCH=arm $BUILDDIR/binary" \ "GOOS=linux GOARCH=arm $BUILDDIR/binary" \
"GOOS=linux GOARCH=ppc64le $BUILDDIR/binary" \ "GOOS=linux GOARCH=ppc64le $BUILDDIR/binary" \
"GOOS=linux GOARCH=s390x $BUILDDIR/binary" \ "GOOS=linux GOARCH=s390x $BUILDDIR/binary" \
; )
# Outside of circleCI run all at once. On circleCI run two at a time because
# each continer has access to two cores.
group=${CROSS_GROUP-"all"}
if [ "$group" == "all" ]; then
echo "Building binaries for all platforms"
parallel ::: "${jobs[@]}"
exit 0
fi
declare -i start=$group*2
parallel ::: "${jobs[@]:$start:2}"