Skip to content

Commit

Permalink
Merge #3737 #3749
Browse files Browse the repository at this point in the history
3737: Optimise caching r=amesgen a=newhoggy



3749: Some formatting niceties r=nfrisby a=amesgen

This includes some small things of #3720 not included in #3722.

 - We use `cleanGit` to only copy the git-tracked files to the nix store. Previously, the entire local development directory would be copied (easily >1GB). This subsumes #3669.
 - We reuse the scripts in `scripts/ci` such that people can easily run stylish-haskell in the same way as it is checked in CI.
 - This sets `export LC_ALL=C.UTF-8` for the consensus stylish-haskell check, which hopefully fixes errors like https://hydra.iohk.io/build/14684287/nixlog/1

Co-authored-by: John Ky <john.ky@iohk.io>
Co-authored-by: Alexander Esgen <alexander.esgen@iohk.io>
  • Loading branch information
3 people committed May 17, 2022
3 parents 163408c + a374f3b + 7a3c309 commit ea3ffaa
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,27 @@ jobs:
- uses: actions/checkout@v2

- name: Cache cabal store
uses: actions/cache@v2
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cabal-store-${{ env.CACHE_VERSION }}-${{ matrix.ghc }}-${{ matrix.os }}

- name: Update Hackage index
run: cabal update

- name: Cabal Configure
run: cabal --builddir="$CABAL_BUILDDIR" configure --enable-tests

- name: Record dependencies
run: |
cabal build all --dry-run
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
date > date.txt
- uses: actions/cache@v2
name: Cache cabal store
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
restore-keys: |
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- name: Use cabal.project.local.ci
run: |
cat ./cabal.project.local.ci >> ./cabal.project.local
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,7 @@ consensus layer. Start with the
The consensus team uses `stylish-haskell` >= 0.11.0.0 to format its code. This
is enforced by CI.

Either enable editor integration or run the following command to manually
format all of the consensus code (but not the network code):

```bash
stylish-haskell -i `git ls-files -- 'ouroboros-consensus*/*.hs' | grep -v Setup.hs`
```

Alternatively, call the script used by CI itself:
https://github.com/input-output-hk/ouroboros-network/blob/master/scripts/ci/check-stylish.sh
Either enable editor integration or call the script used by CI itself:

```bash
./scripts/ci/check-stylish.sh
Expand Down
7 changes: 5 additions & 2 deletions nix/check-nixfmt.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{ runCommand, fd, nixfmt }:
{ runCommand, fd, nixfmt, haskell-nix }:

runCommand "check-nixfmt" {
buildInputs = [ fd nixfmt ];
src = ./..;
src = haskell-nix.haskellLib.cleanGit {
name = "ouroboros-network-src";
src = ../.;
};
} ''
unpackPhase
cd $sourceRoot
Expand Down
17 changes: 6 additions & 11 deletions nix/check-stylish-network.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
{ runCommand, fd, lib, stylish-haskell }:
{ runCommand, fd, lib, stylish-haskell, haskell-nix }:

runCommand "check-stylish-network" {
meta.platforms = with lib.platforms; [ linux ];
buildInputs = [ fd stylish-haskell ];
src = ./..;
src = haskell-nix.haskellLib.cleanGit {
name = "ouroboros-network-src";
src = ../.;
};
} ''
unpackPhase
cd $sourceRoot
export LC_ALL=C.UTF-8
fd -p io-sim -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p io-classes -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p strict-stm -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p typed-protocols -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p network-mux -e hs -E Setup.hs -E network-mux/src/Network/Mux/TCPInfo.hs -E network-mux/src/Network/Mux/Bearer/Pipe.hs -E network-mux/src/Network/Mux/Channel.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p ouroboros-network-framework -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd . './ouroboros-network' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p cardano-client -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
bash ./scripts/ci/check-stylish-network.sh
diff -ru $src .
EXIT_CODE=$?
Expand Down
9 changes: 6 additions & 3 deletions nix/check-stylish.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{ runCommand, fd, lib, stylish-haskell }:
{ runCommand, fd, lib, stylish-haskell, haskell-nix }:

runCommand "check-stylish" {
meta.platforms = with lib.platforms; [ linux ];
buildInputs = [ fd stylish-haskell ];
src = ./..;
src = haskell-nix.haskellLib.cleanGit {
name = "ouroboros-network-src";
src = ../.;
};
} ''
unpackPhase
cd $sourceRoot
fd -p ouroboros-consensus -e hs -E Setup.hs -E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/TxLimits.hs -X stylish-haskell -c .stylish-haskell.yaml -i
bash ./scripts/ci/check-stylish.sh
diff -ru $src .
EXIT_CODE=$?
Expand Down
8 changes: 4 additions & 4 deletions scripts/ci/check-stylish-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

set -euo pipefail

export LC_ALL=C.UTF-8
fd -p io-sim -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p io-classes -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p strict-stm -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p typed-protocols -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
# TODO CPP pragmas in export lists are not supported by stylish-haskell
fd -p network-mux -e hs -E Setup.hs -E network-mux/src/Network/Mux/Bearer/Pipe.hs -E network-mux/src/Network/Mux/Channel.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p ouroboros-network* -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p network-mux -e hs -E Setup.hs -E network-mux/src/Network/Mux/TCPInfo.hs -E network-mux/src/Network/Mux/Bearer/Pipe.hs -E network-mux/src/Network/Mux/Channel.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p ouroboros-network-framework -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd . './ouroboros-network' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd -p cardano-client -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i

git diff --exit-code
5 changes: 2 additions & 3 deletions scripts/ci/check-stylish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -euo pipefail

export LC_ALL=C.UTF-8
# TODO the export of the <= operator TxLimits crashes stylish-haskell
fd -p ouroboros-consensus -e hs -E Setup.hs -E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/TxLimits.hs -X stylish-haskell -i

git diff --exit-code
fd -p ouroboros-consensus -e hs -E Setup.hs -E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/TxLimits.hs -X stylish-haskell -c .stylish-haskell.yaml -i

0 comments on commit ea3ffaa

Please sign in to comment.