Skip to content

Commit

Permalink
travis: split build into matrix of 3
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthewbauer committed Jul 12, 2016
1 parent dde259d commit f76e5ab
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 53 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
109 changes: 61 additions & 48 deletions maintainers/scripts/travis-nox-review-pr.sh
Original file line number Diff line number Diff line change
@@ -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
fi

# 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'
while test -n "$1"; do

# 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
# tell Travis to use folding
echo -en "travis_fold:start:$1\r"

case $1 in

install)
echo "=== Installing Nix..."

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."
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
exit 1
fi
fi
else
echo "$0: Unknown option $1" >&2
false
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

0 comments on commit f76e5ab

Please sign in to comment.