about summary refs log tree commit diff
path: root/maintainers/scripts/travis-nox-review-pr.sh
blob: a366ac435bd1092defaf34a49aed3178ade76874 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/env bash
set -e

export NIX_CURL_FLAGS=-sS

if [[ $1 == nix ]]; then
    echo "=== Installing Nix..."
    # Install Nix
    bash <(curl -sS https://nixos.org/nix/install)
    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'

    # Nix builds in /tmp and we need exec support
    sudo mount
    sudo mount -o remount,exec /run

    # 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
        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