Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
pr-scope:
name: Set PR scope
runs-on: ubuntu-latest
needs: [ size-label ]
steps:
- uses: actions/labeler@v5
name: Set label
Expand All @@ -29,4 +30,6 @@ jobs:
"20": "M",
"50": "L",
"100": "XL"
}
}


8 changes: 5 additions & 3 deletions src/pkgchk-cli/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ type PackageCheckCommand(nuget: Tk.Nuget.INugetClient) =
|> Markdown.generate
|> String.joinLines

let summaryTitle = settings.GithubSummaryTitle

if markdown.Length < Github.maxCommentSize then
GithubComment.create settings.GithubSummaryTitle markdown
GithubComment.create summaryTitle markdown
else
trace $"Shrinking Github output as too large (attempt #{attempt + 1})..."

if attempt >= 1 then
GithubComment.create settings.GithubSummaryTitle "_The report's too big for Github - Please check logs_"
GithubComment.create summaryTitle "_The report is too big for Github - Please check logs_"
else
genComment trace (settings, [], errorHits, hitCounts, imageUri) (attempt + 1)

Expand Down Expand Up @@ -289,7 +291,7 @@ type PackageCheckCommand(nuget: Tk.Nuget.INugetClient) =
let comment = genComment trace (settings, hits, errorHits, hitCounts, reportImg) 0

trace $"Posting {comment.title} report to Github repo {repo}..."
let _ = (comment |> Github.setPrComment client repo prId).Result
let _ = (comment |> Github.setPrComment trace client repo prId).Result
$"{comment.title} report sent to Github." |> Console.italic |> console

errorHits |> returnCode
6 changes: 5 additions & 1 deletion src/pkgchk-cli/Github.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ module Github =
return []
}

let setPrComment (client: IGitHubClient) (owner, repo) prId (comment: GithubComment) =
let setPrComment trace (client: IGitHubClient) (owner, repo) prId (comment: GithubComment) =
task {

let (commentTitle, commentBody) = constructComment comment

// As there's no concret mechanism in Octokit to affinitise comments, we must use titles as the discriminator.
let! comments = getIssueComments client (owner, repo) prId

$"Found {comments |> Seq.length} comments." |> trace

let previousComment =
comments
|> Seq.filter (fun c -> c.Body.StartsWith(commentTitle, StringComparison.InvariantCulture))
Expand All @@ -80,11 +82,13 @@ module Github =
match previousComment with
| Some c ->
task {
$"Updating Github comment {c.Id}..." |> trace
let! x = client.Issue.Comment.Update(owner, repo, c.Id, commentBody)
return x
}
| None ->
task {
"Creating new Github comment..." |> trace
let! x = client.Issue.Comment.Create(owner, repo, prId, commentBody)
return x
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkgchk-cli/pkgchk-cli.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<ItemGroup>
<PackageReference Include="FSharp.Data" Version="6.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Octokit" Version="9.1.1" />
<PackageReference Include="Octokit" Version="10.0.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.48.0" />
<PackageReference Include="Tk.Nuget" Version="0.1.41" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/pkgchk-cli.tests/GithubTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module GithubTests =
GithubComment.body = "body" }

let pr = 1
let rt = pkgchk.Github.setPrComment client repo pr gc
let rt = pkgchk.Github.setPrComment ignore client repo pr gc
let r = rt.Result

commentClient.Received(1).Create(fst repo, snd repo, pr, Arg.Any<string>())
Expand All @@ -135,7 +135,7 @@ module GithubTests =
let issueClient = issueClient () |> bindComments commentClient
let client = client () |> bindIssues issueClient

let rt = pkgchk.Github.setPrComment client repo pr gc
let rt = pkgchk.Github.setPrComment ignore client repo pr gc
let r = rt.Result

commentClient
Expand Down