Skip to content

Commit

Permalink
ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ffaerber committed Nov 21, 2017
1 parent b3cd001 commit c970543
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 26 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ env:
- ARCH=arm32v7

script:
- chmod +x ./travis-deploy.sh
- ./travis-deploy.sh
- chmod +x ./travis-build.sh
- ./travis-build.sh
- >
if [ -n "$TRAVIS_TAG" ]; then
travis_retry timeout 5m docker login -u="$DOCKER_USER" -p="$DOCKER_PASS"
./travis-deploy.sh
fi
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
ARG ARCH=amd64
FROM ${ARCH}/ubuntu:17.04

# RUN [ -f tmp/qemu-arm-static ] && cp tmp/qemu-arm-static /usr/bin/qemu-arm-static || echo "no qemu bin found"
COPY tmp/qemu-arm-static /usr/bin/qemu-arm-static
FROM ${ARCH}/debian:stretch-slim

RUN apt-get update && \
apt-get install -y \
Expand Down
25 changes: 25 additions & 0 deletions travis-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e

echo "Updating Docker engine"
sudo service docker stop
curl -fsSL https://get.docker.com/ | sudo sh
docker version

if [ "$ARCH" != "amd64" ]; then
# prepare qemu
docker run --rm --privileged multiarch/qemu-user-static:register --reset

if [ "$ARCH" == "arm64" ]; then
# prepare qemu binary
docker create --name register hypriot/qemu-register
docker cp register:qemu-aarch64 qemu-aarch64-static
fi
fi

if [ -d tmp ]; then
docker rm build
rm -rf tmp
fi

docker build -t ffaerber/appsample:build --build-arg ARCH=$ARCH .
54 changes: 34 additions & 20 deletions travis-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
#!/bin/bash
set -e
if [ "$TRAVIS_TAG" ]; then
docker version
uname -a
echo "Updating Docker engine to latest version"
sudo service docker stop
curl -fsSL https://get.docker.com/ | sudo sh
docker version

docker login -u="$DOCKER_USER" -p="$DOCKER_PASS"
image="ffaerber/appsample"

docker run --rm --privileged multiarch/qemu-user-static:register --reset
mkdir tmp
pushd tmp &&
curl -L -o qemu-arm-static.tar.gz https://github.com/multiarch/qemu-user-static/releases/download/v2.9.1-1/qemu-arm-static.tar.gz &&
tar xzf qemu-arm-static.tar.gz &&
popd
docker tag appsample "$image:linux-$ARCH-$TRAVIS_TAG"
docker push "$image:linux-$ARCH-$TRAVIS_TAG"

docker build -t ffaerber/appsample:build --build-arg ARCH=$ARCH . --no-cache
docker run ffaerber/appsample:build uname -a
if [ "$ARCH" == "amd64" ]; then
set +e
echo "Waiting for other images $image:linux-arm-$TRAVIS_TAG"
until docker run --rm stefanscherer/winspector "$image:linux-arm-$TRAVIS_TAG"
do
sleep 15
echo "Try again"
done
until docker run --rm stefanscherer/winspector "$image:linux-arm64-$TRAVIS_TAG"
do
sleep 15
echo "Try again"
done
set -e

docker tag ffaerber/appsample:build ffaerber/appsample:$TRAVIS_TAG-$ARCH
docker tag ffaerber/appsample:build ffaerber/appsample:latest-$ARCH
docker push ffaerber/appsample:$TRAVIS_TAG-$ARCH
docker push ffaerber/appsample:latest-$ARCH
echo "Downloading manifest-tool"
wget https://github.com/estesp/manifest-tool/releases/download/v0.5.0/manifest-tool-linux-amd64
mv manifest-tool-linux-amd64 manifest-tool
chmod +x manifest-tool
./manifest-tool

echo "Pushing manifest $image:$TRAVIS_TAG"
./manifest-tool push from-args \
--platforms linux/amd64,linux/arm \
--template "$image:OS-ARCH-$TRAVIS_TAG" \
--target "$image:$TRAVIS_TAG"

echo "Pushing manifest $image:latest"
./manifest-tool push from-args \
--platforms linux/amd64,linux/arm \
--template "$image:OS-ARCH-$TRAVIS_TAG" \
--target "$image:latest"
fi

0 comments on commit c970543

Please sign in to comment.