Combine test and application dependencies

This commit is contained in:
Eugen Wissner 2023-09-21 23:51:02 +02:00
parent 77c9a2ab54
commit a7114618c1
4 changed files with 31 additions and 7 deletions

View File

@ -22,6 +22,7 @@ import Text.URI.QQ (uri)
import Data.Foldable (for_) import Data.Foldable (for_)
import qualified Text.URI as URI import qualified Text.URI as URI
import GHC.Records (HasField(..)) import GHC.Records (HasField(..))
import System.FilePath ((</>), (<.>))
data Package = Package data Package = Package
{ latest :: Package.Updater { latest :: Package.Updater
@ -77,12 +78,20 @@ updatePackage Package{..} version = do
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
let tarball = "slackbuilds/development/universal-ctags/ctags-#{version}.tar.gz" let tarball = "slackbuilds/development/universal-ctags/ctags-#{version}.tar.gz"
checksum <- fromMaybe undefined <$> download uri' tarball checksum <- fromMaybe undefined <$> download uri' tarball
download' <- liftIO $ mkURI "https://download.dlackware.com/hosted-sources/universal-ctags/ctags-#{version}.tar.gz" download' <- liftIO
$ mkURI
$ Text.replace "#{version}" version
"https://download.dlackware.com/hosted-sources/universal-ctags/ctags-#{version}.tar.gz"
repository' <- SlackBuilderT $ asks repository
let infoFilePath = repository' </> Text.unpack packagePath
</> (Text.unpack name <.> "info")
liftIO $ Text.IO.writeFile "slackbuilds/#{package.path}/#{package.name}.info" liftIO $ Text.IO.writeFile infoFilePath
$ Package.infoTemplate package' [Package.Download download' checksum False] $ Package.infoTemplate package' [Package.Download download' checksum False]
updateSlackBuildVersion packagePath version updateSlackBuildVersion packagePath version
uploadCommand (Text.pack tarball) "#{CONFIG[:remote_path]}/universal-ctags"
remotePath' <- SlackBuilderT $ asks remotePath
uploadCommand (Text.pack tarball) $ remotePath' <> "/universal-ctags"
commit packagePath version commit packagePath version

View File

@ -63,6 +63,7 @@ instance Show DownloadTemplate
where where
show (DownloadTemplate components) = concatMap show components show (DownloadTemplate components) = concatMap show components
-- | Replaces placeholders in the URL template with the given version.
renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI
renderDownloadWithVersion (DownloadTemplate components) version = renderDownloadWithVersion (DownloadTemplate components) version =
URI.mkURI $ foldr f "" components URI.mkURI $ foldr f "" components

View File

@ -15,7 +15,13 @@ maintainer: belka@caraus.de
category: Build category: Build
extra-source-files: CHANGELOG.md extra-source-files: CHANGELOG.md
common dependencies
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends:
base ^>= 4.16.4.0,
executable slackbuilder executable slackbuilder
import: dependencies
main-is: Main.hs main-is: Main.hs
other-modules: other-modules:
@ -37,7 +43,6 @@ executable slackbuilder
TypeApplications TypeApplications
build-depends: build-depends:
aeson ^>= 2.2.0, aeson ^>= 2.2.0,
base ^>= 4.16.4.0,
bytestring ^>= 0.11.0, bytestring ^>= 0.11.0,
conduit ^>= 1.3.5, conduit ^>= 1.3.5,
cryptonite >= 0.30, cryptonite >= 0.30,
@ -56,14 +61,15 @@ executable slackbuilder
hs-source-dirs: app hs-source-dirs: app
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
test-suite slackbuilder-test test-suite slackbuilder-test
import: dependencies
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: Spec.hs main-is: Spec.hs
other-modules:
SlackBuilder.PackageSpec
hs-source-dirs: hs-source-dirs:
tests tests
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
default-language: Haskell2010 default-language: Haskell2010
build-depends: build-depends:
hspec >= 2.10.9 && < 2.12 hspec >= 2.10.9 && < 2.12

View File

@ -0,0 +1,8 @@
module SlackBuilder.PackageSpec
( spec
) where
import Test.Hspec (Spec)
spec :: Spec
spec = pure ()