diff --git a/.github/format.sh b/.github/format.sh new file mode 100755 index 0000000..90be9ca --- /dev/null +++ b/.github/format.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Extensions necessary to tell fourmolu about +EXTENSIONS="-o -XTypeApplications -o -XTemplateHaskell -o -XImportQualifiedPost -o -XPatternSynonyms -o -fplugin=RecordDotPreprocessor" +SOURCES=$(git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.hs') +nix run nixpkgs#haskellPackages.fourmolu -- --mode check --check-idempotence $EXTENSIONS $SOURCES diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml new file mode 100644 index 0000000..10b425d --- /dev/null +++ b/.github/workflows/integrate.yaml @@ -0,0 +1,92 @@ +on: + push: + paths: + - "**.hs" + - "**.nix" + - "flake.lock" + - "agora.cabal" + branches: + - master + - staging + pull_request: + paths: + - "**.hs" + - "**.nix" + - "flake.lock" + - "agora.cabal" +jobs: + check-formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.4.0 + + - uses: cachix/install-nix-action@v16 + name: Set up Nix and IOHK caches + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/ + experimental-features = nix-command flakes + + - uses: cachix/cachix-action@v10 + with: + name: mlabs + authToken: ${{ secrets.CACHIX_KEY }} + + - run: ./.github/format.sh + name: Run fourmolu + + run-linter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.4.0 + + - uses: cachix/install-nix-action@v16 + name: Set up Nix and IOHK caches + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/ + experimental-features = nix-command flakes + + - uses: cachix/cachix-action@v10 + with: + name: mlabs + authToken: ${{ secrets.CACHIX_KEY }} + + - run: nix run nixpkgs#hlint -- $(git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.hs') + name: Run hlint + + check-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.4.0 + + - uses: cachix/install-nix-action@v16 + name: Set up Nix and IOHK caches + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/ + experimental-features = nix-command flakes + + - uses: cachix/cachix-action@v10 + with: + name: mlabs + authToken: ${{ secrets.CACHIX_KEY }} + + - name: Add cabal folder to cache + id: cabal + uses: actions/cache@v2.1.4 + with: + path: | + ~/.cabal/packages + ~/.cabal/store + dist-newstyle + key: ${{ runner.os }}-cabal + + - name: Build the project + run: nix build diff --git a/.gitignore b/.gitignore index 9699888..5ae1889 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ result-* .vscode/ .idea tags +TAGS .nvimrc *.tix diff --git a/agora.cabal b/agora.cabal index bc8e01d..2f3a649 100644 --- a/agora.cabal +++ b/agora.cabal @@ -68,6 +68,7 @@ common deps , data-default-class , plutarch , plutus-core + , plutus-extra , plutus-ledger , plutus-ledger-api , plutus-tx @@ -78,7 +79,6 @@ common deps , serialise , template-haskell , text - , plutus-extra common test-deps build-depends: @@ -86,6 +86,7 @@ common test-deps , quickcheck-instances , tagged , tasty + , tasty-hunit , utf8-string -------------------------------------------------------------------------------- diff --git a/flake.lock b/flake.lock index f8466b2..7dc3852 100644 --- a/flake.lock +++ b/flake.lock @@ -35,11 +35,11 @@ "Shrinker": { "flake": false, "locked": { - "lastModified": 1641477919, - "narHash": "sha256-D6Rl2/2ABrHwBdoU8U4iNU8gVC4MTy14heh4ouCjQE4=", + "lastModified": 1642430208, + "narHash": "sha256-tfWyB7zCLzncwRpyl7eUOzuOBbg9KLu6sxSxRaFlOug=", "owner": "Plutonomicon", "repo": "Shrinker", - "rev": "37bf56e83d0d568232ff2be1ae4daf1946a81189", + "rev": "0e60707996b876c7bd23a348f54545217ce2e556", "type": "github" }, "original": { @@ -696,11 +696,11 @@ "hackage_2": { "flake": false, "locked": { - "lastModified": 1641604316, - "narHash": "sha256-yadiTlqUcS7f5ANmjjunh1xh1vjGdfAlkOwBq/4Slls=", + "lastModified": 1642554756, + "narHash": "sha256-1+SN+z80HgKYshlCf8dRxwRojQzuwwsQ5uq14N/JP1Y=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "f71140013b530aaa38cc3769976c6b2bdb248891", + "rev": "f9d5e67ca90926b244c0ad68815371d37582a149", "type": "github" }, "original": { @@ -712,11 +712,11 @@ "haskell-language-server": { "flake": false, "locked": { - "lastModified": 1643360816, - "narHash": "sha256-M4noTbTGa7oYfg2/8NqDugGX/qs8j//gJUiLwuPU9Co=", + "lastModified": 1642772345, + "narHash": "sha256-fjdNOcd0S35OAvMZu81/im32B7hSIimjs08VKQA58Mw=", "owner": "haskell", "repo": "haskell-language-server", - "rev": "ce41b6459af131c845f942bd39e356f02b6306fa", + "rev": "f0bbc390b995953885506b755f4e4b5c6af618fb", "type": "github" }, "original": { @@ -772,7 +772,7 @@ "nix-tools": "nix-tools", "nixpkgs": [ "haskell-nix", - "nixpkgs-2105" + "nixpkgs-unstable" ], "nixpkgs-2003": "nixpkgs-2003", "nixpkgs-2009": "nixpkgs-2009", @@ -815,17 +815,17 @@ ], "nixpkgs-2003": "nixpkgs-2003_2", "nixpkgs-2105": "nixpkgs-2105_2", - "nixpkgs-2111": "nixpkgs-2111", + "nixpkgs-2111": "nixpkgs-2111_2", "nixpkgs-unstable": "nixpkgs-unstable_2", "old-ghc-nix": "old-ghc-nix_2", "stackage": "stackage_2" }, "locked": { - "lastModified": 1641853401, - "narHash": "sha256-62ay0XTxNbNOYt5KnnWXiBTkrUlSY1t0kJR1KeWuGTg=", + "lastModified": 1642811877, + "narHash": "sha256-7YbbFF4ISWMcs5hHDfH7GkCSccvwEwhvKZ5D74Cuajo=", "owner": "L-as", "repo": "haskell.nix", - "rev": "148bd7563804e504ef7bfc53191ba3f84fd91129", + "rev": "ac825b91c202947ec59b1a477003564cc018fcec", "type": "github" }, "original": { @@ -1139,11 +1139,11 @@ }, "nixpkgs-2009": { "locked": { - "lastModified": 1635350005, - "narHash": "sha256-tAMJnUwfaDEB2aa31jGcu7R7bzGELM9noc91L2PbVjg=", + "lastModified": 1624271064, + "narHash": "sha256-qns/uRW7MR2EfVf6VEeLgCsCp7pIOjDeR44JzTF09MA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1c1f5649bb9c1b0d98637c8c365228f57126f361", + "rev": "46d1c3f28ca991601a53e9a14fdd53fcd3dd8416", "type": "github" }, "original": { @@ -1186,6 +1186,22 @@ } }, "nixpkgs-2111": { + "locked": { + "lastModified": 1644510859, + "narHash": "sha256-xjpVvL5ecbyi0vxtVl/Fh9bwGlMbw3S06zE5nUzFB8A=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d1d5d7e3679fec9d07f2eb804d9f9fdb98378d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2111_2": { "locked": { "lastModified": 1640283207, "narHash": "sha256-SCwl7ZnCfMDsuSYvwIroiAlk7n33bW8HFfY8NvKhcPA=", @@ -1384,6 +1400,7 @@ "hercules-ci-effects": "hercules-ci-effects", "hs-memory": "hs-memory", "nixpkgs": [ + "plutarch", "haskell-nix", "nixpkgs-unstable" ], @@ -1597,6 +1614,7 @@ "haskell-nix", "nixpkgs-unstable" ], + "nixpkgs-2111": "nixpkgs-2111", "optparse-applicative": "optparse-applicative", "ouroboros-network": "ouroboros-network", "plutarch": "plutarch", @@ -1724,11 +1742,11 @@ "stackage_2": { "flake": false, "locked": { - "lastModified": 1641518807, - "narHash": "sha256-aEULsFF9b0vNLUzaj4lnbci8UL6r/6UvuJsY9x04ZJ0=", + "lastModified": 1642468901, + "narHash": "sha256-+Hu4m9i8v8Moey/C8fy8juyxB729JdsXz02cK8nJXLk=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "52fe0717d7e436fdeb6032f1ca342d1d73351716", + "rev": "7544f8fd16bb92b7cf90cb51cb4ddc43173526de", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6b9f7a5..e4751d7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,10 @@ inputs.haskell-nix.url = "github:input-output-hk/haskell.nix?rev=4aeeba8d713d0b98c92c8c717df24da17d463c1d"; inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; - inputs.haskell-nix.inputs.nixpkgs.follows = "haskell-nix/nixpkgs-2105"; + inputs.haskell-nix.inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; + + # Temp workaround for Nix issue. + inputs.nixpkgs-2111.url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; inputs.plutus.url = "github:input-output-hk/plutus?rev=65bad0fd53e432974c3c203b1b1999161b6c2dce"; diff --git a/hie.yaml b/hie.yaml index 2a1e864..23b82b5 100644 --- a/hie.yaml +++ b/hie.yaml @@ -2,3 +2,5 @@ cradle: cabal: - path: "./src" component: "lib:agora" + - path: "./test" + component: "test:agora-test" diff --git a/src/Agora/AuthorityToken.hs b/src/Agora/AuthorityToken.hs index bbd2849..4b59f8d 100644 --- a/src/Agora/AuthorityToken.hs +++ b/src/Agora/AuthorityToken.hs @@ -24,7 +24,7 @@ import Plutarch.Prelude said transaction. Said validator should be made aware of _this_ token's existence in order to prevent incorrect minting. -} -data AuthorityToken = AuthorityToken +newtype AuthorityToken = AuthorityToken { -- | Token that must move in order for minting this to be valid. authority :: AssetClass } diff --git a/test/Spec.hs b/test/Spec.hs index 8534df0..9cfc14c 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -9,4 +9,5 @@ import Test.Tasty (defaultMain, testGroup) -------------------------------------------------------------------------------- main :: IO () -main = defaultMain $ testGroup "Suites" [] +main = + defaultMain $ testGroup "Suites" []