From e2108a5751a90c68b0b6da27d97a8daa516f69f3 Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Wed, 16 Apr 2025 13:10:25 +0300 Subject: [PATCH 1/9] .gitignore --- .gitignore | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..310a83a --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +dist +dist-* +cabal-dev +*~ +*.swp +*.swo +\#*\# +*.elc +*.o +*.prof +*.hi +*.hie +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +*.pdf +*.prof +*.log +*.aes +*.hp +*.eventlog +*.eventlog.html +.virtualenv +.hsenv +.cabal-sandbox/ +**/.stack-work* +cabal.sandbox.config +cabal.config +cabal.project.local +TAGS +!TAGS/ +tags +!tags/ +client.crt +client.key +admin/static/markup-rule/*.gz +admin/static/markup-rule/*.map +**/admin/static/dev +/docker/stack +/docker/ghcjs +/docker/stack-work +/docker/node_modules +/docker/nix +/nix/result* +/nix/stackage/*.nix +.tmp/ +stack*.yaml.lock +.envrc +.bin +.vscode +/air/seatmap-frontend/.ghc.environment.* +/air/seatmap-frontend/result +.hpc +cabal*.project.local +cabal*.project.local~ +.HTF/ +.ghc.environment.* +Makefile.local +.gcroots +hie.yaml +.dir-locals.el +/sso/auth-frontend/elm-pages/dev/elm.js +/bin +/result* From 72fce05e4a4e13fa7fc170b741cada4d5a6a6f6d Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Wed, 16 Apr 2025 13:15:44 +0300 Subject: [PATCH 2/9] Tidy up cabal --- connexpay/connexpay.cabal | 55 +++++++++++-------------- connexpay/src/Web/Connexpay/Auth.hs | 4 +- connexpay/src/Web/Connexpay/Data.hs | 9 ++-- connexpay/src/Web/Connexpay/Init.hs | 1 - connexpay/src/Web/Connexpay/Payments.hs | 5 +-- connexpay/src/Web/Connexpay/Types.hs | 4 +- connexpay/{src/Tool.hs => tool/Main.hs} | 4 +- 7 files changed, 35 insertions(+), 47 deletions(-) rename connexpay/{src/Tool.hs => tool/Main.hs} (98%) diff --git a/connexpay/connexpay.cabal b/connexpay/connexpay.cabal index 90d22bc..473647f 100644 --- a/connexpay/connexpay.cabal +++ b/connexpay/connexpay.cabal @@ -9,13 +9,28 @@ maintainer: nick@typeable.io copyright: Typeable.io category: Web build-type: Simple --- extra-source-files: -common warnings - ghc-options: -Wall + +common common + default-extensions: + BlockArguments + DeriveAnyClass + DerivingVia + DuplicateRecordFields + LambdaCase + MultiWayIf + NoFieldSelectors + OverloadedLabels + OverloadedRecordDot + OverloadedStrings + RecordWildCards + default-language: GHC2021 + ghc-options: + -Wall -Wmissing-deriving-strategies -Wprepositive-qualified-module + -Wunused-packages -Wredundant-constraints library - import: warnings + import: common exposed-modules: Web.Connexpay Web.Connexpay.Auth Web.Connexpay.Data @@ -23,12 +38,6 @@ library Web.Connexpay.Payments Web.Connexpay.Types Web.Connexpay.Utils - default-extensions: DuplicateRecordFields - OverloadedLabels - OverloadedRecordDot - NoFieldSelectors - -- other-modules: - -- other-extensions: build-depends: base >=4.14 && < 5.0 , aeson , async @@ -42,36 +51,18 @@ library , text , uuid hs-source-dirs: src - default-language: GHC2021 executable connexpay-tool - import: warnings - default-extensions: DuplicateRecordFields - OverloadedLabels - OverloadedRecordDot - NoFieldSelectors + import: common build-depends: base >= 4.17 , aeson - , async , bucks - , bytestring - , http-api-data + , connexpay , http-client , http-client-tls - , http-types - , mtl , optparse-applicative - , req , text , uuid , yaml - hs-source-dirs: src - other-modules: Web.Connexpay - Web.Connexpay.Auth - Web.Connexpay.Data - Web.Connexpay.Init - Web.Connexpay.Payments - Web.Connexpay.Types - Web.Connexpay.Utils - main-is: Tool.hs - default-language: GHC2021 + hs-source-dirs: tool + main-is: Main.hs diff --git a/connexpay/src/Web/Connexpay/Auth.hs b/connexpay/src/Web/Connexpay/Auth.hs index 27d0f56..0d026ec 100644 --- a/connexpay/src/Web/Connexpay/Auth.hs +++ b/connexpay/src/Web/Connexpay/Auth.hs @@ -1,5 +1,5 @@ {-# LANGUAGE OverloadedLists #-} -{-# LANGUAGE OverloadedStrings #-} + module Web.Connexpay.Auth (authenticate) where import Web.Connexpay.Types @@ -33,7 +33,7 @@ mkAuthForm login passwd = ByteString.toStrict (urlEncodeAsForm form) data TokenReply = TokenReply { token :: BearerToken , expires_in :: Natural - } deriving (Show) + } deriving stock (Show) instance FromJSON TokenReply where parseJSON (Object v) = do typ <- v .: "token_type" diff --git a/connexpay/src/Web/Connexpay/Data.hs b/connexpay/src/Web/Connexpay/Data.hs index da5cbd1..6901a56 100644 --- a/connexpay/src/Web/Connexpay/Data.hs +++ b/connexpay/src/Web/Connexpay/Data.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE OverloadedStrings #-} module Web.Connexpay.Data ( TransactionStatus(..) , PaymentFailure(..) , ConnectionError(..) @@ -24,7 +23,7 @@ data TransactionStatus = TransactionApproved -- ^ Obvious | TransactionCreatedProcError -- ^ Processor errored out | TransactionApprovedWarning -- ^ Wut 0__o FIXME: figure out what this is | TransactionOther Text -- ^ In case they return something unexpected - deriving (Eq, Ord, Show) + deriving stock (Eq, Ord, Show) statuses :: [(Text, TransactionStatus)] statuses = [ ( "Transaction - Approved", TransactionApproved ) @@ -49,7 +48,7 @@ data PaymentFailure = CVVFailed -- ^ CVV verification failure | GeneralDecline -- ^ They just decline | LocalTransaction -- ^ Special case for transactions that were registered but did't go through somehow. | OtherProcessingError Text -- ^ Some other processing error with 422 code - deriving (Eq, Show) + deriving stock (Eq, Show) describeFailure :: PaymentFailure -> Text describeFailure CVVFailed = "CVV authorisation failure" @@ -81,7 +80,7 @@ data ConnectionError = ParseError String | InvalidUrl String String | HttpFailure HttpExceptionContent | TokenError String - deriving Show + deriving stock Show -- | Error type for Connexpay. -- There are two possible cases here: @@ -91,6 +90,6 @@ data ConnectionError = ParseError String -- No exception here, this must be handled as usual. data ConnexpayError = ConnectionError ConnectionError | PaymentFailure PaymentFailure (Maybe Text) - deriving (Show) + deriving stock (Show) instance Exception ConnexpayError diff --git a/connexpay/src/Web/Connexpay/Init.hs b/connexpay/src/Web/Connexpay/Init.hs index 713c228..cf5f855 100644 --- a/connexpay/src/Web/Connexpay/Init.hs +++ b/connexpay/src/Web/Connexpay/Init.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE OverloadedStrings #-} module Web.Connexpay.Init (initConnexpay) where import Web.Connexpay.Auth diff --git a/connexpay/src/Web/Connexpay/Payments.hs b/connexpay/src/Web/Connexpay/Payments.hs index f6133ab..cbd9f49 100644 --- a/connexpay/src/Web/Connexpay/Payments.hs +++ b/connexpay/src/Web/Connexpay/Payments.hs @@ -1,5 +1,4 @@ {-# LANGUAGE DataKinds #-} -{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE UndecidableInstances #-} @@ -132,7 +131,7 @@ data AuthResponse = AuthResponse { paymentGuid :: AuthOnlyGuid , processorMessage :: Maybe Text , addressVerificationCode :: Maybe Text , cvvVerificationCode :: Maybe Text - } deriving (Show) + } deriving stock (Show) instance FromJSON AuthResponse where parseJSON (Object o) = AuthResponse <$> o .: "guid" @@ -201,7 +200,7 @@ instance ToJSON CPTransaction where data CaptureResponse = CaptureResponse { captureGuid :: CaptureGuid , saleGuid :: SaleGuid , saleStatus :: TransactionStatus - } deriving (Show) + } deriving stock (Show) instance FromJSON CaptureResponse where parseJSON (Object o) = diff --git a/connexpay/src/Web/Connexpay/Types.hs b/connexpay/src/Web/Connexpay/Types.hs index 246ee5e..c8689c6 100644 --- a/connexpay/src/Web/Connexpay/Types.hs +++ b/connexpay/src/Web/Connexpay/Types.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE OverloadedStrings #-} module Web.Connexpay.Types where import Web.Connexpay.Data @@ -37,7 +36,8 @@ data Connexpay = Connexpay { logAction :: Text -> IO () } newtype ConnexpayM a = ConnexpayM (ReaderT Connexpay (ExceptT ConnexpayError IO) a) - deriving (Functor, Applicative, Monad, MonadIO, MonadReader Connexpay, MonadError ConnexpayError) + deriving newtype + (Functor, Applicative, Monad, MonadIO, MonadReader Connexpay, MonadError ConnexpayError) instance MonadHttp ConnexpayM where handleHttpException (JsonHttpException e) = throwError (ConnectionError $ ParseError e) diff --git a/connexpay/src/Tool.hs b/connexpay/tool/Main.hs similarity index 98% rename from connexpay/src/Tool.hs rename to connexpay/tool/Main.hs index 6693907..5f4ce53 100644 --- a/connexpay/src/Tool.hs +++ b/connexpay/tool/Main.hs @@ -1,5 +1,5 @@ {-# LANGUAGE ApplicativeDo #-} -{-# LANGUAGE OverloadedStrings #-} + module Main where import Control.Concurrent (yield) @@ -28,7 +28,7 @@ data Config = Config { login :: Text , use_tls :: Bool , proxy_host :: Maybe Text , proxy_port :: Maybe Word - } deriving Generic + } deriving stock Generic instance FromJSON Config From e1bd8c9fcc111a6bc8866638305bdd3805382f4a Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 11:25:10 +0300 Subject: [PATCH 3/9] Tidy .gitignore --- .gitignore | 64 ++++++++++++------------------------------------------ 1 file changed, 14 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 310a83a..b91670a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,65 +1,29 @@ +# https://github.com/github/gitignore/blob/main/Haskell.gitignore dist dist-* cabal-dev -*~ -*.swp -*.swo -\#*\# -*.elc *.o -*.prof *.hi *.hie *.chi *.chs.h *.dyn_o *.dyn_hi -*.pdf -*.prof -*.log -*.aes -*.hp -*.eventlog -*.eventlog.html -.virtualenv +.hpc .hsenv .cabal-sandbox/ -**/.stack-work* cabal.sandbox.config -cabal.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ cabal.project.local -TAGS -!TAGS/ -tags -!tags/ -client.crt -client.key -admin/static/markup-rule/*.gz -admin/static/markup-rule/*.map -**/admin/static/dev -/docker/stack -/docker/ghcjs -/docker/stack-work -/docker/node_modules -/docker/nix -/nix/result* -/nix/stackage/*.nix -.tmp/ -stack*.yaml.lock -.envrc -.bin -.vscode -/air/seatmap-frontend/.ghc.environment.* -/air/seatmap-frontend/result -.hpc -cabal*.project.local -cabal*.project.local~ +cabal.project.local~ .HTF/ -.ghc.environment.* -Makefile.local -.gcroots -hie.yaml -.dir-locals.el -/sso/auth-frontend/elm-pages/dev/elm.js -/bin -/result* + +stack.yaml.lock + +# Temp files +*~ +\#*\# From 5cb5cafbd00e159d9d3be5cfb41eec66e1f94256 Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 10:51:35 +0300 Subject: [PATCH 4/9] Add cabal.project --- cabal.project | 15 ++++ cabal.project.freeze | 201 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 cabal.project create mode 100644 cabal.project.freeze diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..24e8a93 --- /dev/null +++ b/cabal.project @@ -0,0 +1,15 @@ +with-compiler: ghc-9.6.6 + +packages: + connexpay/ + connexpay-optparse/ + +source-repository-package + type: git + location: https://github.com/typeable/bucks.git + tag: 9e378b675fe7fb88d5ddb3af068d82eb441f343c + +source-repository-package + type: git + location: https://github.com/typeable/req.git + tag: 8829ac5197f7a4b3f04b7fdfc3ea66cfe70ab0a5 diff --git a/cabal.project.freeze b/cabal.project.freeze new file mode 100644 index 0000000..40b872a --- /dev/null +++ b/cabal.project.freeze @@ -0,0 +1,201 @@ +active-repositories: hackage.haskell.org:merge +constraints: any.Cabal ==3.10.3.0, + any.Cabal-syntax ==3.10.3.0, + any.OneTuple ==0.4.2, + any.QuickCheck ==2.14.3, + QuickCheck -old-random +templatehaskell, + any.RSA ==2.4.1, + any.SHA ==1.6.4.4, + SHA -exe, + any.StateVar ==1.2.2, + any.aeson ==2.1.2.1, + aeson -cffi +ordered-keymap, + any.ansi-terminal ==1.0.2, + ansi-terminal -example, + any.ansi-terminal-types ==0.11.5, + any.appar ==0.1.8, + any.array ==0.5.6.0, + any.asn1-encoding ==0.9.6, + any.asn1-parse ==0.9.5, + any.asn1-types ==0.3.4, + any.assoc ==1.1.1, + assoc -tagged, + any.async ==2.2.5, + async -bench, + any.attoparsec ==0.14.4, + attoparsec -developer, + any.attoparsec-iso8601 ==1.1.1.0, + any.authenticate-oauth ==1.7, + any.base ==4.18.2.1, + any.base-compat ==0.13.1, + any.base-compat-batteries ==0.13.1, + any.base-orphans ==0.9.2, + any.base64-bytestring ==1.2.1.0, + any.basement ==0.0.16, + any.bifunctors ==5.6.2, + bifunctors +tagged, + any.binary ==0.8.9.1, + any.bitvec ==1.1.5.0, + bitvec +simd, + any.blaze-builder ==0.4.2.3, + any.bucks ==0.1, + bucks -aeson -openapi -rel8, + any.byteorder ==1.0.4, + any.bytestring ==0.11.5.3, + any.case-insensitive ==1.2.1.0, + any.cereal ==0.5.8.3, + cereal -bytestring-builder, + any.colour ==2.3.6, + any.comonad ==5.0.8, + comonad +containers +distributive +indexed-traversable, + any.conduit ==1.3.6, + any.containers ==0.6.7, + any.contravariant ==1.5.5, + contravariant +semigroups +statevar +tagged, + any.cookie ==0.4.6, + any.crypto-api ==0.13.3, + crypto-api -all_cpolys, + any.crypto-pubkey-types ==0.4.3, + any.cryptohash-md5 ==0.11.101.0, + any.cryptohash-sha1 ==0.11.101.0, + any.crypton ==0.34, + crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes, + any.crypton-connection ==0.3.2, + any.crypton-x509 ==1.7.7, + any.crypton-x509-store ==1.6.9, + any.crypton-x509-system ==1.6.7, + any.crypton-x509-validation ==1.6.12, + any.data-default ==0.7.1.1, + any.data-default-class ==0.1.2.0, + any.data-default-instances-containers ==0.0.1, + any.data-default-instances-dlist ==0.0.1, + any.data-default-instances-old-locale ==0.0.1, + any.data-fix ==0.3.4, + any.deepseq ==1.4.8.1, + any.directory ==1.3.8.5, + any.distributive ==0.6.2.1, + distributive +semigroups +tagged, + any.dlist ==1.0, + dlist -werror, + any.entropy ==0.4.1.10, + entropy -donotgetentropy, + any.exceptions ==0.10.7, + any.filepath ==1.4.300.1, + any.generically ==0.1.1, + any.ghc-bignum ==1.3, + any.ghc-boot-th ==9.6.6, + any.ghc-prim ==0.10.0, + any.groups ==0.5.3, + any.hashable ==1.4.4.0, + hashable +integer-gmp -random-initial-seed, + any.hourglass ==0.2.12, + any.hsc2hs ==0.68.10, + hsc2hs -in-ghc-tree, + any.http-api-data ==0.5.1, + http-api-data -use-text-show, + any.http-client ==0.7.17, + http-client +network-uri, + any.http-client-tls ==0.3.6.3, + any.http-types ==0.12.4, + any.indexed-traversable ==0.1.4, + any.indexed-traversable-instances ==0.1.2, + any.integer-conversion ==0.1.0.1, + any.integer-gmp ==1.1, + any.integer-logarithms ==1.0.3.1, + integer-logarithms -check-bounds +integer-gmp, + any.iproute ==1.7.14, + any.libyaml ==0.1.4, + libyaml -no-unicode -system-libyaml, + any.libyaml-clib ==0.2.5, + any.megaparsec ==9.5.0, + megaparsec -dev, + any.memory ==0.18.0, + memory +support_bytestring +support_deepseq, + any.mime-types ==0.1.2.0, + any.modern-uri ==0.3.6.1, + modern-uri -dev, + any.monad-control ==1.0.3.1, + any.mono-traversable ==1.0.20.0, + any.mtl ==2.3.1, + any.mtl-compat ==0.2.2, + mtl-compat -two-point-one -two-point-two, + any.network ==3.1.4.0, + network -devel, + any.network-info ==0.2.1, + any.network-uri ==2.6.4.2, + any.old-locale ==1.0.0.7, + any.old-time ==1.1.0.4, + any.optparse-applicative ==0.18.1.0, + optparse-applicative +process, + any.os-string ==2.0.6, + any.parsec ==3.1.16.1, + any.parser-combinators ==1.3.0, + parser-combinators -dev, + any.pem ==0.2.4, + any.pretty ==1.1.3.6, + any.prettyprinter ==1.7.1, + prettyprinter -buildreadme +text, + any.prettyprinter-ansi-terminal ==1.1.3, + any.primitive ==0.8.0.0, + any.process ==1.6.19.0, + any.profunctors ==5.6.2, + any.random ==1.2.1.2, + any.reflection ==2.1.8, + reflection -slow +template-haskell, + any.req ==3.13.4, + req -dev, + any.resourcet ==1.3.0, + any.retry ==0.9.3.1, + retry -lib-werror, + any.rts ==1.0.2, + any.scientific ==0.3.7.0, + scientific -bytestring-builder -integer-simple, + any.semialign ==1.3.1, + semialign +semigroupoids, + any.semigroupoids ==6.0.1, + semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers, + any.socks ==0.6.1, + any.split ==0.2.5, + any.splitmix ==0.1.0.5, + splitmix -optimised-mixer, + any.stm ==2.5.1.0, + any.streaming-commons ==0.2.2.6, + streaming-commons -use-bytestring-builder, + any.strict ==0.5, + any.tagged ==0.8.8, + tagged +deepseq +transformers, + any.template-haskell ==2.20.0.0, + any.text ==2.0.2, + any.text-short ==0.1.6, + text-short -asserts, + any.th-abstraction ==0.5.0.0, + any.th-compat ==0.1.5, + any.these ==1.2.1, + any.time ==1.12.2, + any.time-compat ==1.9.6.1, + time-compat -old-locale, + any.tls ==1.8.0, + tls +compat -hans +network, + any.transformers ==0.6.1.0, + any.transformers-base ==0.4.6, + transformers-base +orphaninstances, + any.transformers-compat ==0.7.2, + transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, + any.unix ==2.8.4.0, + any.unix-time ==0.4.15, + any.unliftio-core ==0.2.1.0, + any.unordered-containers ==0.2.20, + unordered-containers -debug, + any.uuid ==1.3.15, + any.uuid-types ==1.0.5.1, + any.vector ==0.13.1.0, + vector +boundschecks -internalchecks -unsafechecks -wall, + any.vector-algorithms ==0.9.0.2, + vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks, + any.vector-stream ==0.1.0.1, + any.witherable ==0.4.2, + any.yaml ==0.11.11.2, + yaml +no-examples +no-exe, + any.zlib ==0.6.3.0, + zlib -bundled-c-zlib -non-blocking-ffi -pkg-config +index-state: hackage.haskell.org 2025-03-23T06:19:38Z From 98a2b96da23ab10e3a4d99d3ed55c099bc70456b Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 11:24:57 +0300 Subject: [PATCH 5/9] CI --- .github/workflows/haskell-ci.yml | 224 ++++++++++++++++++++ cabal.haskell-ci | 1 + connexpay-optparse/connexpay-optparse.cabal | 3 + connexpay/connexpay.cabal | 2 + 4 files changed, 230 insertions(+) create mode 100644 .github/workflows/haskell-ci.yml create mode 100644 cabal.haskell-ci diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml new file mode 100644 index 0000000..98a39cb --- /dev/null +++ b/.github/workflows/haskell-ci.yml @@ -0,0 +1,224 @@ +# This GitHub workflow config has been generated by a script via +# +# haskell-ci 'github' 'cabal.project' +# +# To regenerate the script (for example after adjusting tested-with) run +# +# haskell-ci regenerate +# +# For more information, see https://github.com/haskell-CI/haskell-ci +# +# version: 0.19.20250330 +# +# REGENDATA ("0.19.20250330",["github","cabal.project"]) +# +name: Haskell-CI +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + linux: + name: Haskell-CI - Linux - ${{ matrix.compiler }} + runs-on: ubuntu-24.04 + timeout-minutes: + 60 + container: + image: buildpack-deps:jammy + continue-on-error: ${{ matrix.allow-failure }} + strategy: + matrix: + include: + - compiler: ghc-9.10.1 + compilerKind: ghc + compilerVersion: 9.10.1 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.8.4 + compilerKind: ghc + compilerVersion: 9.8.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.6.6 + compilerKind: ghc + compilerVersion: 9.6.6 + setup-method: ghcup + allow-failure: false + fail-fast: false + steps: + - name: apt-get install + run: | + apt-get update + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + - name: Install GHCup + run: | + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.50.1/x86_64-linux-ghcup-0.1.50.1 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + - name: Install cabal-install + run: | + "$HOME/.ghcup/bin/ghcup" install cabal 3.14.1.1-p1 || (cat "$HOME"/.ghcup/logs/*.* && false) + echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.1.1-p1 -vnormal+nowrap" >> "$GITHUB_ENV" + - name: Install GHC (GHCup) + if: matrix.setup-method == 'ghcup' + run: | + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: Set PATH and environment variables + run: | + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + echo "LANG=C.UTF-8" >> "$GITHUB_ENV" + echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" + echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" + HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') + echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" + echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" + echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" + echo "HEADHACKAGE=false" >> "$GITHUB_ENV" + echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: env + run: | + env + - name: write cabal config + run: | + mkdir -p $CABAL_DIR + cat >> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz + echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c - + xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan + rm -f cabal-plan.xz + chmod a+x $HOME/.cabal/bin/cabal-plan + cabal-plan --version + - name: checkout + uses: actions/checkout@v4 + with: + path: source + - name: initial cabal.project for sdist + run: | + touch cabal.project + echo "packages: $GITHUB_WORKSPACE/source/connexpay" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/connexpay-optparse" >> cabal.project + cat cabal.project + - name: sdist + run: | + mkdir -p sdist + $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist + - name: unpack + run: | + mkdir -p unpacked + find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; + - name: generate cabal.project + run: | + PKGDIR_connexpay="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/connexpay-[0-9.]*')" + echo "PKGDIR_connexpay=${PKGDIR_connexpay}" >> "$GITHUB_ENV" + PKGDIR_connexpay_optparse="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/connexpay-optparse-[0-9.]*')" + echo "PKGDIR_connexpay_optparse=${PKGDIR_connexpay_optparse}" >> "$GITHUB_ENV" + rm -f cabal.project cabal.project.local + touch cabal.project + touch cabal.project.local + echo "packages: ${PKGDIR_connexpay}" >> cabal.project + echo "packages: ${PKGDIR_connexpay_optparse}" >> cabal.project + echo "package connexpay" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project + echo "package connexpay-optparse" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project + cat >> cabal.project <> cabal.project.local + cat cabal.project + cat cabal.project.local + - name: dump install plan + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all + cabal-plan + - name: restore cache + uses: actions/cache/restore@v4 + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store + restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- + - name: install dependencies + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all + - name: build w/o tests + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: build + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always + - name: cabal check + run: | + cd ${PKGDIR_connexpay} || false + ${CABAL} -vnormal check + cd ${PKGDIR_connexpay_optparse} || false + ${CABAL} -vnormal check + - name: haddock + run: | + $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all + - name: unconstrained build + run: | + rm -f cabal.project.local + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: save cache + if: always() + uses: actions/cache/save@v4 + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store diff --git a/cabal.haskell-ci b/cabal.haskell-ci new file mode 100644 index 0000000..e1f1b77 --- /dev/null +++ b/cabal.haskell-ci @@ -0,0 +1 @@ +branches: master diff --git a/connexpay-optparse/connexpay-optparse.cabal b/connexpay-optparse/connexpay-optparse.cabal index 603c0fd..7a4ced7 100644 --- a/connexpay-optparse/connexpay-optparse.cabal +++ b/connexpay-optparse/connexpay-optparse.cabal @@ -10,6 +10,9 @@ copyright: Antorica LLC category: System build-type: Simple + +tested-with: GHC ==9.10.1 || ==9.8.4 || ==9.6.6 + common warnings ghc-options: -Wall diff --git a/connexpay/connexpay.cabal b/connexpay/connexpay.cabal index 473647f..4204271 100644 --- a/connexpay/connexpay.cabal +++ b/connexpay/connexpay.cabal @@ -11,6 +11,8 @@ category: Web build-type: Simple +tested-with: GHC ==9.10.1 || ==9.8.4 || ==9.6.6 + common common default-extensions: BlockArguments From 8f4c177a03699c1b5cfc0db16dabfa6412d5cb0e Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 11:50:29 +0300 Subject: [PATCH 6/9] CI fixes --- connexpay-optparse/connexpay-optparse.cabal | 3 ++- connexpay/connexpay.cabal | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/connexpay-optparse/connexpay-optparse.cabal b/connexpay-optparse/connexpay-optparse.cabal index 7a4ced7..0ec728c 100644 --- a/connexpay-optparse/connexpay-optparse.cabal +++ b/connexpay-optparse/connexpay-optparse.cabal @@ -1,5 +1,6 @@ cabal-version: 3.0 name: connexpay-optparse +description: Parsing CLI arguments for connexpay version: 0.1 synopsis: Optparse Applicative combinators for Connexpay license: MIT @@ -11,7 +12,7 @@ category: System build-type: Simple -tested-with: GHC ==9.10.1 || ==9.8.4 || ==9.6.6 +tested-with: GHC ==9.8.4 || ==9.6.6 common warnings ghc-options: -Wall diff --git a/connexpay/connexpay.cabal b/connexpay/connexpay.cabal index 4204271..db79f41 100644 --- a/connexpay/connexpay.cabal +++ b/connexpay/connexpay.cabal @@ -1,5 +1,6 @@ cabal-version: 3.0 name: connexpay +description: Interacting with Connexpay API version: 0.1 synopsis: ConnexPay library for Haskell homepage: https://github.com/typeable/connexpay @@ -11,7 +12,7 @@ category: Web build-type: Simple -tested-with: GHC ==9.10.1 || ==9.8.4 || ==9.6.6 +tested-with: GHC ==9.8.4 || ==9.6.6 common common default-extensions: From 88c1550aef9ae45e9d89f93d22308e3dad70ec27 Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 12:09:55 +0300 Subject: [PATCH 7/9] LICENSE --- connexpay/LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 connexpay/LICENSE diff --git a/connexpay/LICENSE b/connexpay/LICENSE new file mode 100644 index 0000000..72d29ee --- /dev/null +++ b/connexpay/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Typeable + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From f274e448e4a5d09fbe8e5ff22a235d673fdfe5b0 Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 12:14:20 +0300 Subject: [PATCH 8/9] Regenerate CI --- .github/workflows/haskell-ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 98a39cb..31a5785 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -32,11 +32,6 @@ jobs: strategy: matrix: include: - - compiler: ghc-9.10.1 - compilerKind: ghc - compilerVersion: 9.10.1 - setup-method: ghcup - allow-failure: false - compiler: ghc-9.8.4 compilerKind: ghc compilerVersion: 9.8.4 From c34d2f35dc7aac4487a8402903baa0c99b225834 Mon Sep 17 00:00:00 2001 From: Uladzimir Stsepchanka Date: Fri, 18 Apr 2025 12:19:36 +0300 Subject: [PATCH 9/9] Oops --- connexpay/connexpay.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connexpay/connexpay.cabal b/connexpay/connexpay.cabal index db79f41..d0028dc 100644 --- a/connexpay/connexpay.cabal +++ b/connexpay/connexpay.cabal @@ -4,7 +4,7 @@ description: Interacting with Connexpay API version: 0.1 synopsis: ConnexPay library for Haskell homepage: https://github.com/typeable/connexpay -license: NONE +license: MIT author: Nick maintainer: nick@typeable.io copyright: Typeable.io