mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-28 23:22:00 +03:00
fix hlint warnings
This commit is contained in:
parent
24252bac2e
commit
fbcded8cde
79
src/Check.hs
79
src/Check.hs
@ -109,8 +109,8 @@ checkTestsBuildReport True =
|
||||
|
||||
checkReport :: BinaryCheck -> Text
|
||||
checkReport (BinaryCheck p False False) =
|
||||
"- Warning: no invocation of " <> T.pack p <>
|
||||
" had a zero exit code or showed the expected version"
|
||||
"- Warning: no invocation of " <>
|
||||
T.pack p <> " had a zero exit code or showed the expected version"
|
||||
checkReport (BinaryCheck p _ _) =
|
||||
"- " <> T.pack p <> " passed the binary check."
|
||||
|
||||
@ -127,48 +127,49 @@ ourLockedDownReadProcessInterleaved processConfig tempDir =
|
||||
foundVersionInOutputs :: Text -> String -> IO (Maybe Text)
|
||||
foundVersionInOutputs expectedVersion resultPath =
|
||||
hush <$>
|
||||
(runExceptT $ do
|
||||
(exitCode, _) <-
|
||||
proc "grep" ["-r", T.unpack expectedVersion, resultPath] &
|
||||
ourReadProcessInterleaved
|
||||
case exitCode of
|
||||
ExitSuccess ->
|
||||
return $
|
||||
"- found " <> expectedVersion <> " with grep in " <> T.pack resultPath <>
|
||||
"\n"
|
||||
_ -> throwE "grep did not find version in file names")
|
||||
runExceptT
|
||||
(do (exitCode, _) <-
|
||||
proc "grep" ["-r", T.unpack expectedVersion, resultPath] &
|
||||
ourReadProcessInterleaved
|
||||
case exitCode of
|
||||
ExitSuccess ->
|
||||
return $
|
||||
"- found " <>
|
||||
expectedVersion <> " with grep in " <> T.pack resultPath <> "\n"
|
||||
_ -> throwE "grep did not find version in file names")
|
||||
|
||||
foundVersionInFileNames :: Text -> String -> IO (Maybe Text)
|
||||
foundVersionInFileNames expectedVersion resultPath =
|
||||
hush <$>
|
||||
(runExceptT $ do
|
||||
(_, contents) <- shell ("find " <> resultPath) & ourReadProcessInterleaved
|
||||
(contents =~ versionRegex expectedVersion) & hoistMaybe &
|
||||
noteT (T.pack "Expected version not found")
|
||||
return $
|
||||
"- found " <> expectedVersion <> " in filename of file in " <>
|
||||
T.pack resultPath <>
|
||||
"\n")
|
||||
runExceptT
|
||||
(do (_, contents) <-
|
||||
shell ("find " <> resultPath) & ourReadProcessInterleaved
|
||||
(contents =~ versionRegex expectedVersion) & hoistMaybe &
|
||||
noteT (T.pack "Expected version not found")
|
||||
return $
|
||||
"- found " <>
|
||||
expectedVersion <>
|
||||
" in filename of file in " <> T.pack resultPath <> "\n")
|
||||
|
||||
treeGist :: String -> IO (Maybe Text)
|
||||
treeGist resultPath =
|
||||
hush <$>
|
||||
(runExceptT $
|
||||
(do contents <- proc "tree" [resultPath] & ourReadProcessInterleavedBS_
|
||||
g <-
|
||||
shell "gist" & setStdin (byteStringInput contents) &
|
||||
ourReadProcessInterleaved_
|
||||
return $ "- directory tree listing: " <> g <> "\n"))
|
||||
runExceptT
|
||||
(do contents <- proc "tree" [resultPath] & ourReadProcessInterleavedBS_
|
||||
g <-
|
||||
shell "gist" & setStdin (byteStringInput contents) &
|
||||
ourReadProcessInterleaved_
|
||||
return $ "- directory tree listing: " <> g <> "\n")
|
||||
|
||||
duGist :: String -> IO (Maybe Text)
|
||||
duGist resultPath =
|
||||
hush <$>
|
||||
(runExceptT $
|
||||
(do contents <- proc "du" [resultPath] & ourReadProcessInterleavedBS_
|
||||
g <-
|
||||
shell "gist" & setStdin (byteStringInput contents) &
|
||||
ourReadProcessInterleaved_
|
||||
return $ "- du listing: " <> g <> "\n"))
|
||||
runExceptT
|
||||
(do contents <- proc "du" [resultPath] & ourReadProcessInterleavedBS_
|
||||
g <-
|
||||
shell "gist" & setStdin (byteStringInput contents) &
|
||||
ourReadProcessInterleaved_
|
||||
return $ "- du listing: " <> g <> "\n")
|
||||
|
||||
result :: MonadIO m => UpdateEnv -> String -> m Text
|
||||
result updateEnv resultPath =
|
||||
@ -206,16 +207,20 @@ result updateEnv resultPath =
|
||||
fromMaybe "" <$>
|
||||
foundVersionInOutputs expectedVersion resultPath <>
|
||||
foundVersionInFileNames expectedVersion resultPath <>
|
||||
treeGist resultPath <>
|
||||
duGist resultPath
|
||||
treeGist resultPath <> duGist resultPath
|
||||
return $
|
||||
let testsBuildSummary = checkTestsBuildReport testsBuild
|
||||
c = T.intercalate "\n" (map checkReport checks')
|
||||
binaryCheckSummary =
|
||||
"- " <> passedZeroExitCode <> " of " <> numBinaries <>
|
||||
" passed binary check by having a zero exit code."
|
||||
"- " <>
|
||||
passedZeroExitCode <>
|
||||
" of " <>
|
||||
numBinaries <> " passed binary check by having a zero exit code."
|
||||
versionPresentSummary =
|
||||
"- " <> passedVersionPresent <> " of " <> numBinaries <>
|
||||
"- " <>
|
||||
passedVersionPresent <>
|
||||
" of " <>
|
||||
numBinaries <>
|
||||
" passed binary check by having the new version present in output."
|
||||
in [interpolate|
|
||||
$testsBuildSummary
|
||||
|
49
src/Main.hs
49
src/Main.hs
@ -20,7 +20,7 @@ import Utils (Options(..), setupNixpkgs)
|
||||
|
||||
default (T.Text)
|
||||
|
||||
data UpdateOptions =
|
||||
newtype UpdateOptions =
|
||||
UpdateOptions
|
||||
{ dry :: Bool
|
||||
}
|
||||
@ -33,7 +33,7 @@ data Command
|
||||
|
||||
updateOptionsParser :: O.Parser Command
|
||||
updateOptionsParser =
|
||||
Update <$> UpdateOptions <$>
|
||||
Update . UpdateOptions <$>
|
||||
O.switch
|
||||
(O.long "dry-run" <>
|
||||
O.help
|
||||
@ -42,31 +42,32 @@ updateOptionsParser =
|
||||
commandParser :: O.Parser Command
|
||||
commandParser =
|
||||
O.hsubparser
|
||||
((O.command
|
||||
"update"
|
||||
(O.info updateOptionsParser (O.progDesc "Update packages"))) <>
|
||||
(O.command
|
||||
"delete-done"
|
||||
(O.info
|
||||
(pure DeleteDone)
|
||||
(O.progDesc "Deletes branches from PRs that were merged or closed"))) <>
|
||||
(O.command
|
||||
"version"
|
||||
(O.info
|
||||
(pure Version)
|
||||
(O.progDesc
|
||||
"Displays version information for nixpkgs-update and dependencies"))) <>
|
||||
(O.command
|
||||
"update-vulnerability-db"
|
||||
(O.info
|
||||
(pure UpdateVulnDB)
|
||||
(O.progDesc "Updates the vulnerability database"))))
|
||||
(O.command
|
||||
"update"
|
||||
(O.info updateOptionsParser (O.progDesc "Update packages")) <>
|
||||
O.command
|
||||
"delete-done"
|
||||
(O.info
|
||||
(pure DeleteDone)
|
||||
(O.progDesc "Deletes branches from PRs that were merged or closed")) <>
|
||||
O.command
|
||||
"version"
|
||||
(O.info
|
||||
(pure Version)
|
||||
(O.progDesc
|
||||
"Displays version information for nixpkgs-update and dependencies")) <>
|
||||
O.command
|
||||
"update-vulnerability-db"
|
||||
(O.info
|
||||
(pure UpdateVulnDB)
|
||||
(O.progDesc "Updates the vulnerability database")))
|
||||
|
||||
programInfo :: O.ParserInfo Command
|
||||
programInfo =
|
||||
O.info
|
||||
(commandParser <**> O.helper)
|
||||
(O.fullDesc <> O.progDesc "Update packages in the Nixpkgs repository" <>
|
||||
(O.fullDesc <>
|
||||
O.progDesc "Update packages in the Nixpkgs repository" <>
|
||||
O.header "nixpkgs-update")
|
||||
|
||||
getGithubToken :: IO Text
|
||||
@ -81,7 +82,7 @@ main = do
|
||||
setupNixpkgs token
|
||||
setEnv "GITHUB_TOKEN" (T.unpack token) True
|
||||
deleteDone token
|
||||
Update (UpdateOptions {dry}) -> do
|
||||
Update UpdateOptions {dry} -> do
|
||||
token <- getGithubToken
|
||||
updates <- T.readFile "packages-to-update.txt"
|
||||
setupNixpkgs token
|
||||
@ -90,7 +91,7 @@ main = do
|
||||
setEnv "GC_INITIAL_HEAP_SIZE" "10g" True
|
||||
updateAll (Options dry token) updates
|
||||
Version -> do
|
||||
v <- runExceptT $ Nix.version
|
||||
v <- runExceptT Nix.version
|
||||
case v of
|
||||
Left t -> T.putStrLn ("error:" <> t)
|
||||
Right t -> T.putStrLn t
|
||||
|
Loading…
Reference in New Issue
Block a user