Skip to content

Commit 5be04b5

Browse files
committed
Add code coverage
1 parent 928ca93 commit 5be04b5

File tree

8 files changed

+94
-21
lines changed

8 files changed

+94
-21
lines changed

.github/workflows/test.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,45 @@ jobs:
3737
run: dotnet build --no-restore -c Debug
3838
- name: Test solution [Debug]
3939
working-directory: src
40-
run: dotnet test --no-restore
40+
run: dotnet test --no-restore -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:Include=[GraphQL-Parser]* -p:CoverletOutput=../../${{ matrix.os }}.lcov.info
41+
- name: Convert coverage report to clover format
42+
uses: danielpalme/[email protected]
43+
with:
44+
reports: '${{ matrix.os }}.lcov.info'
45+
targetdir: '.'
46+
reporttypes: 'Clover'
47+
tag: '${{ github.run_number }}_${{ github.run_id }}'
48+
- name: Monitor coverage
49+
if: ${{ matrix.os == 'ubuntu-latest' }}
50+
uses: slavcodev/[email protected]
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
clover_file: "Clover.xml"
54+
threshold_alert: 80
55+
threshold_warning: 90
56+
# https://github.com/marketplace/actions/coveralls-github-action
57+
- name: Upload coverage to Coveralls
58+
uses: coverallsapp/[email protected]
59+
with:
60+
github-token: ${{secrets.GITHUB_TOKEN }}
61+
path-to-lcov: ${{ matrix.os }}.lcov.info
62+
parallel: true
63+
flag-name: ${{ matrix.os }}
64+
- name: Upload coverage to Codecov
65+
if: ${{ 0 == 1 }}
66+
uses: codecov/codecov-action@v1
67+
with:
68+
file: ${{ matrix.os }}.lcov.info
69+
flags: unittests # optional
70+
name: codecov-umbrella # optional
71+
fail_ci_if_error: true # optional (default = false)
72+
verbose: true # optional (default = false)
73+
finish:
74+
needs: test
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Coveralls Finished
78+
uses: coverallsapp/[email protected]
79+
with:
80+
github-token: ${{ secrets.github_token }}
81+
parallel-finished: true

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# GraphQL Dotnet Parser
2-
[![AppVeyor](https://img.shields.io/appveyor/ci/graphql-dotnet-ci/parser.svg)](https://ci.appveyor.com/project/graphql-dotnet-ci/parser)
3-
[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=master)](https://coveralls.io/github/graphql-dotnet/parser?branch=master)
2+
43
[![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser)
5-
[![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)
64
[![Nuget](https://img.shields.io/nuget/dt/GraphQL-Parser)](https://www.nuget.org/packages/GraphQL-Parser)
75

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

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

12+
[![Build status](https://github.com/graphql-dotnet/parser/workflows/Publish%20preview%20to%20GitHub%20registry/badge.svg)](https://github.com/graphql-dotnet/parser/actions)
13+
[![Build status](https://github.com/graphql-dotnet/parser/workflows/Publish%20release%20to%20Nuget%20registry/badge.svg)](https://github.com/graphql-dotnet/parser/actions)
14+
1415
This library contains a lexer and parser classes as well as the complete GraphQL AST model.
1516

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

19+
Preview versions of this package are available on [GitHub Packages](https://github.com/orgs/graphql-dotnet/packages?repo_name=parser).
20+
1821
## Lexer
1922
Generates token based on input text.
2023
### Usage

src/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<VersionPrefix>5.3.5-preview</VersionPrefix>
4+
<VersionPrefix>5.3.4-preview</VersionPrefix>
55
<LangVersion>latest</LangVersion>
66
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -17,6 +17,7 @@
1717
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1818
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1919
<!-- https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables -->
20+
<!-- https://github.com/clairernovotny/DeterministicBuilds -->
2021
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">True</ContinuousIntegrationBuild>
2122
<NoWarn>$(NoWarn);1591</NoWarn>
2223
<Nullable>enable</Nullable>

src/Directory.Build.targets

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- This target must be imported into Directory.Build.targets -->
2+
<!-- Workaround. Remove once we're on 3.1.300+
3+
https://github.com/dotnet/sourcelink/issues/572 -->
4+
<Project>
5+
<PropertyGroup>
6+
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
10+
</ItemGroup>
11+
<ItemGroup>
12+
<SourceRoot Include="$(NuGetPackageRoot)" />
13+
</ItemGroup>
14+
15+
<Target Name="CoverletGetPathMap"
16+
DependsOnTargets="InitializeSourceRootMappedPaths"
17+
Returns="@(_LocalTopLevelSourceRoot)"
18+
Condition="'$(DeterministicSourcePaths)' == 'true'">
19+
<ItemGroup>
20+
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
21+
</ItemGroup>
22+
</Target>
23+
</Project>

src/GraphQLParser.Tests/GraphQLParser.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
1317
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
1418
<PackageReference Include="Shouldly" Version="4.0.0-beta0004" />
1519
<PackageReference Include="xunit" Version="2.4.1" />

src/GraphQLParser.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
..\.editorconfig = ..\.editorconfig
1515
..\.gitignore = ..\.gitignore
1616
Directory.Build.props = Directory.Build.props
17+
Directory.Build.targets = Directory.Build.targets
1718
..\LICENSE.md = ..\LICENSE.md
1819
..\assets\logo.64x64.png = ..\assets\logo.64x64.png
1920
NuGet.config = NuGet.config

src/GraphQLParser/LexerContext.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,13 @@ private void ValidateCharacterCode(int code)
429429
}
430430
}
431431

432-
private int WaitForEndOfComment(string body, int position, char code)
433-
{
434-
while (++position < body.Length && (code = body[position]) != 0 && (code > 0x001F || code == 0x0009) && code != 0x000A && code != 0x000D)
435-
{
436-
}
437-
438-
return position;
439-
}
432+
//private int WaitForEndOfComment(string body, int position, char code)
433+
//{
434+
// while (++position < body.Length && (code = body[position]) != 0 && (code > 0x001F || code == 0x0009) && code != 0x000A && code != 0x000D)
435+
// {
436+
// }
437+
438+
// return position;
439+
//}
440440
}
441441
}

src/GraphQLParser/ParserContext.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ private GraphQLFieldSelection ParseFieldSelection()
529529
return CreateFieldSelection(start, name, alias, comment);
530530
}
531531

532-
private GraphQLValue ParseFloat(bool isConstant)
532+
private GraphQLValue ParseFloat(/*bool isConstant*/)
533533
{
534534
var token = _currentToken;
535535
Advance();
@@ -631,7 +631,7 @@ private GraphQLInputValueDefinition ParseInputValueDef()
631631
};
632632
}
633633

634-
private GraphQLValue ParseInt(bool isConstant)
634+
private GraphQLValue ParseInt(/*bool isConstant*/)
635635
{
636636
var token = _currentToken;
637637
Advance();
@@ -719,7 +719,7 @@ private GraphQLNamedType ParseNamedType()
719719
};
720720
}
721721

722-
private GraphQLValue ParseNameValue(bool isConstant)
722+
private GraphQLValue ParseNameValue(/*bool isConstant*/)
723723
{
724724
var token = _currentToken;
725725

@@ -891,7 +891,7 @@ private GraphQLSelectionSet ParseSelectionSet()
891891
};
892892
}
893893

894-
private GraphQLValue ParseString(bool isConstant)
894+
private GraphQLValue ParseString(/*bool isConstant*/)
895895
{
896896
var token = _currentToken;
897897
Advance();
@@ -987,10 +987,10 @@ private GraphQLUnionTypeDefinition ParseUnionTypeDefinition()
987987
{
988988
TokenKind.BRACKET_L => ParseList(isConstant),
989989
TokenKind.BRACE_L => ParseObject(isConstant),
990-
TokenKind.INT => ParseInt(isConstant),
991-
TokenKind.FLOAT => ParseFloat(isConstant),
992-
TokenKind.STRING => ParseString(isConstant),
993-
TokenKind.NAME => ParseNameValue(isConstant),
990+
TokenKind.INT => ParseInt(/*isConstant*/),
991+
TokenKind.FLOAT => ParseFloat(/*isConstant*/),
992+
TokenKind.STRING => ParseString(/*isConstant*/),
993+
TokenKind.NAME => ParseNameValue(/*isConstant*/),
994994
TokenKind.DOLLAR when !isConstant => ParseVariable(),
995995
_ => throw new GraphQLSyntaxErrorException($"Unexpected {_currentToken}", _source, _currentToken.Start)
996996
};

0 commit comments

Comments
 (0)