Skip to content

Commit

Permalink
Import cardano-submit-api from cardano-rest repo
Browse files Browse the repository at this point in the history
Publish submit-api artifacts
Tidy up imports
Remove unused cardano-cli dependencies
Document how to test
  • Loading branch information
newhoggy authored and jutaro committed May 13, 2021
1 parent d758f2e commit f174535
Show file tree
Hide file tree
Showing 38 changed files with 1,966 additions and 404 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/haskell.yml
Expand Up @@ -136,6 +136,23 @@ jobs:
- name: Run tests
run: TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 retry 2 cabal test --builddir="$CABAL_BUILDDIR" cardano-node-chairman

- name: Build & Test
run: |
mkdir -p artifacts
for exe in $(cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style == "local" and (."component-name" | startswith("exe:"))) | ."bin-file"'); do
( cd artifacts
tar -C "$(dirname $exe)" -czf "$(basename $exe).tar.gz" "$(basename $exe)"
)
done
- name: Save Artifact
if: matrix.ghc == '8.10.3'
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.os }}_cardano-rest
path: ./artifacts

- name: Delete socket files in preparation for upload artifacts
if: ${{ always() }}
run: |
Expand All @@ -149,3 +166,56 @@ jobs:
with:
name: chairman-test-artifacts-${{ matrix.os }}-${{ matrix.ghc }}
path: ${{ runner.temp }}/chairman/

release:
needs: [build]
if: ${{ startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2.3.4

- name: Create Release Tag
id: create_release_tag
run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

- name: Download Artifact (linux)
uses: actions/download-artifact@v1
with:
name: ubuntu-latest_cardano-rest

- name: Download Artifact (macOS)
uses: actions/download-artifact@v1
with:
name: macOS-latest_cardano-rest

- name: Upload Release Asset (cardano-submit-api, linux)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ubuntu-latest_cardano-rest/cardano-submit-api.tar.gz
asset_name: cardano-submit-api_${{ steps.create_release_tag.outputs.TAG }}-linux.tar.gz
asset_content_type: application/gzip

- name: Upload Release Asset (cardano-submit-api, macOS)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macOS-latest_cardano-rest/cardano-submit-api.tar.gz
asset_name: cardano-submit-api_${{ steps.create_release_tag.outputs.TAG }}-macOS.tar.gz
asset_content_type: application/gzip
1 change: 1 addition & 0 deletions cabal.project
Expand Up @@ -8,6 +8,7 @@ packages:
cardano-config
cardano-node
cardano-node-chairman
cardano-submit-api
hedgehog-extras
nix/supervisord-cluster/topology

Expand Down
74 changes: 34 additions & 40 deletions cardano-api/cardano-api.cabal
Expand Up @@ -6,22 +6,44 @@ description: The cardano api
author: IOHK
maintainer: operations@iohk.io
license: Apache-2.0
license-files:
LICENSE
NOTICE
license-files: LICENSE
NOTICE
build-type: Simple
extra-source-files: README.md, ChangeLog.md

common base { build-depends: base >= 4.12 && < 4.15 }

common project-config
default-language: Haskell2010
default-extensions: NoImplicitPrelude
OverloadedStrings

ghc-options: -Wall
-Wcompat
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wpartial-fields
-Wredundant-constraints

if impl(ghc >= 8.10)
ghc-options: -Wunused-packages

if impl(ghc < 8.10)
ghc-options: -Wno-incomplete-patterns


library
import: base, project-config

hs-source-dirs: src

exposed-modules: Cardano.Api
Cardano.Api.Byron
Cardano.Api.Crypto.Ed25519Bip32
Cardano.Api.Shelley
Cardano.Api.ChainSync.Client
Cardano.Api.ChainSync.ClientPipelined

Cardano.Api.Crypto.Ed25519Bip32
-- TODO: Eliminate in the future when
-- we create wrapper types for the ledger types
-- in this modulde
Expand All @@ -33,10 +55,7 @@ library
Cardano.Api.Protocol.Shelley
Cardano.Api.Protocol.Types


other-modules: Cardano.Api.TxSubmit.ErrorRender
Cardano.Api.TxSubmit.Types

other-modules:
-- Splitting up the big Typed module:
Cardano.Api.Address
Cardano.Api.Block
Expand All @@ -49,8 +68,8 @@ library
Cardano.Api.IPC
Cardano.Api.Key
Cardano.Api.KeysByron
Cardano.Api.KeysShelley
Cardano.Api.KeysPraos
Cardano.Api.KeysShelley
Cardano.Api.Modes
Cardano.Api.NetworkId
Cardano.Api.OperationalCertificate
Expand All @@ -69,14 +88,12 @@ library
Cardano.Api.TxBody
Cardano.Api.TxInMode
Cardano.Api.TxMetadata
Cardano.Api.TxSubmit.ErrorRender
Cardano.Api.TxSubmit.Types
Cardano.Api.Utils
Cardano.Api.Value




build-depends: base >= 4.12 && < 5
, aeson >= 1.5.6.0
build-depends: aeson >= 1.5.6.0
, aeson-pretty >= 0.8.5
, attoparsec
, base16-bytestring >= 1.0
Expand Down Expand Up @@ -120,27 +137,13 @@ library
, unordered-containers >= 0.2.11
, vector

default-language: Haskell2010
default-extensions: NoImplicitPrelude
OverloadedStrings

ghc-options: -Wall
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
-Wpartial-fields
-Wcompat

if impl(ghc < 8.10)
ghc-options: -Wno-incomplete-patterns

test-suite cardano-api-test
import: base, project-config
hs-source-dirs: test
main-is: cardano-api-test.hs
type: exitcode-stdio-1.0

build-depends: base >= 4.12 && < 5
, aeson >= 1.5.6.0
build-depends: aeson >= 1.5.6.0
, base16-bytestring
, bytestring
, cardano-api
Expand Down Expand Up @@ -186,13 +189,4 @@ test-suite cardano-api-test
Test.Cardano.Api.Typed.Value
Test.Tasty.Hedgehog.Group

default-language: Haskell2010
default-extensions: NoImplicitPrelude

ghc-options: -Wall
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
-Wpartial-fields
-Wcompat
-threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T
ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api.hs
Expand Up @@ -152,7 +152,7 @@ module Cardano.Api (
TxBodyError(..),

-- ** Transaction Ids
TxId,
TxId(..),
getTxId,

-- ** Transaction inputs
Expand Down
3 changes: 2 additions & 1 deletion cardano-api/src/Cardano/Api/TxSubmit/Types.hs
Expand Up @@ -3,13 +3,14 @@ module Cardano.Api.TxSubmit.Types
( NodeApiEnv (..)
, SocketPath (..)
, TxSubmitStatus (..)
, ApplyMempoolPayloadErr(..)
, renderTxSubmitStatus
, textShow
) where

import Cardano.Api.TxSubmit.ErrorRender
import Cardano.Binary (DecoderError)
import Cardano.Chain.Byron.API (ApplyMempoolPayloadErr)
import Cardano.Chain.Byron.API (ApplyMempoolPayloadErr(..))
import qualified Cardano.Chain.Genesis as Genesis
import qualified Cardano.Chain.UTxO as Utxo

Expand Down
5 changes: 2 additions & 3 deletions cardano-api/test/Test/Cardano/Api/Typed/Value.hs
Expand Up @@ -18,6 +18,8 @@ import Test.Cardano.Api.Typed.Gen
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog.Group (fromGroup)

{- HLINT ignore "Use map once" -}

prop_roundtrip_Value_JSON :: Property
prop_roundtrip_Value_JSON =
property $ do v <- forAll genValueDefault
Expand Down Expand Up @@ -69,9 +71,6 @@ canonicalise =
isZeroOrEmpty (ValueNestedBundleAda q) = q == 0
isZeroOrEmpty (ValueNestedBundle _ as) = Map.null as

{-# ANN canonicalise "HLint: ignore Use map once" #-}


-- -----------------------------------------------------------------------------

tests :: TestTree
Expand Down
41 changes: 24 additions & 17 deletions cardano-api/test/cardano-api-test.cabal
Expand Up @@ -6,12 +6,33 @@ description: Library for utilities used in testing the Cardano API.
author: IOHK
maintainer: operations@iohk.io
license: Apache-2.0
license-files:
LICENSE
NOTICE
license-files: LICENSE
NOTICE
build-type: Simple

common base { build-depends: base >= 4.12 && < 4.15 }

common project-config
default-language: Haskell2010
default-extensions: NoImplicitPrelude
OverloadedStrings

ghc-options: -Wall
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
-Wpartial-fields
-Wcompat

if impl(ghc >= 8.10)
ghc-options: -Wunused-packages

if impl(ghc < 8.10)
ghc-options: -Wno-incomplete-patterns

library
import: base, project-config

exposed-modules: Test.Cardano.Api.Typed.Gen

other-modules: Test.Cardano.Api.Metadata
Expand All @@ -33,17 +54,3 @@ library
, tasty
, tasty-hedgehog
, text

default-language: Haskell2010
default-extensions: NoImplicitPrelude
OverloadedStrings

ghc-options: -Wall
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
-Wpartial-fields
-Wcompat

if impl(ghc < 8.10)
ghc-options: -Wno-incomplete-patterns

0 comments on commit f174535

Please sign in to comment.