Skip to content

Add codecoverage, CodeQL analysis, dotnet-format #89

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

Merged
merged 18 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 42 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,45 @@ jobs:
run: dotnet build --no-restore -c Debug
- name: Test solution [Debug]
working-directory: src
run: dotnet test --no-restore
run: dotnet test --no-restore -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:Include=[GraphQL-Parser]* -p:CoverletOutput=../../${{ matrix.os }}.lcov.info
- name: Convert coverage report to clover format
uses: danielpalme/[email protected]
with:
reports: '${{ matrix.os }}.lcov.info'
targetdir: '.'
reporttypes: 'Clover'
tag: '${{ github.run_number }}_${{ github.run_id }}'
- name: Monitor coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: slavcodev/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clover_file: "Clover.xml"
threshold_alert: 80
threshold_warning: 90
# https://github.com/marketplace/actions/coveralls-github-action
- name: Upload coverage to Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ matrix.os }}.lcov.info
parallel: true
flag-name: ${{ matrix.os }}
- name: Upload coverage to Codecov
if: ${{ 0 == 1 }}
uses: codecov/codecov-action@v1
with:
file: ${{ matrix.os }}.lcov.info
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# GraphQL Dotnet Parser
[![AppVeyor](https://img.shields.io/appveyor/ci/graphql-dotnet-ci/parser.svg)](https://ci.appveyor.com/project/graphql-dotnet-ci/parser)
[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=master)](https://coveralls.io/github/graphql-dotnet/parser?branch=master)

[![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser)
[![MyGet Pre Release](https://img.shields.io/myget/graphql-dotnet/vpre/GraphQL-Parser?label=myget)](https://www.myget.org/F/graphql-dotnet/api/v3/index.json)
[![Nuget](https://img.shields.io/nuget/dt/GraphQL-Parser)](https://www.nuget.org/packages/GraphQL-Parser)

![Activity](https://img.shields.io/github/commit-activity/w/graphql-dotnet/parser)
Expand All @@ -11,10 +9,15 @@

![Size](https://img.shields.io/github/repo-size/graphql-dotnet/parser)

[![Build status](https://github.com/graphql-dotnet/parser/workflows/Publish%20preview%20to%20GitHub%20registry/badge.svg)](https://github.com/graphql-dotnet/parser/actions)
[![Build status](https://github.com/graphql-dotnet/parser/workflows/Publish%20release%20to%20Nuget%20registry/badge.svg)](https://github.com/graphql-dotnet/parser/actions)

This library contains a lexer and parser classes as well as the complete GraphQL AST model.

The parser from this library is used in [GraphQL for .NET](https://github.com/graphql-dotnet/graphql-dotnet).

Preview versions of this package are available on [GitHub Packages](https://github.com/orgs/graphql-dotnet/packages?repo_name=parser).

## Lexer
Generates token based on input text.
### Usage
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<VersionPrefix>5.3.5-preview</VersionPrefix>
<VersionPrefix>5.3.4-preview</VersionPrefix>
<LangVersion>latest</LangVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -17,6 +17,7 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables -->
<!-- https://github.com/clairernovotny/DeterministicBuilds -->
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>
<NoWarn>$(NoWarn);1591</NoWarn>
<Nullable>enable</Nullable>
Expand Down
23 changes: 23 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- This target must be imported into Directory.Build.targets -->
<!-- Workaround. Remove once we're on 3.1.300+
https://github.com/dotnet/sourcelink/issues/572 -->
<Project>
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>
<ItemGroup>
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
</ItemGroup>
<ItemGroup>
<SourceRoot Include="$(NuGetPackageRoot)" />
</ItemGroup>

<Target Name="CoverletGetPathMap"
DependsOnTargets="InitializeSourceRootMappedPaths"
Returns="@(_LocalTopLevelSourceRoot)"
Condition="'$(DeterministicSourcePaths)' == 'true'">
<ItemGroup>
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
</ItemGroup>
</Target>
</Project>
4 changes: 4 additions & 0 deletions src/GraphQLParser.Tests/GraphQLParser.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Shouldly" Version="4.0.0-beta0004" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
1 change: 1 addition & 0 deletions src/GraphQLParser.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
..\.gitignore = ..\.gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
..\LICENSE.md = ..\LICENSE.md
..\assets\logo.64x64.png = ..\assets\logo.64x64.png
NuGet.config = NuGet.config
Expand Down
16 changes: 8 additions & 8 deletions src/GraphQLParser/LexerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,13 @@ private void ValidateCharacterCode(int code)
}
}

private int WaitForEndOfComment(string body, int position, char code)
{
while (++position < body.Length && (code = body[position]) != 0 && (code > 0x001F || code == 0x0009) && code != 0x000A && code != 0x000D)
{
}

return position;
}
//private int WaitForEndOfComment(string body, int position, char code)
//{
// while (++position < body.Length && (code = body[position]) != 0 && (code > 0x001F || code == 0x0009) && code != 0x000A && code != 0x000D)
// {
// }

// return position;
//}
}
}
16 changes: 8 additions & 8 deletions src/GraphQLParser/ParserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ private GraphQLFieldSelection ParseFieldSelection()
return CreateFieldSelection(start, name, alias, comment);
}

private GraphQLValue ParseFloat(bool isConstant)
private GraphQLValue ParseFloat(/*bool isConstant*/)
{
var token = _currentToken;
Advance();
Expand Down Expand Up @@ -631,7 +631,7 @@ private GraphQLInputValueDefinition ParseInputValueDef()
};
}

private GraphQLValue ParseInt(bool isConstant)
private GraphQLValue ParseInt(/*bool isConstant*/)
{
var token = _currentToken;
Advance();
Expand Down Expand Up @@ -719,7 +719,7 @@ private GraphQLNamedType ParseNamedType()
};
}

private GraphQLValue ParseNameValue(bool isConstant)
private GraphQLValue ParseNameValue(/*bool isConstant*/)
{
var token = _currentToken;

Expand Down Expand Up @@ -891,7 +891,7 @@ private GraphQLSelectionSet ParseSelectionSet()
};
}

private GraphQLValue ParseString(bool isConstant)
private GraphQLValue ParseString(/*bool isConstant*/)
{
var token = _currentToken;
Advance();
Expand Down Expand Up @@ -987,10 +987,10 @@ private GraphQLUnionTypeDefinition ParseUnionTypeDefinition()
{
TokenKind.BRACKET_L => ParseList(isConstant),
TokenKind.BRACE_L => ParseObject(isConstant),
TokenKind.INT => ParseInt(isConstant),
TokenKind.FLOAT => ParseFloat(isConstant),
TokenKind.STRING => ParseString(isConstant),
TokenKind.NAME => ParseNameValue(isConstant),
TokenKind.INT => ParseInt(/*isConstant*/),
TokenKind.FLOAT => ParseFloat(/*isConstant*/),
TokenKind.STRING => ParseString(/*isConstant*/),
TokenKind.NAME => ParseNameValue(/*isConstant*/),
TokenKind.DOLLAR when !isConstant => ParseVariable(),
_ => throw new GraphQLSyntaxErrorException($"Unexpected {_currentToken}", _source, _currentToken.Start)
};
Expand Down