travis: split build into matrix of 3

This adds a 3rd matrix to be built by Travis. The new matrix "checks"
the NixPkgs evaluation so the other 2 can save their resources for
building. Hopefully, this will lead to less "out of space" errors that
seem to be happening with Travis. Also adds folding.
This commit is contained in:
Matthew Bauer 2016-06-27 21:29:12 +00:00
parent dde259dfb5
commit f76e5ab0cf
2 changed files with 75 additions and 56 deletions

View file

@ -1,14 +1,20 @@
matrix:
allow_failures:
- os: osx
include:
- os: linux
language: generic
sudo: required
dist: trusty
script:
- ./maintainers/scripts/travis-nox-review-pr.sh verify
- ./maintainers/scripts/travis-nox-review-pr.sh check
- ./maintainers/scripts/travis-nox-review-pr.sh tarball
- os: linux
language: generic
sudo: required
dist: trusty
script: ./maintainers/scripts/travis-nox-review-pr.sh pr
- os: osx
language: generic
osx_image: xcode7.3
before_install: ./maintainers/scripts/travis-nox-review-pr.sh nix
install: ./maintainers/scripts/travis-nox-review-pr.sh nox
script: ./maintainers/scripts/travis-nox-review-pr.sh build
script: ./maintainers/scripts/travis-nox-review-pr.sh pr
install: ./maintainers/scripts/travis-nox-review-pr.sh install

View file

@ -1,58 +1,71 @@
#! /usr/bin/env bash
set -e
# This should make Curl silent
# but download-from-binary-cache doesn't respect
export NIX_CURL_FLAGS=-sS
if [[ $1 == nix ]]; then
echo "=== Installing Nix..."
# Install Nix
bash <(curl -sS https://nixos.org/nix/install)
if [ -d $HOME/.nix-profile ]; then
source $HOME/.nix-profile/etc/profile.d/nix.sh
# Make sure we can use hydra's binary cache
sudo mkdir /etc/nix
sudo sh -c 'echo "build-max-jobs = 4" > /etc/nix/nix.conf'
# Verify evaluation
echo "=== Verifying that nixpkgs evaluates..."
nix-env -f. -qa --json >/dev/null
elif [[ $1 == nox ]]; then
source $HOME/.nix-profile/etc/profile.d/nix.sh
echo "=== Installing nox..."
nix-build -A nox '<nixpkgs>' --show-trace
elif [[ $1 == build ]]; then
source $HOME/.nix-profile/etc/profile.d/nix.sh
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
echo "Skipping NixOS things on darwin"
else
# Nix builds in /tmp and we need exec support
sudo mount -o remount,exec /run
sudo mount -o remount,exec /run/user
sudo mount
echo "=== Checking NixOS options"
nix-build nixos/release.nix -A options --show-trace
echo "=== Checking tarball creation"
nix-build pkgs/top-level/release.nix -A tarball --show-trace
fi
if [[ $TRAVIS_PULL_REQUEST == false ]]; then
echo "=== Not a pull request"
else
echo "=== Checking PR"
if ! nix-shell -p nox --run "nox-review pr ${TRAVIS_PULL_REQUEST}"; then
if sudo dmesg | egrep 'Out of memory|Killed process' > /tmp/oom-log; then
echo "=== The build failed due to running out of memory:"
cat /tmp/oom-log
echo "=== Please disregard the result of this Travis build."
fi
exit 1
fi
fi
else
echo "$0: Unknown option $1" >&2
false
fi
while test -n "$1"; do
# tell Travis to use folding
echo -en "travis_fold:start:$1\r"
case $1 in
install)
echo "=== Installing Nix..."
curl -sS https://nixos.org/nix/install | sh
# Make sure we can use hydra's binary cache
sudo mkdir /etc/nix
echo "build-max-jobs = 4" | sudo tee /etc/nix/nix.conf > /dev/null
# Make sure we can execute within /tmp in Linux
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo mount -o remount,exec /run
sudo mount -o remount,exec /run/user
sudo mount > /dev/null
fi
;;
verify)
echo "=== Verifying that nixpkgs evaluates..."
nix-env --file $TRAVIS_BUILD_DIR --query --available --json > /dev/null
;;
check)
echo "=== Checking NixOS options"
nix-build $TRAVIS_BUILD_DIR/nixos/release.nix --attr options --show-trace
;;
tarball)
echo "=== Checking tarball creation"
nix-build $TRAVIS_BUILD_DIR/pkgs/top-level/release.nix --attr tarball --show-trace
;;
pr)
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "=== No pull request found"
else
echo "=== Building pull request #$TRAVIS_PULL_REQUEST"
nix-shell --packages nox git --run "nox-review pr $TRAVIS_PULL_REQUEST" -I nixpkgs=$TRAVIS_BUILD_DIR
fi
;;
*)
echo "Skipping unknown option $1"
;;
esac
echo -en "travis_fold:end:$1\r"
shift
done