diff --git a/.editorconfig b/.editorconfig index 15c0413f..3a7f70f0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 @@ -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..symbols = dotnet_naming_rule.private_fields_with_underscore.symbols = private_fields - + # dotnet_naming_symbols.. = dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private - + # dotnet_naming_rule..style = dotnet_naming_rule.private_fields_with_underscore.style = prefix_underscore - + # dotnet_naming_style.. = dotnet_naming_style.prefix_underscore.capitalization = camel_case dotnet_naming_style.prefix_underscore.required_prefix = _ - + # dotnet_naming_rule..severity = dotnet_naming_rule.private_fields_with_underscore.severity = warning @@ -248,8 +248,8 @@ dotnet_naming_rule.async_methods_end_in_async.style = end_in_async_style # dotnet_naming_style.. = 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..severity = diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..f5652115 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/.github/workflows/publish-preview.yml b/.github/workflows/publish-preview.yml index cfc4b9b2..568fdd50 100644 --- a/.github/workflows/publish-preview.yml +++ b/.github/workflows/publish-preview.yml @@ -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' @@ -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 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 0c86fa39..5dbea0e7 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -5,6 +5,10 @@ on: types: - published +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + jobs: publish: runs-on: ubuntu-latest @@ -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' @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4cc1541d..18800816 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 @@ -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/ReportGenerator-GitHub-Action@4.7.1 + with: + reports: '${{ matrix.os }}.lcov.info' + targetdir: '.' + reporttypes: 'Clover' + tag: 'test_${{ github.run_number }}' + - name: Monitor coverage + if: ${{ startsWith(matrix.os, 'ubuntu') }} + uses: slavcodev/coverage-monitor-action@1.2.0 + 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/github-action@v1.1.2 + 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/github-action@v1.1.2 + 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 diff --git a/.github/workflows/wipcheck.yml b/.github/workflows/wipcheck.yml index 57243d75..a61e9abe 100644 --- a/.github/workflows/wipcheck.yml +++ b/.github/workflows/wipcheck.yml @@ -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 diff --git a/README.md b/README.md index 8c48514e..cdb0041c 100644 --- a/README.md +++ b/README.md @@ -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**
[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=master)](https://coveralls.io/github/graphql-dotnet/parser?branch=master)
+**develop**
[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=develop)](https://coveralls.io/github/graphql-dotnet/parser?branch=develop)
+ [![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) @@ -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` and in most cases diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8c53eb8d..dc86f7c9 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -17,9 +17,10 @@ true true + True true - $(NoWarn);1591 + $(NoWarn);1591 enable diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..78052937 --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,23 @@ + + + + + $([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)')) + + + + + + + + + + + <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/> + + + diff --git a/src/GraphQLParser.ApiTests/ApiApprovalTests.cs b/src/GraphQLParser.ApiTests/ApiApprovalTests.cs index 066ff006..4a658127 100644 --- a/src/GraphQLParser.ApiTests/ApiApprovalTests.cs +++ b/src/GraphQLParser.ApiTests/ApiApprovalTests.cs @@ -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}")); } } diff --git a/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj b/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj index 8358a0aa..a5f234af 100644 --- a/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj +++ b/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj @@ -10,6 +10,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/GraphQLParser.sln b/src/GraphQLParser.sln index 17bfa796..345681ed 100644 --- a/src/GraphQLParser.sln +++ b/src/GraphQLParser.sln @@ -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 @@ -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 diff --git a/src/NuGet.config b/src/NuGet.config deleted file mode 100644 index 57268ff3..00000000 --- a/src/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - -