From fedb73a665b5adb23cfe09cfee5cde522035bf72 Mon Sep 17 00:00:00 2001 From: iko Date: Mon, 24 Feb 2020 21:02:46 +0300 Subject: [PATCH] Proper utf-8 decoding --- package.yaml | 1 + src/Data/Tasks/Build.hs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.yaml b/package.yaml index 7486bf3..8c4eba7 100644 --- a/package.yaml +++ b/package.yaml @@ -52,6 +52,7 @@ library: - transformers - cassava - http-media + - utf8-string executables: sc-build-exe: diff --git a/src/Data/Tasks/Build.hs b/src/Data/Tasks/Build.hs index 394273f..8a2377d 100644 --- a/src/Data/Tasks/Build.hs +++ b/src/Data/Tasks/Build.hs @@ -16,7 +16,7 @@ import Control.Monad.IO.Unlift import Control.Task import Data.Aeson hiding (Success) import qualified Data.ByteString.Lazy.Char8 as BS -import Data.Char +import qualified Data.ByteString.Lazy.UTF8 as BS import Data.String import Data.Submission import Data.Submission.Query @@ -55,7 +55,7 @@ instance Task Build "build-repo" where (shellCode, _, shellErr) <- readProcess . setWorkingDir dir $ shell preProcessShell case shellCode of ExitFailure n -> do - let err = BS.unpack shellErr + let err = BS.toString shellErr logError . T.pack $ "preprocessing command for repo " <> show fullRepoName <> " at sha " <> show sha @@ -129,7 +129,7 @@ instance Task Build "build-repo" where return (buildCode, buildOut, buildErr) case dockerRes of (ExitFailure n, _, buildErr) -> do - let err = filter (\c -> isPrint c || isSpace c) . BS.unpack $ buildErr + let err = BS.toString buildErr logError . T.pack $ "test command for repo " <> show fullRepoName <> " at sha " <> show sha @@ -142,7 +142,7 @@ instance Task Build "build-repo" where (ExitSuccess, buildOut, _) -> case eitherDecode' (BS.dropWhile (/= '{') buildOut) of Left err' -> do - let err = err' <> " " <> BS.unpack buildOut + let err = err' <> " " <> BS.toString buildOut logError . T.pack $ "could not decode test result from repo " <> show fullRepoName <> " at sha " @@ -150,7 +150,7 @@ instance Task Build "build-repo" where <> ": " <> err scheduleFailedStatus err owner repoName sha - updateSubmissionStatus fullRepoName sha' (SubmissionFailed (err <> BS.unpack buildOut)) + updateSubmissionStatus fullRepoName sha' (SubmissionFailed (err <> BS.toString buildOut)) Right testResult@TestResult {..} -> do scheduleTestedStatus testResult owner repoName sha updateSubmissionStatus fullRepoName sha' (SubmissionRun testResult)