Skip to content

Commit

Permalink
Add workflows, samples, tests, and formatting checks (#238)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Maximov <[email protected]>
  • Loading branch information
Shane32 and sungam3r authored Dec 10, 2022
1 parent 62a5cef commit 4976887
Show file tree
Hide file tree
Showing 38 changed files with 649 additions and 131 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build artifacts

# ==== NOTE: do not rename this yml file or the run_number will be reset ====

on:
push:
branches:
- master
- develop

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install dependencies
run: dotnet restore
- name: Build solution [Release]
run: dotnet build --no-restore -c Release -p:VersionSuffix=$GITHUB_RUN_NUMBER
- name: Pack solution [Release]
run: dotnet pack --no-restore --no-build -c Release -p:VersionSuffix=$GITHUB_RUN_NUMBER -o out
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Nuget packages
path: |
out/*
- name: Publish Nuget packages to GitHub registry
run: dotnet nuget push "out/*" -k ${{secrets.GITHUB_TOKEN}}
28 changes: 0 additions & 28 deletions .github/workflows/dotnetcore.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check formatting

on:
pull_request:
branches:
- master
- develop

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install dependencies
run: dotnet restore
- name: Check formatting
run: dotnet format --no-restore --verify-no-changes --severity warn || (echo "Run 'dotnet format' to fix issues" && exit 1)
68 changes: 68 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish release

on:
release:
types:
- published

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check github.ref starts with 'refs/tags/'
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
echo Error! github.ref does not start with 'refs/tags'
echo github.ref: ${{ github.ref }}
exit 1
- name: Set version number environment variable
env:
github_ref: ${{ github.ref }}
run: |
version="${github_ref:10}"
echo version=$version
echo "version=$version" >> $GITHUB_ENV
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.CONV_NUGET_AUTH_TOKEN}}
- name: Install dependencies
run: dotnet restore
- name: Build solution [Release]
run: dotnet build --no-restore -c Release -p:Version=$version
- name: Pack solution [Release]
run: dotnet pack --no-restore --no-build -c Release -p:Version=$version -o out
- name: Upload Nuget packages as workflow artifacts
uses: actions/upload-artifact@v3
with:
name: Nuget packages
path: |
out/*
- name: Publish Nuget packages to Nuget registry
run: dotnet nuget push "out/*" -k ${{secrets.CONV_NUGET_AUTH_TOKEN}}
- name: Upload Nuget packages as release artifacts
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
for (let file of await fs.readdir('out')) {
console.log('uploading', file);
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: ${{ github.event.release.id }},
name: file,
data: await fs.readFile(`out/${file}`)
});
}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run code tests

on: [pull_request]

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install dependencies
run: dotnet restore
- name: Build solution [Release]
run: dotnet build --no-restore -c Release
- name: Build solution [Debug]
run: dotnet build --no-restore -c Debug
- name: Test solution [Debug]
run: dotnet test --no-restore --no-build
22 changes: 22 additions & 0 deletions .github/workflows/wipcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check if PR title contains [WIP]

on:
pull_request:
types:
- opened # when PR is opened
- edited # when PR is edited
- synchronize # when code is added
- reopened # when a closed PR is reopened

jobs:
check-title:
runs-on: ubuntu-latest

steps:
- name: Fail build if pull request title contains [WIP]
env:
TITLE: ${{ github.event.pull_request.title }}
if: ${{ contains(github.event.pull_request.title, '[WIP]') }} # This function is case insensitive.
run: |
echo Warning! PR title "$TITLE" contains [WIP]. Remove [WIP] from the title when PR is ready.
exit 1
108 changes: 100 additions & 8 deletions Conventions.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.0.0

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 15.0.0.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL.Conventions", "src\GraphQL.Conventions\GraphQL.Conventions.csproj", "{AEAC9A4B-7D5B-48C6-86A9-E665F6DE4B6C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Conventions", "src\GraphQL.Conventions\GraphQL.Conventions.csproj", "{AEAC9A4B-7D5B-48C6-86A9-E665F6DE4B6C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL.Conventions.Tests", "test\GraphQL.Conventions.Tests\GraphQL.Conventions.Tests.csproj", "{5CF44C73-E5C9-4E53-A69D-4013E8AE85E5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Conventions.Tests", "test\GraphQL.Conventions.Tests\GraphQL.Conventions.Tests.csproj", "{5CF44C73-E5C9-4E53-A69D-4013E8AE85E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleWebApp", "samples\SimpleWebApp\SimpleWebApp.csproj", "{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataLoaderWithEFCore", "samples\DataLoaderWithEFCore\DataLoaderWithEFCore\DataLoaderWithEFCore.csproj", "{B4F24672-8293-4016-AE29-304C2758D4D1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{117AB27B-C4F4-4072-A857-4D2B868BEB80}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SubscriptionExample", "samples\SubscriptionsGraphQLServer\SubscriptionExample\SubscriptionExample\SubscriptionExample.csproj", "{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{60A6D426-6E98-45CA-B5C4-59B27C4EFD81}"
ProjectSection(SolutionItems) = preProject
.github\FUNDING.yml = .github\FUNDING.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{67DFCB1B-6331-41E5-8FD3-03964526EDDD}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\formatting.yml = .github\workflows\formatting.yml
.github\workflows\publish.yml = .github\workflows\publish.yml
.github\workflows\test.yml = .github\workflows\test.yml
.github\workflows\wipcheck.yml = .github\workflows\wipcheck.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solution Items", "{5A8618B7-7299-4507-A665-CC9CEE8B4674}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples' Tests", "Samples' Tests", "{F9132124-0747-427F-B607-B7BAD25332F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubscriptionExample.Tests", "test\SubscriptionExample.Tests\SubscriptionExample.Tests.csproj", "{0BDE134F-0332-4D46-B762-DC861B6B126D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,9 +49,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AEAC9A4B-7D5B-48C6-86A9-E665F6DE4B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AEAC9A4B-7D5B-48C6-86A9-E665F6DE4B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -43,5 +74,66 @@ Global
{5CF44C73-E5C9-4E53-A69D-4013E8AE85E5}.Release|x64.Build.0 = Release|Any CPU
{5CF44C73-E5C9-4E53-A69D-4013E8AE85E5}.Release|x86.ActiveCfg = Release|Any CPU
{5CF44C73-E5C9-4E53-A69D-4013E8AE85E5}.Release|x86.Build.0 = Release|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Debug|x64.ActiveCfg = Debug|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Debug|x64.Build.0 = Debug|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Debug|x86.Build.0 = Debug|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Release|Any CPU.Build.0 = Release|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Release|x64.ActiveCfg = Release|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Release|x64.Build.0 = Release|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Release|x86.ActiveCfg = Release|Any CPU
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9}.Release|x86.Build.0 = Release|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Debug|x64.ActiveCfg = Debug|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Debug|x64.Build.0 = Debug|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Debug|x86.Build.0 = Debug|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Release|Any CPU.Build.0 = Release|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Release|x64.ActiveCfg = Release|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Release|x64.Build.0 = Release|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Release|x86.ActiveCfg = Release|Any CPU
{B4F24672-8293-4016-AE29-304C2758D4D1}.Release|x86.Build.0 = Release|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Debug|x64.ActiveCfg = Debug|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Debug|x64.Build.0 = Debug|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Debug|x86.ActiveCfg = Debug|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Debug|x86.Build.0 = Debug|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Release|Any CPU.Build.0 = Release|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Release|x64.ActiveCfg = Release|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Release|x64.Build.0 = Release|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Release|x86.ActiveCfg = Release|Any CPU
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3}.Release|x86.Build.0 = Release|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Debug|x64.ActiveCfg = Debug|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Debug|x64.Build.0 = Debug|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Debug|x86.ActiveCfg = Debug|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Debug|x86.Build.0 = Debug|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Release|Any CPU.Build.0 = Release|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Release|x64.ActiveCfg = Release|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Release|x64.Build.0 = Release|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Release|x86.ActiveCfg = Release|Any CPU
{0BDE134F-0332-4D46-B762-DC861B6B126D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{19B85ED5-1F02-4D9D-AE9E-F265FC64C5D9} = {117AB27B-C4F4-4072-A857-4D2B868BEB80}
{B4F24672-8293-4016-AE29-304C2758D4D1} = {117AB27B-C4F4-4072-A857-4D2B868BEB80}
{E7DA8A82-3914-41E5-B5BE-D0BB3F234CE3} = {117AB27B-C4F4-4072-A857-4D2B868BEB80}
{67DFCB1B-6331-41E5-8FD3-03964526EDDD} = {60A6D426-6E98-45CA-B5C4-59B27C4EFD81}
{0BDE134F-0332-4D46-B762-DC861B6B126D} = {F9132124-0747-427F-B607-B7BAD25332F7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BBCC6FB7-C0AE-43E0-866B-CA12D6D121DC}
EndGlobalSection
EndGlobal
3 changes: 1 addition & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"projects": [
"src",
"test",
"deps/graphql-dotnet/src"
"test"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
var movie2 = new Movie { Id = Guid.NewGuid(), Title = "A Star Is Born", Genre = "Drama/Romance", ReleaseDateUtc = DateTime.Parse("10/04/2018 00:00:00Z") };

modelBuilder.Entity<Actor>().HasData(
new Actor { Id = Guid.NewGuid(), CountryCode = "UK", Name = "Rowan Atkinson", MovieId = movie1.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "FR", Name = "Olga Kurylenko", MovieId = movie1.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Jake Lacy", MovieId = movie1.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Bradley Cooper", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Lady Gaga", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Sam Elliott", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "UK", Name = "Rowan Atkinson", MovieId = movie1.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "FR", Name = "Olga Kurylenko", MovieId = movie1.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Jake Lacy", MovieId = movie1.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Bradley Cooper", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Lady Gaga", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Sam Elliott", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Andrew Dice Clay", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Dave Chappelle", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Rebecca Field", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Michael Harney", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Rafi Gavron", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Willam Belli", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Halsey", MovieId = movie2.Id });
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Dave Chappelle", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Rebecca Field", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Michael Harney", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Rafi Gavron", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Willam Belli", MovieId = movie2.Id },
new Actor { Id = Guid.NewGuid(), CountryCode = "US", Name = "Halsey", MovieId = movie2.Id });

modelBuilder.Entity<Country>().HasData(
new Country { Code = "UK", Name = "United Kingdom" },
Expand Down
Loading

0 comments on commit 4976887

Please sign in to comment.