Skip to content

Commit 6bcec3b

Browse files
authored
Use Check Runs API to report on status checks (success and failures) (#1129)
* First pass at code. Prototype of generating checks This has a prototype to create the proper JSON format for the status check. Remaining task: Consume the output and POST the results. * Add POST capability. POST the check results back to GitHub * Update YML and shell script * Introduce error for check run * Remove error introduced for testing * remove warnings. This way, the only annotations that are displayed actually matter for the tool being run * Respond to feedback Warnings shouldn't be treated as errors.
1 parent 4ecb750 commit 6bcec3b

11 files changed

+418
-159
lines changed

.github/workflows/renumber-sections.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ on:
1414
jobs:
1515
renumber-sections:
1616
runs-on: ubuntu-latest
17+
permissions:
18+
checks: write
1719
env:
1820
DOTNET_NOLOGO: true
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1922

2023
steps:
2124
- name: Check out our repo
@@ -29,4 +32,4 @@ jobs:
2932
- name: Run section renumbering dry run
3033
run: |
3134
cd tools
32-
./run-section-renumber.sh --dryrun
35+
./run-section-renumber.sh ${{ github.event.pull_request.head.sha }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace StandardAnchorTags;
2+
internal class DiagnosticIDs
3+
{
4+
public const string TOC001 = nameof(TOC001);
5+
public const string TOC002 = nameof(TOC002);
6+
}

tools/StandardAnchorTags/GenerateGrammar.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,34 @@
22

33
namespace StandardAnchorTags;
44

5+
/// <summary>
6+
/// The data storage for the headers of the grammar file
7+
/// </summary>
8+
/// <param name="LexicalHeader">The text for the lexical section header</param>
9+
/// <param name="SyntacticHeader">The text for the syntactic section header</param>
10+
/// <param name="UnsafeExtensionsHeader">The text for the unsafe extensions header</param>
11+
/// <param name="GrammarFooter">The footer</param>
512
public record GrammarHeaders(string LexicalHeader,
613
string SyntacticHeader,
714
string UnsafeExtensionsHeader,
815
string GrammarFooter);
916

17+
/// <summary>
18+
/// This class generates a grammar file from the ANTLR blocks in the standard
19+
/// </summary>
20+
/// <remarks>
21+
/// The full grammar is in small pieces in each clause of the standard. Then,
22+
/// its duplicated in an Annex. Rather than copy and paste by hand, generate that
23+
/// Annex from the other smaller parts.
24+
/// </remarks>
1025
public class GenerateGrammar : IDisposable
1126
{
27+
/// <summary>
28+
/// Read the existing headers from a grammar file
29+
/// </summary>
30+
/// <param name="pathToStandard">Path to the standard files (likely ../standard)</param>
31+
/// <param name="grammarFile">The filename for the grammar annex</param>
32+
/// <returns>The task that will return the headers when complete.</returns>
1233
public static async Task<GrammarHeaders> ReadExistingHeaders(string pathToStandard, string grammarFile)
1334
{
1435
GrammarHeaders headers = new GrammarHeaders("", "", "", "");
@@ -50,24 +71,53 @@ public static async Task<GrammarHeaders> ReadExistingHeaders(string pathToStanda
5071
private readonly string pathToStandardFiles;
5172
private readonly StreamWriter grammarStream;
5273

74+
/// <summary>
75+
/// Construct a new grammar generator
76+
/// </summary>
77+
/// <param name="grammarPath">The path to the file</param>
78+
/// <param name="pathToStandardFiles">The path to the files in the standard</param>
79+
/// <param name="headers">The header text</param>
5380
public GenerateGrammar(string grammarPath, string pathToStandardFiles, GrammarHeaders headers)
5481
{
5582
grammarStream = new StreamWriter(Path.Combine(pathToStandardFiles, grammarPath), false);
5683
this.pathToStandardFiles = pathToStandardFiles;
5784
informativeTextBlocks = headers;
5885
}
5986

87+
/// <summary>
88+
/// Write the header text that appears before the grammar output.
89+
/// </summary>
90+
/// <returns>The task</returns>
6091
public async Task WriteHeader() => await grammarStream.WriteAsync(informativeTextBlocks.LexicalHeader);
92+
93+
/// <summary>
94+
/// Write the header text for the syntactic section
95+
/// </summary>
96+
/// <returns>The task</returns>
6197
public async Task WriteSyntaxHeader() => await grammarStream.WriteAsync(informativeTextBlocks.SyntacticHeader);
98+
99+
/// <summary>
100+
/// Write the header text for the unsafe extensions section
101+
/// </summary>
102+
/// <returns>The task</returns>
62103
public async Task WriteUnsafeExtensionHeader() => await grammarStream.WriteAsync(informativeTextBlocks.UnsafeExtensionsHeader);
63104

105+
/// <summary>
106+
/// Write the footer text that appears after the grammar output.
107+
/// </summary>
108+
/// <returns>The task</returns>
64109
public async Task WriteGrammarFooter()
65110
{
66111
await grammarStream.WriteAsync(informativeTextBlocks.GrammarFooter);
67112
await grammarStream.FlushAsync();
68113
grammarStream.Close();
69114
}
70115

116+
/// <summary>
117+
/// Extract the grammar from one file in the standard
118+
/// </summary>
119+
/// <param name="inputFileName">The input file from the standard</param>
120+
/// <returns>The task</returns>
71121
public async Task ExtractGrammarFrom(string inputFileName)
72122
{
73123
string inputFilePath = $"{pathToStandardFiles}/{inputFileName}";
@@ -106,5 +156,8 @@ public async Task ExtractGrammarFrom(string inputFileName)
106156
}
107157
}
108158

159+
/// <summary>
160+
/// Dispose of the stream
161+
/// </summary>
109162
public void Dispose() => grammarStream.Dispose();
110163
}

0 commit comments

Comments
 (0)