-
Notifications
You must be signed in to change notification settings - Fork 89
Separate tasks in our workflows #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BillWagner
wants to merge
6
commits into
draft-v8
Choose a base branch
from
chain-tasks
base: draft-v8
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dfcbbbe
initial code
BillWagner 6389fb2
next try
BillWagner 1518858
ooops
BillWagner 9b9881d
Apply suggestions from code review
BillWagner d7a2bd8
compiler issue
BillWagner 16c717c
Update .github/workflows/renumber-sections.yaml
BillWagner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Report status | ||
|
||
# Triggers the workflow when a workflow that generates status completes | ||
on: | ||
workflow_run: | ||
workflows: ["Renumber standard TOC"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
report-status: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
checks: write | ||
pull-requests: write | ||
steps: | ||
- uses: LouisBrunner/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
sha: ${{ inputs.head_sha }} | ||
name: ${{ inputs.check_name }} | ||
conclusion: ${{ inputs.conclusion}} | ||
# output.summary is required with actions! | ||
output: | | ||
{"summary":"${{inputs.summary}}"} | ||
annotations: ${{ inputs.annotations }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
using Octokit; | ||
|
||
namespace Utilities; | ||
|
||
// This defines the custom serializer for the annotations block. | ||
// That enables the status checks to write the annotations to | ||
// the GitHub Actions output. That lets a subsequent action read | ||
// these annotations in a different security context and write | ||
// them to the PR. | ||
[JsonSerializable(typeof(IList<NewCheckRunAnnotation>))] | ||
public sealed partial class JsonCheckRunAnnotationSerializerContext : JsonSerializerContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
using Octokit; | ||
using Actions.Core.Extensions; | ||
using Actions.Core.Services; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Utilities; | ||
|
||
|
@@ -24,6 +27,17 @@ public record StatusCheckMessage(string file, int StartLine, int EndLine, string | |
/// <param name="toolName">The name of the tool that is running the check</param> | ||
public class StatusCheckLogger(string pathToRoot, string toolName) | ||
{ | ||
private Lazy<ICoreService> _gitHubCoreService = new(() => InitializeCoreService()); | ||
|
||
private static ICoreService InitializeCoreService() | ||
{ | ||
using var provider = new ServiceCollection() | ||
.AddGitHubActionsCore() | ||
.BuildServiceProvider(); | ||
|
||
return provider.GetRequiredService<ICoreService>(); | ||
} | ||
|
||
private List<NewCheckRunAnnotation> annotations = []; | ||
public bool Success { get; private set; } = true; | ||
|
||
|
@@ -153,13 +167,17 @@ public void ExitOnFailure(StatusCheckMessage d) | |
/// <param name="repo">The GitHub repo name</param> | ||
/// <param name="sha">The head sha when running as a GitHub action</param> | ||
/// <returns>The full check run result object</returns> | ||
public async Task BuildCheckRunResult(string token, string owner, string repo, string sha) | ||
public async Task<IList<NewCheckRunAnnotation>> BuildCheckRunResult(string token, string owner, string repo, string sha) | ||
{ | ||
|
||
var title = $"{toolName} Check Run results"; | ||
var summary = $"{toolName} result is {(Success ? "success" : "failure")} with {annotations.Count} diagnostics."; | ||
|
||
NewCheckRun result = new(toolName, sha) | ||
{ | ||
Status = CheckStatus.Completed, | ||
Conclusion = Success ? CheckConclusion.Success : CheckConclusion.Failure, | ||
Output = new($"{toolName} Check Run results", $"{toolName} result is {(Success ? "success" : "failure")} with {annotations.Count} diagnostics.") | ||
Output = new(title, summary) | ||
{ | ||
Annotations = annotations | ||
} | ||
|
@@ -182,5 +200,43 @@ public async Task BuildCheckRunResult(string token, string owner, string repo, s | |
Console.WriteLine("Exception details:"); | ||
Console.WriteLine(e); | ||
} | ||
try | ||
{ | ||
var core = _gitHubCoreService.Value; | ||
|
||
await core.GroupAsync("Writing run outputs", async () => | ||
{ | ||
await core.SetOutputAsync("check_name", title, JsonCheckRunAnnotationSerializerContext.Default.String); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe group these into pairs of lines (so remove the blank line between the two check_name-related lines, and then between the two conclusion-related lines, etc.) |
||
core.WriteInfo("Set check_name output"); | ||
|
||
await core.SetOutputAsync("conclusion", Success ? "success" : "failure", JsonCheckRunAnnotationSerializerContext.Default.String); | ||
|
||
core.WriteInfo("Set conclusion output"); | ||
|
||
await core.SetOutputAsync("summary", summary, JsonCheckRunAnnotationSerializerContext.Default.String); | ||
|
||
core.WriteInfo("Set summary output"); | ||
|
||
await core.SetOutputAsync("head_sha", sha, JsonCheckRunAnnotationSerializerContext.Default.String); | ||
|
||
core.WriteInfo("Set head_sha output"); | ||
|
||
await core.SetOutputAsync("annotations", annotations, JsonCheckRunAnnotationSerializerContext.Default.IListNewCheckRunAnnotation); | ||
|
||
core.WriteInfo("Set annotations output"); | ||
return true; // to get a natural lambda type. | ||
}); | ||
// Now, we have a file named annotations. | ||
} | ||
// If the token does not have the correct permissions, we will get a 403 | ||
// Once running on a branch on the dotnet org, this should work correctly. | ||
catch (ForbiddenException e) | ||
{ | ||
Console.WriteLine("===== WARNING: Could not create a check run.====="); | ||
Console.WriteLine("Exception details:"); | ||
Console.WriteLine(e); | ||
} | ||
return annotations; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change, as it appears to be unused? (Or emit the annotations somewhere?)