diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 8f08e59..c09a17e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -8,7 +8,7 @@ env: # Per-host variables - shared across containers on host macos: "x86_64-darwin" linux: "x86_64-linux" - nix: "nix develop --accept-flake-config" + nix: "nix develop --accept-flake-config --allow-import-from-derivation" steps: @@ -47,3 +47,11 @@ steps: system: ${linux} env: TMPDIR: "/cache" + - label: "Check cardano-ledger-specs" + depends_on: linux-nix + command: | + ${nix} --command bash -c scripts/cardano-ledger-specs.sh + agents: + system: ${linux} + env: + TMPDIR: "/cache" diff --git a/.gitignore b/.gitignore index bada683..887d278 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ cabal*.project.local* .ghci hie.yaml .direnv/ +result +lib/cardano-ledger-specs/fine-types diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra.fine b/lib/cardano-ledger-specs/Allegra.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra.fine rename to lib/cardano-ledger-specs/Allegra.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/Address.fine b/lib/cardano-ledger-specs/Allegra/Address.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/Address.fine rename to lib/cardano-ledger-specs/Allegra/Address.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/Block.fine b/lib/cardano-ledger-specs/Allegra/Block.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/Block.fine rename to lib/cardano-ledger-specs/Allegra/Block.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/Crypto.fine b/lib/cardano-ledger-specs/Allegra/Crypto.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/Crypto.fine rename to lib/cardano-ledger-specs/Allegra/Crypto.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/Delegation.fine b/lib/cardano-ledger-specs/Allegra/Delegation.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/Delegation.fine rename to lib/cardano-ledger-specs/Allegra/Delegation.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/PParams.fine b/lib/cardano-ledger-specs/Allegra/PParams.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/PParams.fine rename to lib/cardano-ledger-specs/Allegra/PParams.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/Script.fine b/lib/cardano-ledger-specs/Allegra/Script.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/Script.fine rename to lib/cardano-ledger-specs/Allegra/Script.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Allegra/Tx.fine b/lib/cardano-ledger-specs/Allegra/Tx.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Allegra/Tx.fine rename to lib/cardano-ledger-specs/Allegra/Tx.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo.fine b/lib/cardano-ledger-specs/Alonzo.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo.fine rename to lib/cardano-ledger-specs/Alonzo.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Address.fine b/lib/cardano-ledger-specs/Alonzo/Address.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Address.fine rename to lib/cardano-ledger-specs/Alonzo/Address.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Block.fine b/lib/cardano-ledger-specs/Alonzo/Block.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Block.fine rename to lib/cardano-ledger-specs/Alonzo/Block.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/CostModel.fine b/lib/cardano-ledger-specs/Alonzo/CostModel.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/CostModel.fine rename to lib/cardano-ledger-specs/Alonzo/CostModel.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Crypto.fine b/lib/cardano-ledger-specs/Alonzo/Crypto.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Crypto.fine rename to lib/cardano-ledger-specs/Alonzo/Crypto.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Delegation.fine b/lib/cardano-ledger-specs/Alonzo/Delegation.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Delegation.fine rename to lib/cardano-ledger-specs/Alonzo/Delegation.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/PParams.fine b/lib/cardano-ledger-specs/Alonzo/PParams.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/PParams.fine rename to lib/cardano-ledger-specs/Alonzo/PParams.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Script.fine b/lib/cardano-ledger-specs/Alonzo/Script.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Script.fine rename to lib/cardano-ledger-specs/Alonzo/Script.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Tx.fine b/lib/cardano-ledger-specs/Alonzo/Tx.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Tx.fine rename to lib/cardano-ledger-specs/Alonzo/Tx.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Alonzo/Value.fine b/lib/cardano-ledger-specs/Alonzo/Value.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Alonzo/Value.fine rename to lib/cardano-ledger-specs/Alonzo/Value.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage.fine b/lib/cardano-ledger-specs/Babbage.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage.fine rename to lib/cardano-ledger-specs/Babbage.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Address.fine b/lib/cardano-ledger-specs/Babbage/Address.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Address.fine rename to lib/cardano-ledger-specs/Babbage/Address.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Block.fine b/lib/cardano-ledger-specs/Babbage/Block.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Block.fine rename to lib/cardano-ledger-specs/Babbage/Block.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/CostModel.fine b/lib/cardano-ledger-specs/Babbage/CostModel.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/CostModel.fine rename to lib/cardano-ledger-specs/Babbage/CostModel.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Crypto.fine b/lib/cardano-ledger-specs/Babbage/Crypto.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Crypto.fine rename to lib/cardano-ledger-specs/Babbage/Crypto.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Delegation.fine b/lib/cardano-ledger-specs/Babbage/Delegation.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Delegation.fine rename to lib/cardano-ledger-specs/Babbage/Delegation.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/PParams.fine b/lib/cardano-ledger-specs/Babbage/PParams.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/PParams.fine rename to lib/cardano-ledger-specs/Babbage/PParams.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Script.fine b/lib/cardano-ledger-specs/Babbage/Script.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Script.fine rename to lib/cardano-ledger-specs/Babbage/Script.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Tx.fine b/lib/cardano-ledger-specs/Babbage/Tx.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Tx.fine rename to lib/cardano-ledger-specs/Babbage/Tx.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Babbage/Value.fine b/lib/cardano-ledger-specs/Babbage/Value.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Babbage/Value.fine rename to lib/cardano-ledger-specs/Babbage/Value.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary.fine b/lib/cardano-ledger-specs/Mary.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary.fine rename to lib/cardano-ledger-specs/Mary.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Address.fine b/lib/cardano-ledger-specs/Mary/Address.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Address.fine rename to lib/cardano-ledger-specs/Mary/Address.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Block.fine b/lib/cardano-ledger-specs/Mary/Block.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Block.fine rename to lib/cardano-ledger-specs/Mary/Block.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Crypto.fine b/lib/cardano-ledger-specs/Mary/Crypto.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Crypto.fine rename to lib/cardano-ledger-specs/Mary/Crypto.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Delegation.fine b/lib/cardano-ledger-specs/Mary/Delegation.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Delegation.fine rename to lib/cardano-ledger-specs/Mary/Delegation.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/PParams.fine b/lib/cardano-ledger-specs/Mary/PParams.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/PParams.fine rename to lib/cardano-ledger-specs/Mary/PParams.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Script.fine b/lib/cardano-ledger-specs/Mary/Script.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Script.fine rename to lib/cardano-ledger-specs/Mary/Script.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Tx.fine b/lib/cardano-ledger-specs/Mary/Tx.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Tx.fine rename to lib/cardano-ledger-specs/Mary/Tx.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Mary/Value.fine b/lib/cardano-ledger-specs/Mary/Value.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Mary/Value.fine rename to lib/cardano-ledger-specs/Mary/Value.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley.fine b/lib/cardano-ledger-specs/Shelley.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley.fine rename to lib/cardano-ledger-specs/Shelley.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/Address.fine b/lib/cardano-ledger-specs/Shelley/Address.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/Address.fine rename to lib/cardano-ledger-specs/Shelley/Address.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/Block.fine b/lib/cardano-ledger-specs/Shelley/Block.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/Block.fine rename to lib/cardano-ledger-specs/Shelley/Block.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/Crypto.fine b/lib/cardano-ledger-specs/Shelley/Crypto.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/Crypto.fine rename to lib/cardano-ledger-specs/Shelley/Crypto.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/Delegation.fine b/lib/cardano-ledger-specs/Shelley/Delegation.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/Delegation.fine rename to lib/cardano-ledger-specs/Shelley/Delegation.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/PParams.fine b/lib/cardano-ledger-specs/Shelley/PParams.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/PParams.fine rename to lib/cardano-ledger-specs/Shelley/PParams.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/Script.fine b/lib/cardano-ledger-specs/Shelley/Script.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/Script.fine rename to lib/cardano-ledger-specs/Shelley/Script.fine diff --git a/lib/fine-types/test/data/Cardano/Ledger/Shelley/Tx.fine b/lib/cardano-ledger-specs/Shelley/Tx.fine similarity index 100% rename from lib/fine-types/test/data/Cardano/Ledger/Shelley/Tx.fine rename to lib/cardano-ledger-specs/Shelley/Tx.fine diff --git a/lib/fine-types/fine-types.cabal b/lib/fine-types/fine-types.cabal index 048904f..d5b39b8 100644 --- a/lib/fine-types/fine-types.cabal +++ b/lib/fine-types/fine-types.cabal @@ -119,12 +119,6 @@ test-suite unit main-is: Spec.hs other-modules: - Language.FineTypes.Cardano.Ledger.AlonzoSpec - Language.FineTypes.Cardano.Ledger.AllegraSpec - Language.FineTypes.Cardano.Ledger.BabbageSpec - Language.FineTypes.Cardano.Ledger.Common - Language.FineTypes.Cardano.Ledger.MarySpec - Language.FineTypes.Cardano.Ledger.ShelleySpec Language.FineTypes.Export.OpenAPI.SchemaSpec Language.FineTypes.Export.OpenAPI.ValueSpec Language.FineTypes.PackageSpec diff --git a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/AllegraSpec.hs b/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/AllegraSpec.hs deleted file mode 100644 index 513233f..0000000 --- a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/AllegraSpec.hs +++ /dev/null @@ -1,24 +0,0 @@ -module Language.FineTypes.Cardano.Ledger.AllegraSpec - ( spec - ) -where - -import Language.FineTypes.Cardano.Ledger.Common - ( moduleMultiFileSpec - , packageSpec - ) -import Test.Hspec (Spec) - -spec :: Spec -spec = do - moduleMultiFileSpec - "Allegra" - [ "Crypto.fine" - , "PParams.fine" - , "Address.fine" - , "Block.fine" - , "Tx.fine" - , "Delegation.fine" - , "Script.fine" - ] - packageSpec "Allegra.fine" diff --git a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/AlonzoSpec.hs b/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/AlonzoSpec.hs deleted file mode 100644 index 0be48a8..0000000 --- a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/AlonzoSpec.hs +++ /dev/null @@ -1,26 +0,0 @@ -module Language.FineTypes.Cardano.Ledger.AlonzoSpec - ( spec - ) -where - -import Language.FineTypes.Cardano.Ledger.Common - ( moduleMultiFileSpec - , packageSpec - ) -import Test.Hspec (Spec) - -spec :: Spec -spec = do - moduleMultiFileSpec - "Alonzo" - [ "Crypto.fine" - , "PParams.fine" - , "Address.fine" - , "Block.fine" - , "Tx.fine" - , "Delegation.fine" - , "Script.fine" - , "CostModel.fine" - , "Value.fine" - ] - packageSpec "Alonzo.fine" diff --git a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/BabbageSpec.hs b/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/BabbageSpec.hs deleted file mode 100644 index 811f1eb..0000000 --- a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/BabbageSpec.hs +++ /dev/null @@ -1,26 +0,0 @@ -module Language.FineTypes.Cardano.Ledger.BabbageSpec - ( spec - ) -where - -import Language.FineTypes.Cardano.Ledger.Common - ( moduleMultiFileSpec - , packageSpec - ) -import Test.Hspec (Spec) - -spec :: Spec -spec = do - moduleMultiFileSpec - "Babbage" - [ "Crypto.fine" - , "PParams.fine" - , "Address.fine" - , "Block.fine" - , "Tx.fine" - , "Delegation.fine" - , "Script.fine" - , "CostModel.fine" - , "Value.fine" - ] - packageSpec "Babbage.fine" diff --git a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/Common.hs b/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/Common.hs deleted file mode 100644 index aa95f87..0000000 --- a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/Common.hs +++ /dev/null @@ -1,55 +0,0 @@ -module Language.FineTypes.Cardano.Ledger.Common - ( moduleSpec - , moduleMultiFileSpec - , packageSpec - ) -where - -import Prelude - -import Control.Arrow (left) -import Data.Either (isRight) -import Data.Foldable (traverse_) -import Language.FineTypes.Module (collectNotInScope) -import Language.FineTypes.Package - ( compilePackageDescription - , parsePackageDescription - ) -import Language.FineTypes.Parser (parseFineTypes, parseFineTypes') -import System.FilePath (joinPath, ()) -import Test.Hspec (Spec, describe, it, shouldBe, shouldSatisfy) -import Text.Megaparsec (errorBundlePretty) - -import qualified Data.Set as Set - -moduleSpec :: FilePath -> Spec -moduleSpec fp = do - describe ("on module " <> fp) $ do - it "parses" $ do - file <- readFile fp - left errorBundlePretty (parseFineTypes' file) - `shouldSatisfy` isRight - it "detects constants" $ do - file <- readFile fp - Just m <- pure $ parseFineTypes file - collectNotInScope m `shouldBe` Set.empty - -basePath :: FilePath -basePath = joinPath ["test", "data", "Cardano", "Ledger"] - -moduleMultiFileSpec :: FilePath -> [FilePath] -> Spec -moduleMultiFileSpec era = - traverse_ (moduleSpec . (\x -> basePath era x)) - -packageSpec :: FilePath -> Spec -packageSpec era = do - let package = basePath era - describe ("on package " <> era) $ do - it "parses" $ do - file <- readFile package - parsePackageDescription file `shouldSatisfy` isRight - it "compiles" $ do - file <- readFile package - Right pkg <- pure $ parsePackageDescription file - epkg <- compilePackageDescription basePath pkg - epkg `shouldSatisfy` isRight diff --git a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/MarySpec.hs b/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/MarySpec.hs deleted file mode 100644 index 82cff13..0000000 --- a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/MarySpec.hs +++ /dev/null @@ -1,25 +0,0 @@ -module Language.FineTypes.Cardano.Ledger.MarySpec - ( spec - ) -where - -import Language.FineTypes.Cardano.Ledger.Common - ( moduleMultiFileSpec - , packageSpec - ) -import Test.Hspec (Spec) - -spec :: Spec -spec = do - moduleMultiFileSpec - "Mary" - [ "Crypto.fine" - , "PParams.fine" - , "Address.fine" - , "Block.fine" - , "Tx.fine" - , "Delegation.fine" - , "Script.fine" - , "Value.fine" - ] - packageSpec "Mary.fine" diff --git a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/ShelleySpec.hs b/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/ShelleySpec.hs deleted file mode 100644 index 0c60bc8..0000000 --- a/lib/fine-types/test/Language/FineTypes/Cardano/Ledger/ShelleySpec.hs +++ /dev/null @@ -1,24 +0,0 @@ -module Language.FineTypes.Cardano.Ledger.ShelleySpec - ( spec - ) -where - -import Language.FineTypes.Cardano.Ledger.Common - ( moduleMultiFileSpec - , packageSpec - ) -import Test.Hspec (Spec) - -spec :: Spec -spec = do - moduleMultiFileSpec - "Shelley" - [ "Crypto.fine" - , "PParams.fine" - , "Address.fine" - , "Block.fine" - , "Tx.fine" - , "Delegation.fine" - , "Script.fine" - ] - packageSpec "Shelley.fine" diff --git a/scripts/cardano-ledger-specs.sh b/scripts/cardano-ledger-specs.sh new file mode 100755 index 0000000..7875b7d --- /dev/null +++ b/scripts/cardano-ledger-specs.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -euo pipefail + +nix build --accept-flake-config .#fine-types:exe:fine-types +cd lib/cardano-ledger-specs/ +fine_types="../../result/bin/fine-types" +$fine_types check -i Shelley.fine +$fine_types check -i Allegra.fine +$fine_types check -i Mary.fine +$fine_types check -i Alonzo.fine +$fine_types check -i Babbage.fine \ No newline at end of file