Skip to content

Commit 90573d0

Browse files
Added build verification workflow for all tools (#111)
* Add build workflow for .NET, upgrades, etc. * Update TypeScript code, package refs, and tests * Fixed unit tests * Remove analyzer bits * Update actions/docs-verifier/Directory.Build.props Co-authored-by: Youssef Victor <[email protected]> * Fix node workflow * fix cd command * fix run cmds Co-authored-by: Youssef Victor <[email protected]>
1 parent 0c79148 commit 90573d0

File tree

122 files changed

+15245
-12738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+15245
-12738
lines changed

.github/workflows/build-docs-verifier.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ jobs:
1010
configuration: [debug, release]
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2.3.4
13+
- uses: actions/checkout@main
1414
with:
1515
fetch-depth: 0
1616
- name: Setup .NET
17-
uses: actions/setup-dotnet@v1.7.2
17+
uses: actions/setup-dotnet@main
1818
with:
19-
dotnet-version: '6.0.x'
19+
dotnet-version: '7.0.x'
2020
- name: Try get cached dependencies
21-
uses: actions/cache@v2.1.4
21+
uses: actions/cache@main
2222
with:
2323
path: ${{ github.workspace }}/.nuget/packages
2424
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -31,7 +31,7 @@ jobs:
3131
- name: Test
3232
run: dotnet test actions/docs-verifier
3333
- name: Upload Results
34-
uses: actions/upload-artifact@v2.2.2
34+
uses: actions/upload-artifact@main
3535
with:
3636
name: ${{ matrix.os }}_${{ matrix.configuration }}
3737
path: |

.github/workflows/codeql-analysis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@main
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
46+
uses: github/codeql-action/init@main
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
57+
uses: github/codeql-action/autobuild@main
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl

.github/workflows/dogfood.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
steps:
1010
- name: Checkout the repository
11-
uses: actions/checkout@v1
11+
uses: actions/checkout@main
1212

1313
- name: Docs verifier
1414
env:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: dotnet build and test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- README.md
8+
- 'actions/status-checker/**' # Ignore the TypeScript action.
9+
pull_request:
10+
branches: [ main ]
11+
paths-ignore:
12+
- README.md
13+
- 'actions/status-checker/**' # Ignore the TypeScript action.
14+
workflow_dispatch:
15+
inputs:
16+
reason:
17+
description: The reason for running the workflow
18+
required: true
19+
default: Manual run
20+
21+
jobs:
22+
build:
23+
name: build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@main
27+
28+
- name: 'Print manual run reason'
29+
if: ${{ github.event_name == 'workflow_dispatch' }}
30+
run: |
31+
echo 'Reason: ${{ github.event.inputs.reason }}'
32+
- name: Setup .NET 7.0
33+
uses: actions/setup-dotnet@main
34+
with:
35+
dotnet-version: 7.0.x
36+
37+
- name: Restore dependencies for .NET docs tools
38+
run: |
39+
dotnet restore docs-tools.sln
40+
41+
- name: Build .NET docs tools
42+
run: |
43+
dotnet build docs-tools.sln --configuration Release --no-restore
44+
45+
test:
46+
name: test
47+
runs-on: ubuntu-latest
48+
needs: build
49+
50+
steps:
51+
- uses: actions/checkout@main
52+
53+
- name: Setup .NET 7.0
54+
uses: actions/setup-dotnet@main
55+
with:
56+
dotnet-version: 7.0.x
57+
58+
- name: Run tests
59+
run: |
60+
dotnet test docs-tools.sln --verbosity normal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: node build and test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'actions/status-checker/**' # Only run for TypeScript action updates
8+
pull_request:
9+
branches: [ main ]
10+
paths:
11+
- 'actions/status-checker/**' # Only run for TypeScript action updates
12+
13+
jobs:
14+
build:
15+
name: build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@main
19+
- name: Use Node.js 18
20+
uses: actions/setup-node@main
21+
with:
22+
node-version: 18
23+
cache: 'npm'
24+
cache-dependency-path: ./actions/status-checker/package-lock.json
25+
- run: |
26+
cd ./actions/status-checker/
27+
npm ci
28+
npm run build --if-present
29+
npm test

DotNet.DocsTools/GraphQLQueries/AddOrRemoveLabelMutation.cs

+54-55
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
using System;
33
using System.Threading.Tasks;
44

5-
namespace DotNetDocs.Tools.GraphQLQueries
5+
namespace DotNetDocs.Tools.GraphQLQueries;
6+
7+
/// <summary>
8+
/// Add or remove a label.
9+
/// </summary>
10+
/// <remarks>
11+
/// This class performs a mutation to remove or
12+
/// add a label to a "labelable" node.
13+
/// </remarks>
14+
public class AddOrRemoveLabelMutation
615
{
7-
/// <summary>
8-
/// Add or remove a label.
9-
/// </summary>
10-
/// <remarks>
11-
/// This class performs a mutation to remove or
12-
/// add a label to a "labelable" node.
13-
/// </remarks>
14-
public class AddOrRemoveLabelMutation
15-
{
16-
private static readonly string removeLabelMutationText =
16+
private static readonly string removeLabelMutationText =
1717
@"mutation RemoveLabels($nodeID: ID!, $labelIDs: [ID!]!) {
1818
removeLabelsFromLabelable(input: {
1919
labelableId:$nodeID
@@ -28,7 +28,7 @@ public class AddOrRemoveLabelMutation
2828
}
2929
";
3030

31-
private static readonly string addLabelMutationText =
31+
private static readonly string addLabelMutationText =
3232
@"mutation AddLabels($nodeID: ID!, $labelIDs: [ID!]!) {
3333
addLabelsToLabelable(input: {
3434
labelableId:$nodeID
@@ -42,52 +42,51 @@ public class AddOrRemoveLabelMutation
4242
}
4343
}
4444
";
45-
private readonly IGitHubClient client;
46-
private readonly string nodeId;
47-
private readonly string labelId;
48-
private readonly bool addLabel;
45+
private readonly IGitHubClient client;
46+
private readonly string nodeId;
47+
private readonly string labelId;
48+
private readonly bool addLabel;
4949

50-
/// <summary>
51-
/// Construct the query object.
52-
/// </summary>
53-
/// <param name="client">The client.</param>
54-
/// <param name="nodeId">The node to modify</param>
55-
/// <param name="labelId">The id of the label to add or remove</param>
56-
/// <param name="add">True to add, false to remove.</param>
57-
public AddOrRemoveLabelMutation(IGitHubClient client, string nodeId, string labelId, bool add)
58-
{
59-
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
60-
this.nodeId = !string.IsNullOrWhiteSpace(nodeId)
61-
? nodeId
62-
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(nodeId));
63-
this.labelId = !string.IsNullOrWhiteSpace(labelId)
64-
? labelId
65-
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(labelId));
66-
this.addLabel = add;
67-
}
50+
/// <summary>
51+
/// Construct the query object.
52+
/// </summary>
53+
/// <param name="client">The client.</param>
54+
/// <param name="nodeId">The node to modify</param>
55+
/// <param name="labelId">The id of the label to add or remove</param>
56+
/// <param name="add">True to add, false to remove.</param>
57+
public AddOrRemoveLabelMutation(IGitHubClient client, string nodeId, string labelId, bool add)
58+
{
59+
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
60+
this.nodeId = !string.IsNullOrWhiteSpace(nodeId)
61+
? nodeId
62+
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(nodeId));
63+
this.labelId = !string.IsNullOrWhiteSpace(labelId)
64+
? labelId
65+
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(labelId));
66+
this.addLabel = add;
67+
}
6868

69-
/// <summary>
70-
/// Perform the mutation.
71-
/// </summary>
72-
/// <returns>A task to be awaited.</returns>
73-
/// <remarks>
74-
/// I haven't see failures from the GitHub endpoint reflected
75-
/// in the result packet. However, on rare occasions, the
76-
/// mutation fails. This should be updated once I see why it fails.
77-
/// </remarks>
78-
public async Task PerformMutation()
69+
/// <summary>
70+
/// Perform the mutation.
71+
/// </summary>
72+
/// <returns>A task to be awaited.</returns>
73+
/// <remarks>
74+
/// I haven't see failures from the GitHub endpoint reflected
75+
/// in the result packet. However, on rare occasions, the
76+
/// mutation fails. This should be updated once I see why it fails.
77+
/// </remarks>
78+
public async Task PerformMutation()
79+
{
80+
var labelPacket = new GraphQLPacket
7981
{
80-
var labelPacket = new GraphQLPacket
82+
query = addLabel ? addLabelMutationText : removeLabelMutationText,
83+
variables =
8184
{
82-
query = addLabel ? addLabelMutationText : removeLabelMutationText,
83-
variables =
84-
{
85-
["nodeID"] = nodeId,
86-
["labelIDs"] = labelId
87-
}
88-
};
89-
var jsonData = await client.PostGraphQLRequestAsync(labelPacket);
90-
// TODO: check for errors
91-
}
85+
["nodeID"] = nodeId,
86+
["labelIDs"] = labelId
87+
}
88+
};
89+
var jsonData = await client.PostGraphQLRequestAsync(labelPacket);
90+
// TODO: check for errors
9291
}
9392
}
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,58 @@
11
using DotNetDocs.Tools.GitHubCommunications;
22

3-
namespace DotNetDocs.Tools.GraphQLQueries
3+
namespace DotNetDocs.Tools.GraphQLQueries;
4+
5+
/// <summary>
6+
/// Retrieve the count of open issues based on labels
7+
/// </summary>
8+
/// <remarks>
9+
/// This query returns the number of matching open issues. You can specify
10+
/// either issues with certain labels, or issues without certain labels,
11+
/// or a mix.
12+
/// </remarks>
13+
public class LabeledIssueCounts
414
{
5-
/// <summary>
6-
/// Retrieve the count of open issues based on labels
7-
/// </summary>
8-
/// <remarks>
9-
/// This query returns the number of matching open issues. You can specify
10-
/// either issues with certain labels, or issues without certain labels,
11-
/// or a mix.
12-
/// </remarks>
13-
public class LabeledIssueCounts
14-
{
15-
private const string AreaIssuesCount =
15+
private const string AreaIssuesCount =
1616
@"query ($search_value: String!) {
1717
search(query: $search_value, type: ISSUE) {
1818
issueCount
1919
}
2020
}
2121
";
22-
private readonly IGitHubClient client;
23-
private readonly string search_value;
22+
private readonly IGitHubClient client;
23+
private readonly string search_value;
2424

25-
/// <summary>
26-
/// Constructor
27-
/// </summary>
28-
/// <param name="client">The GitHub client.</param>
29-
/// <param name="owner">The owner of the repository</param>
30-
/// <param name="repository">The repository name</param>
31-
/// <param name="labelFilter">The GraphQL string for filtering</param>
32-
public LabeledIssueCounts(IGitHubClient client, string owner, string repository, string labelFilter)
33-
{
34-
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
35-
if (string.IsNullOrWhiteSpace(owner))
36-
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(owner));
37-
if (string.IsNullOrWhiteSpace(repository))
38-
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(repository));
39-
search_value = $"repo:{owner}/{repository} is:issue is:open " + labelFilter;
40-
//Console.WriteLine(search_value);
41-
}
25+
/// <summary>
26+
/// Constructor
27+
/// </summary>
28+
/// <param name="client">The GitHub client.</param>
29+
/// <param name="owner">The owner of the repository</param>
30+
/// <param name="repository">The repository name</param>
31+
/// <param name="labelFilter">The GraphQL string for filtering</param>
32+
public LabeledIssueCounts(IGitHubClient client, string owner, string repository, string labelFilter)
33+
{
34+
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
35+
if (string.IsNullOrWhiteSpace(owner))
36+
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(owner));
37+
if (string.IsNullOrWhiteSpace(repository))
38+
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(repository));
39+
search_value = $"repo:{owner}/{repository} is:issue is:open " + labelFilter;
40+
//Console.WriteLine(search_value);
41+
}
4242

43-
/// <summary>
44-
/// Perform the query for the issue count
45-
/// </summary>
46-
/// <returns>The number of open issues matching this query.</returns>
47-
public async Task<int> PerformQueryAsync()
43+
/// <summary>
44+
/// Perform the query for the issue count
45+
/// </summary>
46+
/// <returns>The number of open issues matching this query.</returns>
47+
public async Task<int> PerformQueryAsync()
48+
{
49+
var queryText = new GraphQLPacket
4850
{
49-
var queryText = new GraphQLPacket
50-
{
51-
query = AreaIssuesCount
52-
};
53-
queryText.variables["search_value"] = search_value;
51+
query = AreaIssuesCount
52+
};
53+
queryText.variables["search_value"] = search_value;
5454

55-
var results = await client.PostGraphQLRequestAsync(queryText);
56-
return results.Descendent("search", "issueCount").GetInt32();
57-
}
55+
var results = await client.PostGraphQLRequestAsync(queryText);
56+
return results.Descendent("search", "issueCount").GetInt32();
5857
}
5958
}

DotnetDocsToolsTests/DotnetDocsTools.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221221-03" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
1212
<PackageReference Include="xunit" Version="2.4.2" />
1313
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1414
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)