From 02a5f431aeb3699a1da432d89c6b1f5e45addbc3 Mon Sep 17 00:00:00 2001 From: Samuel Leathers Date: Tue, 3 Jul 2018 14:10:03 -0400 Subject: [PATCH] [DEVOPS-779] simplify CI setup with buildkite hooks --- .buildkite/hooks/pre-command | 22 ++++++++++++++++++++++ .buildkite/pipeline.yml | 12 ++++++------ pkgs/generate.sh | 2 +- scripts/check-stack2nix.sh | 3 ++- 4 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 .buildkite/hooks/pre-command diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command new file mode 100644 index 00000000000..23080023376 --- /dev/null +++ b/.buildkite/hooks/pre-command @@ -0,0 +1,22 @@ +set -x + +case $(uname -s | tr '[:upper:]' '[:lower:]') in + linux ) NIX_PROFILE_BINPATH=/run/current-system/sw/bin/;; + darwin ) NIX_PROFILE_BINPATH=/nix/var/nix/profiles/default/bin;; + * ) echo "Unsupported OS: $OS_NAME" >&2; exit 1;; +esac + +# Bootstrap on OS X/NixOS: + +NIX_BUILD="$(type -P nix-build)" +NIX_BUILD="${NIX_BUILD:-$NIX_PROFILE_BINPATH/nix-build}" +NIX_SHELL="$(type -P nix-shell)" +NIX_SHELL="${NIX_SHELL:-$NIX_PROFILE_BINPATH/nix-shell}" +NIX_BUILD_SHELL="$(type -P bash)" +NIX_BUILD_SHELL="${NIX_BUILD_SHELL:-$NIX_PROFILE_BINPATH/bash}" + +export NIX_REMOTE=daemon +NIX_PATH="nixpkgs=$(${NIX_BUILD} fetch-nixpkgs.nix -o nixpkgs)" +export PATH=$NIX_PROFILE_BINPATH:$PATH +export NIX_PATH +export NIX_BUILD_SHELL diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index b128c39aa81..f22e3e8b248 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,30 +1,30 @@ steps: - label: 'hlint' - command: 'scripts/ci/nix-shell.sh -p hlint moreutils --run scripts/haskell/lint.sh' + command: 'nix-shell -p hlint moreutils --run scripts/haskell/lint.sh' agents: system: x86_64-linux - label: 'stack2nix' - command: 'scripts/ci/nix-shell.sh -p cabal2nix stack cabal-install ghc moreutils expect -Q -j 4 --run scripts/check-stack2nix.sh' + command: 'nix-shell -Q -j 4 --run scripts/check-stack2nix.sh' agents: system: x86_64-linux - label: 'cardano-x86_64-linux' - command: 'scripts/ci/nix-shell.sh --run scripts/ci/ci.sh' + command: 'nix-shell --run scripts/ci/ci.sh' agents: system: x86_64-linux - label: 'cardano-x86_64-darwin' - command: 'scripts/ci/nix-shell.sh --run scripts/ci/ci.sh' + command: 'nix-shell --run scripts/ci/ci.sh' agents: system: x86_64-darwin - label: 'release.nix' - command: 'scripts/ci/nix-shell.sh --run scripts/ci/check-hydra.sh' + command: 'nix-shell --run scripts/ci/check-hydra.sh' agents: system: x86_64-linux - label: 'explorer frontend: checking generated dependencies' - command: 'scripts/ci/nix-shell.sh --run "cd explorer/frontend && ./nix/generate-frontend-deps.hs --test"' + command: "cd explorer/frontend && ./nix/generate-frontend-deps.hs --test" agents: system: x86_64-linux diff --git a/pkgs/generate.sh b/pkgs/generate.sh index bb8765a6cf3..8225cd84fce 100755 --- a/pkgs/generate.sh +++ b/pkgs/generate.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash +#!nix-shell -i bash -p bash cabal2nix stack cabal-install ghc # regenerate the `pkgs/default.nix` file based on the current contents of cardano-sl.cabal and stack.yaml diff --git a/scripts/check-stack2nix.sh b/scripts/check-stack2nix.sh index 5a4ebb3c14d..84435e7ed52 100755 --- a/scripts/check-stack2nix.sh +++ b/scripts/check-stack2nix.sh @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p git bash # check and warn if `pkgs/default.nix` is out of date