Skip to content
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

Added build verification workflow for all tools #111

Merged
merged 8 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 5 additions & 5 deletions .github/workflows/build-docs-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
configuration: [debug, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@main
with:
dotnet-version: '6.0.x'
dotnet-version: '7.0.x'
- name: Try get cached dependencies
uses: actions/cache@v2.1.4
uses: actions/cache@main
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Test
run: dotnet test actions/docs-verifier
- name: Upload Results
uses: actions/upload-artifact@v2.2.2
uses: actions/upload-artifact@main
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@main

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

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dogfood.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v1
uses: actions/checkout@main

- name: Docs verifier
env:
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/dotnet-build-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: dotnet build and test

on:
push:
branches: [ main ]
paths-ignore:
- README.md
- 'actions/status-checker/**' # Ignore the TypeScript action.
pull_request:
branches: [ main ]
paths-ignore:
- README.md
- 'actions/status-checker/**' # Ignore the TypeScript action.
workflow_dispatch:
inputs:
reason:
description: The reason for running the workflow
required: true
default: Manual run

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main

- name: 'Print manual run reason'
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET 7.0
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x

- name: Restore dependencies for .NET docs tools
run: |
dotnet restore docs-tools.sln

- name: Build .NET docs tools
run: |
dotnet build docs-tools.sln --configuration Release --no-restore

test:
name: test
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@main

- name: Setup .NET 7.0
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x

- name: Run tests
run: |
dotnet test docs-tools.sln --verbosity normal
29 changes: 29 additions & 0 deletions .github/workflows/node-build-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: node build and test

on:
push:
branches: [ main ]
paths:
- 'actions/status-checker/**' # Only run for TypeScript action updates
pull_request:
branches: [ main ]
paths:
- 'actions/status-checker/**' # Only run for TypeScript action updates

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main

- uses: actions/checkout@main
- name: Use Node.js 18
uses: actions/setup-node@main
with:
node-version: 18
cache: 'npm'
- run: cd cd ./actions/status-checker/
- run: npm ci
- run: npm run build --if-present
- run: npm test
109 changes: 54 additions & 55 deletions DotNet.DocsTools/GraphQLQueries/AddOrRemoveLabelMutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
using System;
using System.Threading.Tasks;

namespace DotNetDocs.Tools.GraphQLQueries
namespace DotNetDocs.Tools.GraphQLQueries;
IEvangelist marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Add or remove a label.
/// </summary>
/// <remarks>
/// This class performs a mutation to remove or
/// add a label to a "labelable" node.
/// </remarks>
public class AddOrRemoveLabelMutation
{
/// <summary>
/// Add or remove a label.
/// </summary>
/// <remarks>
/// This class performs a mutation to remove or
/// add a label to a "labelable" node.
/// </remarks>
public class AddOrRemoveLabelMutation
{
private static readonly string removeLabelMutationText =
private static readonly string removeLabelMutationText =
@"mutation RemoveLabels($nodeID: ID!, $labelIDs: [ID!]!) {
removeLabelsFromLabelable(input: {
labelableId:$nodeID
Expand All @@ -28,7 +28,7 @@ public class AddOrRemoveLabelMutation
}
";

private static readonly string addLabelMutationText =
private static readonly string addLabelMutationText =
@"mutation AddLabels($nodeID: ID!, $labelIDs: [ID!]!) {
addLabelsToLabelable(input: {
labelableId:$nodeID
Expand All @@ -42,52 +42,51 @@ public class AddOrRemoveLabelMutation
}
}
";
private readonly IGitHubClient client;
private readonly string nodeId;
private readonly string labelId;
private readonly bool addLabel;
private readonly IGitHubClient client;
private readonly string nodeId;
private readonly string labelId;
private readonly bool addLabel;

/// <summary>
/// Construct the query object.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="nodeId">The node to modify</param>
/// <param name="labelId">The id of the label to add or remove</param>
/// <param name="add">True to add, false to remove.</param>
public AddOrRemoveLabelMutation(IGitHubClient client, string nodeId, string labelId, bool add)
{
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
this.nodeId = !string.IsNullOrWhiteSpace(nodeId)
? nodeId
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(nodeId));
this.labelId = !string.IsNullOrWhiteSpace(labelId)
? labelId
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(labelId));
this.addLabel = add;
}
/// <summary>
/// Construct the query object.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="nodeId">The node to modify</param>
/// <param name="labelId">The id of the label to add or remove</param>
/// <param name="add">True to add, false to remove.</param>
public AddOrRemoveLabelMutation(IGitHubClient client, string nodeId, string labelId, bool add)
{
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
this.nodeId = !string.IsNullOrWhiteSpace(nodeId)
? nodeId
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(nodeId));
this.labelId = !string.IsNullOrWhiteSpace(labelId)
? labelId
: throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(labelId));
this.addLabel = add;
}

/// <summary>
/// Perform the mutation.
/// </summary>
/// <returns>A task to be awaited.</returns>
/// <remarks>
/// I haven't see failures from the GitHub endpoint reflected
/// in the result packet. However, on rare occasions, the
/// mutation fails. This should be updated once I see why it fails.
/// </remarks>
public async Task PerformMutation()
/// <summary>
/// Perform the mutation.
/// </summary>
/// <returns>A task to be awaited.</returns>
/// <remarks>
/// I haven't see failures from the GitHub endpoint reflected
/// in the result packet. However, on rare occasions, the
/// mutation fails. This should be updated once I see why it fails.
/// </remarks>
public async Task PerformMutation()
{
var labelPacket = new GraphQLPacket
{
var labelPacket = new GraphQLPacket
query = addLabel ? addLabelMutationText : removeLabelMutationText,
variables =
{
query = addLabel ? addLabelMutationText : removeLabelMutationText,
variables =
{
["nodeID"] = nodeId,
["labelIDs"] = labelId
}
};
var jsonData = await client.PostGraphQLRequestAsync(labelPacket);
// TODO: check for errors
}
["nodeID"] = nodeId,
["labelIDs"] = labelId
}
};
var jsonData = await client.PostGraphQLRequestAsync(labelPacket);
// TODO: check for errors
}
}
87 changes: 43 additions & 44 deletions DotNet.DocsTools/GraphQLQueries/LabeledIssueCounts.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,58 @@
using DotNetDocs.Tools.GitHubCommunications;

namespace DotNetDocs.Tools.GraphQLQueries
namespace DotNetDocs.Tools.GraphQLQueries;

/// <summary>
/// Retrieve the count of open issues based on labels
/// </summary>
/// <remarks>
/// This query returns the number of matching open issues. You can specify
/// either issues with certain labels, or issues without certain labels,
/// or a mix.
/// </remarks>
public class LabeledIssueCounts
{
/// <summary>
/// Retrieve the count of open issues based on labels
/// </summary>
/// <remarks>
/// This query returns the number of matching open issues. You can specify
/// either issues with certain labels, or issues without certain labels,
/// or a mix.
/// </remarks>
public class LabeledIssueCounts
{
private const string AreaIssuesCount =
private const string AreaIssuesCount =
@"query ($search_value: String!) {
search(query: $search_value, type: ISSUE) {
issueCount
}
}
";
private readonly IGitHubClient client;
private readonly string search_value;
private readonly IGitHubClient client;
private readonly string search_value;

/// <summary>
/// Constructor
/// </summary>
/// <param name="client">The GitHub client.</param>
/// <param name="owner">The owner of the repository</param>
/// <param name="repository">The repository name</param>
/// <param name="labelFilter">The GraphQL string for filtering</param>
public LabeledIssueCounts(IGitHubClient client, string owner, string repository, string labelFilter)
{
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
if (string.IsNullOrWhiteSpace(owner))
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(owner));
if (string.IsNullOrWhiteSpace(repository))
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(repository));
search_value = $"repo:{owner}/{repository} is:issue is:open " + labelFilter;
//Console.WriteLine(search_value);
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="client">The GitHub client.</param>
/// <param name="owner">The owner of the repository</param>
/// <param name="repository">The repository name</param>
/// <param name="labelFilter">The GraphQL string for filtering</param>
public LabeledIssueCounts(IGitHubClient client, string owner, string repository, string labelFilter)
{
this.client = client ?? throw new ArgumentNullException(paramName: nameof(client), message: "Cannot be null");
if (string.IsNullOrWhiteSpace(owner))
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(owner));
if (string.IsNullOrWhiteSpace(repository))
throw new ArgumentException(message: "Must not be whitespace", paramName: nameof(repository));
search_value = $"repo:{owner}/{repository} is:issue is:open " + labelFilter;
//Console.WriteLine(search_value);
}

/// <summary>
/// Perform the query for the issue count
/// </summary>
/// <returns>The number of open issues matching this query.</returns>
public async Task<int> PerformQueryAsync()
/// <summary>
/// Perform the query for the issue count
/// </summary>
/// <returns>The number of open issues matching this query.</returns>
public async Task<int> PerformQueryAsync()
{
var queryText = new GraphQLPacket
{
var queryText = new GraphQLPacket
{
query = AreaIssuesCount
};
queryText.variables["search_value"] = search_value;
query = AreaIssuesCount
};
queryText.variables["search_value"] = search_value;

var results = await client.PostGraphQLRequestAsync(queryText);
return results.Descendent("search", "issueCount").GetInt32();
}
var results = await client.PostGraphQLRequestAsync(queryText);
return results.Descendent("search", "issueCount").GetInt32();
}
}
2 changes: 1 addition & 1 deletion DotnetDocsToolsTests/DotnetDocsTools.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221221-03" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading