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 Sep 15, 2023
1 parent 445086f commit e799d07
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ defaults:
shell: bash

# do we really want nixos-unstable?
env:
env:
NIX_PATH: "nixpkgs=channel:nixos-unstable"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}

jobs:
nix-build:
Expand Down Expand Up @@ -246,3 +248,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: nix build ./nix-tools#checks.x86_64-linux.truncate-index --accept-flake-config

nixprof:
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v3
- name: "Run tests with ghc8107: Profile flakes development shell ..."
run: nix shell github:Kha/nixprof -c ./test/tests.sh ghc8107 nixprof
22 changes: 22 additions & 0 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,26 @@ if [ "$TESTS" == "docs" ] || [ "$TESTS" == "all" ]; then
popd
fi

if [ "$TESTS" == "nixprof" ]; then
printf "*** Profile flakes development shell ...\n" >& 2
cat > Dockerfile <<EOF
FROM nixos/nix
RUN nix-channel --update
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
RUN nix profile install github:Kha/nixprof
RUN nix profile install nixpkgs#time
WORKDIR /workspace
CMD ["sh", "-c", "nixprof record nix develop --accept-flake-config"]
EOF
docker build -t nixprof .
docker run --mount type=bind,source="$(pwd)/..",target=/workspace nixprof
pushd ..
nixprof report -p
nixprof report -a
nixprof report -s
popd
# FIXME: is that the right way to publish a report on GitHub?
# curl -s -H "Authorization: token $GITHUB_TOKEN" -X POST -d "{\"body\": \"$report\"}" "https://api.github.com/repos/input-output-hk/haskell.nix/issues/$PR_NUMBER/comments"
fi

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

0 comments on commit e799d07

Please sign in to comment.