Skip to content

Commit

Permalink
Set up a simple CI profiling step using nixprof
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka committed Aug 22, 2022
1 parent e36a34c commit d02107e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ steps:
agents:
system: x86_64-linux

- label: 'Run profile with ghc8107'
command: "nix shell github:Kha/nixprof -c ./test/profile.sh ghc8107"
agents:
system: x86_64-linux

- label: 'Check that jobset will evaluate in Hydra'
command:
- nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
Expand Down
34 changes: 34 additions & 0 deletions test/profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash jq nix gnused

set -euo pipefail

# check if Nix has the `ca-derivations` experimental features (code 0) is enabled
NIX_CA_DERIVATIONS=$(jq -e '."experimental-features".value|any(. == 0)' <<< $(nix show-config --json)) || true
NIX_BUILD_ARGS="${NIX_BUILD_ARGS:-}"

cd $(dirname $0)

if [ "$#" != "1" ]; then
echo "Please pass a compiler-nix-name to use. For example: ./test/profile.sh ghc884"
exit 1
fi

GHC=$1

printf "*** Cleaning package build directories..." >& 2
rm -rvf */cabal.project.local */.ghc.environment* */dist */dist-newstyle */.stack-work
echo >& 2

printf "*** Profile the nix build...\n" >& 2
nixprof record nix build $NIX_BUILD_ARGS \
-I . -I .. \
--option restrict-eval true \
--option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
--no-link --keep-going -f default.nix \
--argstr compiler-nix-name $GHC \
--arg CADerivationsEnabled $NIX_CA_DERIVATIONS
nixprof report
echo >& 2

printf "\n*** Finished successfully\n" >& 2

0 comments on commit d02107e

Please sign in to comment.