Skip to content

Commit 157a78f

Browse files
authored
Merge branch 'master' into patch-2
2 parents b5b5123 + 6b7bb85 commit 157a78f

File tree

150 files changed

+2936
-1112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+2936
-1112
lines changed

.github/workflows/dotnetcore.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build, test and publish
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
config: Release
11+
PackageOutputPath: nupkg
12+
13+
jobs:
14+
build-test-publish:
15+
runs-on: windows-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Setup .NET Core and GitHub Packages
19+
uses: actions/setup-dotnet@v1
20+
with:
21+
dotnet-version: 3.1.101
22+
source-url: https://nuget.pkg.github.com/octokit/index.json
23+
env:
24+
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
25+
- name: Setup NuGet
26+
uses: nuget/setup-nuget@v1
27+
with:
28+
nuget-version: '5.x'
29+
30+
- name: Build using .NET Core
31+
run: dotnet build Octokit.GraphQL.sln -c ${{ env.config }}
32+
33+
- name: Run Octokit.GraphQL.UnitTests
34+
run: dotnet test -c ${{ env.config }} --no-build .\Octokit.GraphQL.UnitTests\Octokit.GraphQL.UnitTests.csproj # /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[Octokit.GraphQL]Octokit.GraphQL.*"
35+
- name: Run Octokit.GraphQL.Core.UnitTests
36+
run: dotnet test -c ${{ env.config }} --no-build .\Octokit.GraphQL.Core.UnitTests\Octokit.GraphQL.Core.UnitTests.csproj # /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[Octokit.GraphQL]Octokit.GraphQL.*"
37+
- name: Run Octokit.GraphQL.Core.Generation.UnitTests
38+
run: dotnet test -c ${{ env.config }} --no-build .\Octokit.GraphQL.Core.Generation.UnitTests\Octokit.GraphQL.Core.Generation.UnitTests.csproj # /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[Octokit.GraphQL]Octokit.GraphQL.*"
39+
40+
- name: Create package using .nuspec
41+
run: dotnet pack Octokit.GraphQL.Pack/Octokit.GraphQL.Pack.csproj --output ${{ env.PackageOutputPath }}
42+
43+
- name: Upload nupkg artifact
44+
uses: actions/upload-artifact@v2
45+
with:
46+
name: nupkg
47+
path: ${{ env.PackageOutputPath }}/*.nupkg
48+
49+
- name: Publish to GitHub Packages
50+
if: github.ref == 'refs/heads/master'
51+
shell: bash
52+
run: dotnet nuget push ${{ env.PackageOutputPath }}/*.nupkg
53+
54+
- name: Publish to nuget.org
55+
if: github.ref == 'refs/heads/master'
56+
shell: bash
57+
run: dotnet nuget push ${{ env.PackageOutputPath }}/*.nupkg --source nuget.org -k ${{ secrets.NUGET_TOKEN }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Integration tests
2+
3+
on:
4+
push:
5+
6+
# Runs at 00:00 UTC every day
7+
schedule:
8+
- cron: '0 */24 * * *'
9+
10+
# Runs when repository is starred
11+
watch:
12+
types: [started]
13+
14+
env:
15+
config: Release
16+
17+
jobs:
18+
integration-tests:
19+
runs-on: windows-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Setup .NET Core
25+
uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: 3.1.101
28+
29+
- name: Build using .NET Core
30+
run: dotnet build Octokit.GraphQL.sln -c ${{ env.config }}
31+
32+
- name: Run integration tests
33+
run: dotnet test -c ${{ env.config }} --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[Octokit.GraphQL]Octokit.GraphQL.*" .\Octokit.GraphQL.IntegrationTests\Octokit.GraphQL.IntegrationTests.csproj
34+
env:
35+
OCTOKIT_GQL_OAUTHTOKEN: "${{ secrets.OCTOKIT_GQL_OAUTHTOKEN }}"
36+
OCTOKIT_GQL_GITHUBUSERNAME: "${{ secrets.OCTOKIT_GQL_GITHUBUSERNAME }}"

CODE_OF_CONDUCT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected].. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [https://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: https://contributor-covenant.org
74+
[version]: https://contributor-covenant.org/version/1/4/

Octokit.GraphQL.Core.Generation.UnitTests/Octokit.GraphQL.Core.Generation.UnitTests.csproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<LangVersion>7.2</LangVersion>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="coverlet.msbuild" Version="2.2.1">
7+
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
88
<PrivateAssets>all</PrivateAssets>
99
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1010
</PackageReference>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
12-
<PackageReference Include="xunit" Version="2.4.0" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
12+
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
1417
</ItemGroup>
1518
<ItemGroup>
1619
<ProjectReference Include="..\Octokit.GraphQL.Core.Generation\Octokit.GraphQL.Core.Generation.csproj" />

Octokit.GraphQL.Core.Generation/InterfaceGenerator.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ private static string GenerateField(FieldModel field)
7575
GenerateListMethod(field, reduced) :
7676
GenerateListField(field, reduced);
7777
}
78-
else if (reduced.Kind == TypeKind.Union)
79-
{
80-
// HACK: Returning IEnumerable<object> for unions for now until we decide how to handle them.
81-
reduced = TypeModel.List(reduced);
82-
result += method ?
83-
GenerateListMethod(field, reduced) :
84-
GenerateListField(field, reduced);
85-
}
8678
else
8779
{
8880
result += method ?

Octokit.GraphQL.Core.UnitTests/Models/Repository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public Repository(Expression expression) : base(expression)
2020
public ID Id { get; }
2121
public string Name { get; }
2222
public Repository Parent => this.CreateProperty(x => x.Parent, Create);
23+
public Issue IssueByCreation(Arg<DateTimeOffset> createdSince = default) => this.CreateMethodCall(x => x.IssueByCreation(createdSince), Models.Issue.Create);
2324
public Issue Issue(Arg<int> number) => this.CreateMethodCall(x => x.Issue(number), Models.Issue.Create);
2425
public IssueOrPullRequest IssueOrPullRequest(Arg<int> number) => this.CreateMethodCall(x => x.IssueOrPullRequest(number), Models.IssueOrPullRequest.Create);
2526
public IssueConnection Issues(Arg<int>? first = null, Arg<string>? after = null, Arg<int>? last = null, Arg<string>? before = null, Arg<IEnumerable<string>>? labels = null) => this.CreateMethodCall(x => x.Issues(first, after, last, before, labels), IssueConnection.Create);

Octokit.GraphQL.Core.UnitTests/Octokit.GraphQL.Core.UnitTests.csproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<LangVersion>7.2</LangVersion>
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageReference Include="AgileObjects.ReadableExpressions" Version="1.12.1" />
8-
<PackageReference Include="coverlet.msbuild" Version="2.2.1">
8+
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
99
<PrivateAssets>all</PrivateAssets>
1010
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1111
</PackageReference>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
13-
<PackageReference Include="xunit" Version="2.4.0" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
13+
<PackageReference Include="xunit" Version="2.4.1" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
1518
</ItemGroup>
1619
<ItemGroup>
1720
<ProjectReference Include="..\Octokit.GraphQL.Core\Octokit.GraphQL.Core.csproj" />

Octokit.GraphQL.Core.UnitTests/QueryBuilderTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,20 @@ public void IntValue_Variable()
469469
Assert.Equal(expected, query.ToString(0));
470470
}
471471

472+
[Fact]
473+
public void DateTimeOffsetValue_Variable()
474+
{
475+
var expected = "query{repository(owner:\"foo\",name:\"bar\"){issueByCreation(createdSince:\"2000-01-02T03:04:05+00:00\"){body}}}";
476+
var expression = new Query()
477+
.Repository("foo", "bar")
478+
.IssueByCreation(new DateTimeOffset(2000,1,2,3,4,5, default))
479+
.Select(x => x.Body);
480+
481+
var query = expression.Compile();
482+
483+
Assert.Equal(expected, query.ToString(0));
484+
}
485+
472486
[Fact]
473487
public void InputObject_Variable()
474488
{

Octokit.GraphQL.Core/Core/Builders/QueryEntityBuilders.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
4+
using System.Linq;
35
using System.Linq.Expressions;
46
using System.Reflection;
7+
using Octokit.GraphQL.Core.Utilities;
58

69
namespace Octokit.GraphQL.Core.Builders
710
{
@@ -51,6 +54,26 @@ public static IQueryableValue<TValue> CreateMethodCall<TObject, TValue>(
5154
arguments));
5255
}
5356

57+
public static IEnumerable<TValue> CreateMethodCall<TObject, TValue>(
58+
this TObject o,
59+
Expression<Func<TObject, IEnumerable<TValue>>> selector)
60+
where TObject : IQueryableValue
61+
{
62+
var methodCall = (MethodCallExpression)selector.Body;
63+
var arguments = new List<ConstantExpression>();
64+
65+
foreach (MemberExpression arg in methodCall.Arguments)
66+
{
67+
var expression = (ConstantExpression)arg.Expression;
68+
var value = ((FieldInfo)arg.Member).GetValue(expression.Value);
69+
arguments.Add(Expression.Constant(value, arg.Type));
70+
}
71+
72+
return (IEnumerable<TValue>)(Expression.Call(Expression.Constant(o),
73+
methodCall.Method,
74+
arguments));
75+
}
76+
5477
public static TValue CreateMethodCall<TObject, TValue>(
5578
this TObject o,
5679
Expression<Func<TObject, TValue>> selector,

Octokit.GraphQL.Core/Core/Serializers/QuerySerializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ private void SerializeValue(StringBuilder builder, object value)
200200
{
201201
builder.Append(JsonConvert.ToString(id.Value, '"'));
202202
}
203+
else if (value is DateTimeOffset dto)
204+
{
205+
builder.Append(JsonConvert.ToString(dto, DateFormatHandling.IsoDateFormat));
206+
}
203207
else if (value is IEnumerable)
204208
{
205209
builder.Append("[");

0 commit comments

Comments
 (0)