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 all 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
14 changes: 7 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ insert_final_newline = false

# Code files
[*.{cs,vb}]

# .NET code style settings - "This." and "Me." qualifiers
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#this-and-me
dotnet_style_qualification_for_field = false:warning
Expand Down Expand Up @@ -198,18 +198,18 @@ csharp_preserve_single_line_statements = false
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
dotnet_naming_rule.private_fields_with_underscore.symbols = private_fields

# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
dotnet_naming_rule.private_fields_with_underscore.style = prefix_underscore

# dotnet_naming_style.<styleTitle>.<property> = <value>
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _

# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
dotnet_naming_rule.private_fields_with_underscore.severity = warning

Expand Down Expand Up @@ -248,8 +248,8 @@ dotnet_naming_rule.async_methods_end_in_async.style = end_in_async_style

# dotnet_naming_style.<styleTitle>.<property> = <value>
dotnet_naming_style.end_in_async_style.capitalization = pascal_case
dotnet_naming_style.end_in_async_style.word_separator =
dotnet_naming_style.end_in_async_style.required_prefix =
dotnet_naming_style.end_in_async_style.word_separator =
dotnet_naming_style.end_in_async_style.required_prefix =
dotnet_naming_style.end_in_async_style.required_suffix = Async

# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CodeQL analysis

on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]

jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: github/codeql-action/init@v1
with:
languages: csharp
- uses: github/codeql-action/autobuild@v1
- uses: github/codeql-action/analyze@v1
9 changes: 5 additions & 4 deletions .github/workflows/publish-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ on:
- src/**
- .github/workflows/**

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
pack:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Use .NET Core 3.1 SDK
- name: Setup .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
Expand All @@ -27,9 +31,6 @@ jobs:
- name: Install dependencies
working-directory: src
run: dotnet restore
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
- name: Build solution [Release]
working-directory: src
run: dotnet build --no-restore -c Release -p:VersionSuffix=$GITHUB_RUN_NUMBER
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
types:
- published

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -23,7 +27,7 @@ jobs:
version="${github_ref:10}"
echo version=$version
echo "version=$version" >> $GITHUB_ENV
- name: Use .NET Core 3.1 SDK
- name: Setup .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
Expand All @@ -33,9 +37,6 @@ jobs:
- name: Install dependencies
working-directory: src
run: dotnet restore
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
- name: Build solution [Release]
working-directory: src
run: dotnet build --no-restore -c Release -p:Version=$version
Expand Down
72 changes: 68 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ name: Run unit tests

on:
pull_request:
branches:
branches:
- master
- develop
paths:
paths:
- src/**
- .github/workflows/**
# save code coverage reports when PRs are merged
push:
branches:
- master
- develop

env:
DOTNET_NOLOGO: true
Expand All @@ -23,10 +28,13 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Use .NET Core 3.1 LTS SDK
- name: Setup .NET Core 3.1 LTS SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install dependencies
working-directory: src
run: dotnet restore
Expand All @@ -44,4 +52,60 @@ 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
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: danielpalme/[email protected]
with:
reports: '${{ matrix.os }}.lcov.info'
targetdir: '.'
reporttypes: 'Clover'
tag: 'test_${{ github.run_number }}'
- name: Monitor coverage
if: ${{ startsWith(matrix.os, 'ubuntu') }}
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
if: ${{ startsWith(matrix.os, 'ubuntu') }}
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 }} #now disabled
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

buildcheck:
needs:
- test
runs-on: ubuntu-latest
if: always()
steps:
- name: Pass build check
if: ${{ needs.test.result == 'success' }}
run: exit 0
- name: Fail build check
if: ${{ needs.test.result != 'success' }}
run: exit 1
2 changes: 1 addition & 1 deletion .github/workflows/wipcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Check if PR title contains [WIP]

on:
pull_request:
types:
types:
- opened # when PR is opened
- edited # when PR is edited
- synchronize # when code is added
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# 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)
**master**<br/>[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=master)](https://coveralls.io/github/graphql-dotnet/parser?branch=master)<br/>
**develop**<br/>[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=develop)](https://coveralls.io/github/graphql-dotnet/parser?branch=develop)<br/>

[![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 @@ -12,10 +12,19 @@

![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)
[![CodeQL analysis](https://github.com/graphql-dotnet/parser/workflows/CodeQL%20analysis/badge.svg)](https://github.com/graphql-dotnet/parser/actions?query=workflow%3A%22%22CodeQL+analysis%22%22)

[![Total alerts](https://img.shields.io/lgtm/alerts/g/graphql-dotnet/parser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/graphql-dotnet/parser/alerts/)
[![Language grade: C#](https://img.shields.io/lgtm/grade/csharp/g/graphql-dotnet/parser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/graphql-dotnet/parser/context:csharp)

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. Lexer takes advantage of `ReadOnlyMemory<char>` and in most cases
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
<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>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<NoWarn>$(NoWarn);1591</NoWarn>
<NoWarn>$(NoWarn);1591</NoWarn> <!--TODO: temporary solution-->
<Nullable>enable</Nullable>
</PropertyGroup>

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>
2 changes: 1 addition & 1 deletion src/GraphQLParser.ApiTests/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Public_Api_Should_Not_Change_Inadvertently(Type type)
// See: https://shouldly.readthedocs.io/en/latest/assertions/shouldMatchApproved.html
// Note: If the AssemblyName.approved.txt file doesn't match the latest publicApi value,
// this call will try to launch a diff tool to help you out but that can fail on
// your machine if a diff tool isn't configured/setup.
// your machine if a diff tool isn't configured/setup.
publicApi.ShouldMatchApproved(options => options.WithFilenameGenerator((testMethodInfo, discriminator, fileType, fileExtension) => $"{type.Assembly.GetName().Name}.{fileType}.{fileExtension}"));
}
}
Expand Down
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="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 2 additions & 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
..\README.md = ..\README.md
Expand All @@ -35,6 +36,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEM
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{1EBB930E-951D-4857-A5A3-DED7FFE4FBD4}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\codeql-analysis.yml = ..\.github\workflows\codeql-analysis.yml
..\.github\workflows\label.yml = ..\.github\workflows\label.yml
..\.github\workflows\publish-preview.yml = ..\.github\workflows\publish-preview.yml
..\.github\workflows\publish-release.yml = ..\.github\workflows\publish-release.yml
Expand Down
7 changes: 0 additions & 7 deletions src/NuGet.config

This file was deleted.