Skip to content

Commit

Permalink
Merge pull request #4572 from input-output-hk/coot/ci-scripts
Browse files Browse the repository at this point in the history
CI scripts
  • Loading branch information
coot committed May 26, 2023
2 parents e688af9 + 8a356e0 commit 9023e4a
Show file tree
Hide file tree
Showing 20 changed files with 78 additions and 184 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/build.yml
Expand Up @@ -9,21 +9,6 @@ on:
merge_group:

jobs:
check-cabal-files:
runs-on: ubuntu-latest

steps:
- name: Install Haskell
uses: input-output-hk/setup-haskell@v1
id: setup-haskell
with:
cabal-version: "3.10.1.0"

- uses: actions/checkout@v3

- name: Cabal check
run: ./scripts/ci/check-cabal-files.sh

build:
runs-on: ${{ matrix.os }}

Expand Down
35 changes: 31 additions & 4 deletions .github/workflows/checks.yml
Expand Up @@ -10,17 +10,44 @@ on:

jobs:
check-git-dependencies:

name: Check git dependencies

if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}

runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3
- name: Check Dependencies
run: ./scripts/ci/check-git-dependencies.sh

check-changelogs:
name: Check changelogs
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3
- run: ./scripts/ci/check-git-dependencies.sh
- name: Check changelogs
run: ./scripts/ci/check-changelogs.sh

check-cabal-files:
name: Check cabal files
runs-on: ubuntu-latest

steps:
- name: Install Haskell
uses: input-output-hk/setup-haskell@v1
id: setup-haskell
with:
cabal-version: "3.10.1.0"

- uses: actions/checkout@v3

- name: Check cabal files
run: ./scripts/ci/check-cabal-files.sh

2 changes: 1 addition & 1 deletion cardano-client/cardano-client.cabal
Expand Up @@ -12,7 +12,7 @@ author: IOHK Engineering Team
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

library
hs-source-dirs: src
Expand Down
3 changes: 2 additions & 1 deletion cardano-ping/cardano-ping.cabal
Expand Up @@ -11,7 +11,8 @@ author: Karl Knutsson
maintainer: karl.knutsson-ext@cardanofoundation.org marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: README.md
CHANGELOG.md

flag asserts
description: Enable assertions
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Expand Up @@ -42,7 +42,7 @@ let
tests = collectChecks' haskellPackages;
styles = recurseIntoAttrs {
check-nixfmt = callPackage ./nix/check-nixfmt.nix { };
check-stylish-network = callPackage ./nix/check-stylish-network.nix { };
check-stylish = callPackage ./nix/check-stylish.nix { };
};
};

Expand Down
2 changes: 1 addition & 1 deletion monoidal-synchronisation/monoidal-synchronisation.cabal
Expand Up @@ -11,7 +11,7 @@ author: Marcin Szamotulski
maintainer: coot@coot.me
category: Network
copyright: 2021-2023 Input Output Global Inc (IOG).
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

library
exposed-modules: Data.Monoid.Synchronisation
Expand Down
3 changes: 2 additions & 1 deletion network-mux/network-mux.cabal
Expand Up @@ -12,7 +12,8 @@ author: Duncan Coutts, Marc Fontaine, Karl Knutsson, Marcin Szam
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: README.md
CHANGELOG.md

flag asserts
description: Enable assertions
Expand Down
4 changes: 2 additions & 2 deletions nix/check-stylish-network.nix → nix/check-stylish.nix
@@ -1,6 +1,6 @@
{ runCommand, fd, lib, stylish-haskell, haskell-nix }:

runCommand "check-stylish-network" {
runCommand "check-stylish" {
meta.platforms = with lib.platforms; [ linux ];
buildInputs = [ fd stylish-haskell ];
src = haskell-nix.haskellLib.cleanGit {
Expand All @@ -10,7 +10,7 @@ runCommand "check-stylish-network" {
} ''
unpackPhase
cd $sourceRoot
bash ./scripts/ci/check-stylish-network.sh
bash ./scripts/ci/check-stylish.sh
diff -ru $src .
EXIT_CODE=$?
Expand Down
4 changes: 2 additions & 2 deletions ntp-client/ntp-client.cabal
Expand Up @@ -11,8 +11,8 @@ copyright: 2019-2023 Input Output Global Inc (IOG)
maintainer: operations@iohk.io
category: Network
build-type: Simple
extra-source-files: README.md
extra-source-files: CHANGELOG.md
extra-doc-files: README.md
CHANGELOG.md

flag demo
description: Build a demo application
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network-api/ouroboros-network-api.cabal
Expand Up @@ -11,7 +11,7 @@ author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts, Karl
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

flag asserts
description: Enable assertions
Expand Down
Expand Up @@ -11,7 +11,7 @@ author: Alexander Vieth, Duncan Coutts, Marcin Szamotulski
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

Flag ipv6
Description: Enable IPv6 test cases
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network-mock/ouroboros-network-mock.cabal
Expand Up @@ -12,7 +12,7 @@ author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

flag asserts
description: Enable assertions
Expand Down
Expand Up @@ -11,7 +11,7 @@ author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

flag asserts
description: Enable assertions
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network-testing/ouroboros-network-testing.cabal
Expand Up @@ -12,7 +12,7 @@ author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts, Karl
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

source-repository head
type: git
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network/ouroboros-network.cabal
Expand Up @@ -11,7 +11,7 @@ author: Alexander Vieth, Marcin Szamotulski, Duncan Coutts
maintainer: marcin.szamotulski@iohk.io
category: Network
build-type: Simple
extra-source-files: CHANGELOG.md
extra-doc-files: CHANGELOG.md

flag asserts
description: Enable assertions
Expand Down
5 changes: 3 additions & 2 deletions scripts/ci/check-cabal-files.sh
@@ -1,10 +1,11 @@
#!/usr/bin/env bash

for x in $(find . -name '*.cabal' | grep -v dist-newstyle | cut -c 3-); do
for x in $(fd -e cabal); do
(
d=$(dirname $x)
echo "== $d =="
cd $d
pushd $d
cabal check
popd
)
done
18 changes: 18 additions & 0 deletions scripts/ci/check-changelogs.sh
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -eo pipefail

function check_project () {
project=$1
n=$()
if [[ -n $(git diff --name-only master..HEAD -- $project) ]];then
if [[ -z $(git diff --name-only master..HEAD -- $project/CHANGELOG.md) ]]; then
echo "$project was modified but its CHANGELOG was not updated"
exit 1
fi
fi
}

for cbl in $(fd -e 'cabal'); do
check_project $(dirname $cbl)
done
66 changes: 0 additions & 66 deletions scripts/ci/check-consensus-release.sh

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/ci/check-stylish-network.sh

This file was deleted.

78 changes: 9 additions & 69 deletions scripts/ci/check-stylish.sh
@@ -1,73 +1,13 @@
#!/usr/bin/env bash

set -e
set -euo pipefail

export LC_ALL=C.UTF-8
fd -p ouroboros-consensus \
-e hs \
-E Setup.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/LedgerDB/InMemory.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/LedgerDB/OnDisk.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/LedgerDB/Types.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/Impl/Pure.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/Impl/Types.hs\
-E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/Impl.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Mempool/TxLimits.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Util/Counting.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Util/OptNP.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Functors.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/InPairs.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Match.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Telescope.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/DerivingVia.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Tails.hs \
-E ouroboros-consensus-test/src/Test/Util/Classify.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/API.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/API/Types.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/CRC.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/Handle.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/IO.hs \
-E ouroboros-consensus/src/Ouroboros/Consensus/Storage/IO.hs \
-E ouroboros-consensus-test/src/Test/Util/FS/Sim/Error.hs \
-E ouroboros-consensus-test/src/Test/Util/FS/Sim/FsTree.hs \
-E ouroboros-consensus-test/src/Test/Util/FS/Sim/MockFS.hs \
-E ouroboros-consensus-test/src/Test/Util/FS/Sim/Pure.hs \
-E ouroboros-consensus-test/src/Test/Util/FS/Sim/STM.hs \
-E ouroboros-consensus-test/src/Test/Util/Blob.hs \
-E ouroboros-consensus-cardano-tools/app/DBAnalyser/Parsers.hs \
-X stylish-haskell \
-c .stylish-haskell.yaml -i

# We don't want these deprecation warnings to be removed accidentally
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/LedgerDB/InMemory.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/LedgerDB/OnDisk.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/LedgerDB/Types.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Mempool/Impl/Pure.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Mempool/Impl/Types.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Mempool/Impl.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Mempool/TxLimits.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Util/Counting.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Util/OptNP.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Functors.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/InPairs.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Match.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Telescope.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/DerivingVia.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/Tails.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/Classify.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/API.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/API/Types.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/CRC.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/Handle.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/FS/IO.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus/src/Ouroboros/Consensus/Storage/IO.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/FS/Sim/Error.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/FS/Sim/FsTree.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/FS/Sim/MockFS.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/FS/Sim/Pure.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/FS/Sim/STM.hs >/dev/null 2>&1
grep "module.*DEPRECATED" ouroboros-consensus-test/src/Test/Util/Blob.hs >/dev/null 2>&1

fd -p ouroboros-consensus -e cabal -x cabal-fmt -i
# TODO CPP pragmas in export lists are not supported by stylish-haskell
fd . './network-mux' -e hs -E Setup.hs -E TCPInfo.hs -E Pipe.hs -E Channel.hs -E Bearer.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd . './ouroboros-network-api' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd . './ouroboros-network-framework' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd . './ouroboros-network-mock' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i
fd . './ouroboros-network-protocols' -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 . './cardano-client' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell-network.yaml -i

0 comments on commit 9023e4a

Please sign in to comment.