2019-07-30 13:39:29 +02:00
|
|
|
language: nix
|
2019-11-09 15:19:21 +01:00
|
|
|
arch:
|
|
|
|
- amd64
|
|
|
|
- arm64
|
2019-08-15 00:46:21 +02:00
|
|
|
services:
|
|
|
|
- docker
|
2019-08-19 02:36:32 +02:00
|
|
|
env:
|
2019-09-21 13:18:04 +02:00
|
|
|
- NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/5271f8dddc0f2e54f55bd2fc1868c09ff72ac980.tar.gz
|
2019-08-04 02:30:24 +02:00
|
|
|
before_script:
|
2019-11-09 15:19:21 +01:00
|
|
|
- echo "Running Nixery CI build on $(uname -m)"
|
2019-08-19 02:34:20 +02:00
|
|
|
- mkdir test-files
|
|
|
|
- echo ${GOOGLE_KEY} | base64 -d > test-files/key.json
|
|
|
|
- echo ${GCS_SIGNING_PEM} | base64 -d > test-files/gcs.pem
|
|
|
|
- nix-env -f '<nixpkgs>' -iA cachix -A go
|
|
|
|
- cachix use nixery
|
2019-08-04 02:30:24 +02:00
|
|
|
script:
|
2019-08-15 00:46:21 +02:00
|
|
|
- test -z $(gofmt -l server/ build-image/)
|
2019-11-09 15:30:48 +01:00
|
|
|
- nix-build --arg maxLayers 1 | cachix push nixery
|
2019-08-15 00:46:21 +02:00
|
|
|
|
|
|
|
# This integration test makes sure that the container image built
|
|
|
|
# for Nixery itself runs fine in Docker, and that images pulled
|
|
|
|
# from it work in Docker.
|
|
|
|
#
|
|
|
|
# Output from the Nixery container is printed at the end of the
|
|
|
|
# test regardless of test status.
|
|
|
|
- IMG=$(docker load -q -i $(nix-build -A nixery-image) | awk '{ print $3 }')
|
|
|
|
- echo "Loaded Nixery image as ${IMG}"
|
|
|
|
|
|
|
|
- |
|
|
|
|
docker run -d -p 8080:8080 --name nixery \
|
|
|
|
-v ${PWD}/test-files:/var/nixery \
|
|
|
|
-e PORT=8080 \
|
2019-10-28 20:04:59 +01:00
|
|
|
-e GCS_BUCKET=nixery-ci-tests \
|
2019-08-15 00:46:21 +02:00
|
|
|
-e GOOGLE_CLOUD_PROJECT=nixery \
|
|
|
|
-e GOOGLE_APPLICATION_CREDENTIALS=/var/nixery/key.json \
|
2019-09-08 22:53:22 +02:00
|
|
|
-e NIXERY_CHANNEL=nixos-unstable \
|
2019-10-28 20:04:59 +01:00
|
|
|
-e NIXERY_STORAGE_BACKEND=gcs \
|
2019-08-15 00:46:21 +02:00
|
|
|
${IMG}
|
|
|
|
|
|
|
|
# print all of the container's logs regardless of success
|
|
|
|
- |
|
|
|
|
function print_logs {
|
|
|
|
echo "Nixery container logs:"
|
|
|
|
docker logs nixery
|
|
|
|
}
|
|
|
|
trap print_logs EXIT
|
|
|
|
|
|
|
|
# Give the container ~20 seconds to come up
|
|
|
|
- |
|
|
|
|
attempts=0
|
|
|
|
echo -n "Waiting for Nixery to start ..."
|
|
|
|
until $(curl --fail --silent "http://localhost:8080/v2/"); do
|
|
|
|
[[ attempts -eq 30 ]] && echo "Nixery container failed to start!" && exit 1
|
|
|
|
((attempts++))
|
|
|
|
echo -n "."
|
|
|
|
sleep 1
|
|
|
|
done
|
2019-11-09 15:30:01 +01:00
|
|
|
|
|
|
|
# Pull and run an image of the current CPU architecture
|
|
|
|
- |
|
|
|
|
case $(uname -m) in
|
|
|
|
x86_64)
|
|
|
|
docker run --rm localhost:8080/hello hello
|
|
|
|
;;
|
|
|
|
aarch64)
|
|
|
|
docker run --rm localhost:8080/arm64/hello hello
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Pull an image of the opposite CPU architecture (but without running it)
|
|
|
|
- |
|
|
|
|
case $(uname -m) in
|
|
|
|
x86_64)
|
|
|
|
docker pull localhost:8080/arm64/hello
|
|
|
|
;;
|
|
|
|
aarch64)
|
|
|
|
docker pull localhost:8080/hello
|
|
|
|
;;
|
|
|
|
esac
|