Link to meta.changelog in PR description

We now have the bot:

1. Doing the automated upgrade (bump version, src, recomputing hash)
2. Doing a full nixpkgs-review reverse closure rebuild

The next step for a human is to review the upstream changelog. Right now they
have to find it manually, but if `meta.changelog` is set, this commit adds a
link to it directly in the PR description .

Resolves #44
This commit is contained in:
Benjamin Hipple 2020-05-10 19:58:57 -04:00
parent ad876f8e7c
commit ebee2aa0d4
5 changed files with 35 additions and 7 deletions

View File

@ -10,6 +10,7 @@ module Nix
build,
cachix,
getAttr,
getChangelog,
getDerivationFile,
getDescription,
getDrvAttr,
@ -197,6 +198,16 @@ getIsBroken attrPath =
& readNixBool
& overwriteErrorT ("Could not get meta.broken for attrpath " <> attrPath)
getChangelog :: MonadIO m => Text -> ExceptT Text m Text
getChangelog attrPath =
nixEvalET
(EvalOptions NoRaw (Env []))
( "(let pkgs = import ./. {}; in pkgs."
<> attrPath
<> ".meta.changelog or \"\")"
)
& overwriteErrorT ("Could not get meta.changelog for attrpath " <> attrPath)
getDescription :: MonadIO m => Text -> ExceptT Text m Text
getDescription attrPath =
nixEvalET

View File

@ -295,6 +295,7 @@ publishPackage log updateEnv oldSrcUrl newSrcUrl attrPath result opDiff rewriteM
Left msg -> pure msg
metaDescription <- Nix.getDescription attrPath <|> return T.empty
metaHomepage <- Nix.getHomepageET attrPath <|> return T.empty
metaChangelog <- Nix.getChangelog attrPath <|> return T.empty
cveRep <- liftIO $ cveReport updateEnv
releaseUrl <- GH.releaseUrl updateEnv newSrcUrl <|> return ""
compareUrl <- GH.compareUrl oldSrcUrl newSrcUrl <|> return ""
@ -320,6 +321,7 @@ publishPackage log updateEnv oldSrcUrl newSrcUrl attrPath result opDiff rewriteM
isBroken
metaDescription
metaHomepage
metaChangelog
rewriteMsgs
releaseUrl
compareUrl
@ -354,6 +356,7 @@ prMessage ::
Bool ->
Text ->
Text ->
Text ->
[Text] ->
Text ->
Text ->
@ -367,7 +370,7 @@ prMessage ::
Text ->
Text ->
Text
prMessage updateEnv isBroken metaDescription metaHomepage rewriteMsgs releaseUrl compareUrl resultCheckReport commitHash attrPath maintainers resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg =
prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog rewriteMsgs releaseUrl compareUrl resultCheckReport commitHash attrPath maintainers resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg =
-- Some components of the PR description are pre-generated prior to calling
-- because they require IO, but in general try to put as much as possible for
-- the formatting into the pure function so that we can control the body
@ -376,11 +379,15 @@ prMessage updateEnv isBroken metaDescription metaHomepage rewriteMsgs releaseUrl
metaHomepageLine =
if metaHomepage == T.empty
then ""
else "\nmeta.homepage for " <> attrPath <> " is: " <> metaHomepage
else "meta.homepage for " <> attrPath <> " is: " <> metaHomepage
metaDescriptionLine =
if metaDescription == T.empty
then ""
else "\n\nmeta.description for " <> attrPath <> " is: " <> metaDescription
else "meta.description for " <> attrPath <> " is: " <> metaDescription
metaChangelogLine =
if metaDescription == T.empty
then ""
else "meta.changelog for " <> attrPath <> " is: " <> metaChangelog
rewriteMsgsLine = foldl (\ms m -> ms <> T.pack "\n- " <> m) "\n###### Updates performed" rewriteMsgs
maintainersCc =
if not (T.null maintainers)
@ -412,8 +419,13 @@ prMessage updateEnv isBroken metaDescription metaHomepage rewriteMsgs releaseUrl
in [interpolate|
Semi-automatic update generated by [nixpkgs-update](https://github.com/ryantm/nixpkgs-update) tools. $sourceLinkInfo
$brokenMsg
$metaDescriptionLine
$metaHomepageLine
$metaChangelogLine
$rewriteMsgsLine
###### To inspect upstream changes

View File

@ -23,6 +23,7 @@ spec = do
let isBroken = False
let metaDescription = "\"Foobar package description\""
let metaHomepage = "\"https://foobar-homepage.com\""
let metaChangelog = "\"https://foobar-homepage.com/changelog/v1.2.3\""
let rewriteMsgs = ["Version Update", "Other Update"]
let releaseUrl = "https://github.com/foobar/releases"
let compareUrl = "https://github.com/foobar/compare"
@ -38,13 +39,13 @@ spec = do
it "matches a simple mock example" do
expected <- T.readFile "test_data/expected_pr_description_1.md"
let actual = Update.prMessage updateEnv isBroken metaDescription metaHomepage rewriteMsgs releaseUrl compareUrl resultCheckReport commitHash attrPath maintainersCc resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg
let actual = Update.prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog rewriteMsgs releaseUrl compareUrl resultCheckReport commitHash attrPath maintainersCc resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg
T.writeFile "test_data/actual_pr_description_1.md" actual
actual `shouldBe` expected
it "does not include NixPkgs review section when no review was done" do
expected <- T.readFile "test_data/expected_pr_description_2.md"
let nixpkgsReviewMsg' = ""
let actual = Update.prMessage updateEnv isBroken metaDescription metaHomepage rewriteMsgs releaseUrl compareUrl resultCheckReport commitHash attrPath maintainersCc resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg'
let actual = Update.prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog rewriteMsgs releaseUrl compareUrl resultCheckReport commitHash attrPath maintainersCc resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg'
T.writeFile "test_data/actual_pr_description_2.md" actual
actual `shouldBe` expected

View File

@ -1,11 +1,13 @@
Semi-automatic update generated by [nixpkgs-update](https://github.com/ryantm/nixpkgs-update) tools. This update was made based on information from https://update-site.com.
meta.description for foobar is: "Foobar package description"
meta.homepage for foobar is: "https://foobar-homepage.com"
meta.changelog for foobar is: "https://foobar-homepage.com/changelog/v1.2.3"
###### Updates performed
- Version Update
- Other Update

View File

@ -1,11 +1,13 @@
Semi-automatic update generated by [nixpkgs-update](https://github.com/ryantm/nixpkgs-update) tools. This update was made based on information from https://update-site.com.
meta.description for foobar is: "Foobar package description"
meta.homepage for foobar is: "https://foobar-homepage.com"
meta.changelog for foobar is: "https://foobar-homepage.com/changelog/v1.2.3"
###### Updates performed
- Version Update
- Other Update