Make local paths relative to cwd
Some checks failed
Build / test (push) Failing after 5m55s
Build / audit (push) Successful in 13m8s

This commit is contained in:
Eugen Wissner 2024-03-05 23:06:32 +01:00
parent cd15b25db1
commit 16c7063224
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
3 changed files with 22 additions and 32 deletions

View File

@ -7,25 +7,19 @@ on:
jobs: jobs:
audit: audit:
runs-on: alpine runs-on: haskell
steps: steps:
- name: Set up environment - name: Set up environment
shell: ash {0}
run: | run: |
apk add --no-cache git bash curl build-base readline-dev openssl-dev zlib-dev libpq-dev gmp-dev apt-get update -y
- name: Prepare system apt-get upgrade -y
run: | apt-get install -y nodejs pkg-config liblzma-dev
curl --create-dirs --output-dir \
~/.ghcup/bin https://downloads.haskell.org/~ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 -o ghcup
chmod +x ~/.ghcup/bin/ghcup
~/.ghcup/bin/ghcup install ghc 9.4.8
~/.ghcup/bin/ghcup install cabal 3.6.2.0
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: | run: |
~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal update cabal update
~/.ghcup/bin/ghcup run --ghc 9.4.8 --cabal 3.6.2.0 -- cabal install hlint --constraint="hlint ==3.6.1" cabal install hlint "--constraint=hlint ==3.6.1"
- run: ~/.cabal/bin/hlint -- src lib tests - run: cabal exec hlint -- src lib tests
test: test:
runs-on: alpine runs-on: alpine

View File

@ -142,16 +142,6 @@ remoteFileExists url = hostedSources url
} }
go uri = req HEAD uri NoReqBody ignoreResponse mempty go uri = req HEAD uri NoReqBody ignoreResponse mempty
uploadCommand :: FilePath -> Text -> SlackBuilderT ()
uploadCommand localPath remotePath' = do
remoteRoot <- SlackBuilderT $ asks remotePath
localPathFromRepository <- relativeToRepository localPath
liftIO $ callProcess "scp"
[ localPathFromRepository
, Text.unpack $ remoteRoot <> remotePath'
]
cloneAndArchive :: Text -> FilePath -> Text -> SlackBuilderT () cloneAndArchive :: Text -> FilePath -> Text -> SlackBuilderT ()
cloneAndArchive repo tarballPath tagPrefix = do cloneAndArchive repo tarballPath tagPrefix = do
let version = snd $ Text.breakOnEnd "-" let version = snd $ Text.breakOnEnd "-"
@ -217,6 +207,19 @@ cloneAndUpload repo tarballPath tagPrefix = do
>> uploadCommand localPath remoteArchivePath >> uploadCommand localPath remoteArchivePath
>> liftIO (runConduitRes go) <&> (remoteResultURI,) >> liftIO (runConduitRes go) <&> (remoteResultURI,)
-- | Given a path to a local file and a remote path uploads the file using
-- the settings given in the configuration file.
--
-- The remote path is given relative to the path in the configuration.
uploadCommand :: FilePath -> Text -> SlackBuilderT ()
uploadCommand localPath remotePath' = do
remoteRoot <- SlackBuilderT $ asks remotePath
liftIO $ callProcess "scp"
[ localPath
, Text.unpack $ remoteRoot <> remotePath'
]
-- | Downlaods a file into the directory. Returns name of the downloaded file -- | Downlaods a file into the directory. Returns name of the downloaded file
-- and checksum. -- and checksum.
-- --

View File

@ -391,11 +391,7 @@ downloadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilder
downloadWithTemplate downloadTemplate packagePath version = do downloadWithTemplate downloadTemplate packagePath version = do
repository' <- SlackBuilderT $ asks repository repository' <- SlackBuilderT $ asks repository
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
let downloadFileName = URI.unRText checksum <- download uri' $ repository' </> Text.unpack packagePath
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
relativeTarball = packagePath <> "/" <> downloadFileName
tarball = repository' </> Text.unpack relativeTarball
checksum <- download uri' tarball
pure $ Package.Download uri' $ snd checksum pure $ Package.Download uri' $ snd checksum
reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT Package.Download reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT Package.Download
@ -409,10 +405,7 @@ reuploadWithTemplate downloadTemplate commands packagePath version = do
(checksum, relativeTarball') <- case commands of (checksum, relativeTarball') <- case commands of
[] -> do [] -> do
let relativeTarball = packagePathRelativeToCurrent (downloadedFileName, checksum) <- download uri' packagePathRelativeToCurrent
</> downloadFileName
(downloadedFileName, checksum) <- download uri'
$ repository' </> relativeTarball
pure (checksum, packagePathRelativeToCurrent </> downloadedFileName) pure (checksum, packagePathRelativeToCurrent </> downloadedFileName)
_ -> do _ -> do
changedArchiveRootName <- extractRemote uri' packagePathRelativeToCurrent changedArchiveRootName <- extractRemote uri' packagePathRelativeToCurrent