Skip to content

Commit

Permalink
Remove AcceptHeaders.StableVersionJson usage
Browse files Browse the repository at this point in the history
Remove usage of `AcceptHeaders.StableVersionJson` from the actions clients.
  • Loading branch information
martincostello committed Oct 20, 2022
1 parent 06ddeb2 commit 8fff9d6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 57 deletions.
31 changes: 6 additions & 25 deletions Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ public async Task RequestsCorrectUrl()

connection.Received().Get<WorkflowRun>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand Down Expand Up @@ -274,8 +273,7 @@ public async Task RequestsCorrectUrl()

connection.Received().Get<WorkflowRun>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/attempts/456"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand Down Expand Up @@ -376,10 +374,7 @@ public async Task RequestsCorrectUrl()
await client.GetPendingDeployments("fake", "repo", 123);

connection.Received().GetAll<PendingDeployment>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/pending_deployments"),
null,
"application/vnd.github.v3+json",
null);
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/pending_deployments"));
}

[Fact]
Expand Down Expand Up @@ -420,10 +415,7 @@ public async Task RequestsCorrectUrl()
await client.GetReviewHistory("fake", "repo", 123);

connection.Received().GetAll<EnvironmentApprovals>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals"),
null,
"application/vnd.github.v3+json",
null);
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals"));
}

[Fact]
Expand Down Expand Up @@ -465,8 +457,7 @@ public async Task RequestsCorrectUrl()

connection.Received().Get<WorkflowRunUsage>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/timing"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand Down Expand Up @@ -503,7 +494,6 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<WorkflowRunsResponse>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"),
Args.EmptyDictionary,
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand Down Expand Up @@ -538,7 +528,6 @@ public async Task RequestsCorrectUrlWithRequest()
&& x["branch"] == "main"
&& x["exclude_pull_requests"] == "true"
&& x["status"] == "in_progress"),
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand All @@ -560,7 +549,6 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions()
&& x["branch"] == "main"
&& x["status"] == "in_progress"
&& x["check_suite_id"] == "42"),
"application/vnd.github.v3+json",
options);
}

Expand Down Expand Up @@ -619,7 +607,6 @@ public async Task RequestsCorrectUrlWithId()
connection.Received().GetAll<WorkflowRunsResponse>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/runs"),
Args.EmptyDictionary,
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand All @@ -634,7 +621,6 @@ public async Task RequestsCorrectUrlWithName()
connection.Received().GetAll<WorkflowRunsResponse>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yml/runs"),
Args.EmptyDictionary,
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand Down Expand Up @@ -669,7 +655,6 @@ public async Task RequestsCorrectUrlWithIdWithRequest()
&& x["branch"] == "main"
&& x["exclude_pull_requests"] == "true"
&& x["status"] == "in_progress"),
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand Down Expand Up @@ -704,7 +689,6 @@ public async Task RequestsCorrectUrlWithNameWithRequest()
&& x["branch"] == "main"
&& x["exclude_pull_requests"] == "true"
&& x["status"] == "in_progress"),
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand All @@ -726,7 +710,6 @@ public async Task RequestsCorrectUrlWithIdWithRequestWithApiOptions()
&& x["branch"] == "main"
&& x["status"] == "in_progress"
&& x["check_suite_id"] == "42"),
"application/vnd.github.v3+json",
options);
}

Expand All @@ -748,7 +731,6 @@ public async Task RequestsCorrectUrlWithNameWithRequestWithApiOptions()
&& x["branch"] == "main"
&& x["status"] == "in_progress"
&& x["check_suite_id"] == "42"),
"application/vnd.github.v3+json",
options);
}

Expand Down Expand Up @@ -910,8 +892,7 @@ public async Task RequestsCorrectUrl()

connection.Received().Post<Deployment>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/pending_deployments"),
review,
"application/vnd.github.v3+json");
review);
}

[Fact]
Expand Down
20 changes: 6 additions & 14 deletions Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public async Task RequestsCorrectUrlByWorkflowId()

connection.Received().Post<object>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/dispatches"),
createDispatch,
"application/vnd.github.v3+json");
createDispatch);
}

[Fact]
Expand All @@ -59,8 +58,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName()

connection.Received().Post<object>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/dispatches"),
createDispatch,
"application/vnd.github.v3+json");
createDispatch);
}

[Fact]
Expand Down Expand Up @@ -220,8 +218,7 @@ public async Task RequestsCorrectUrlByWorkflowId()

connection.Received().Get<Workflow>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand All @@ -234,8 +231,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName()

connection.Received().Get<Workflow>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand Down Expand Up @@ -279,8 +275,7 @@ public async Task RequestsCorrectUrlByWorkflowId()

connection.Received().Get<WorkflowUsage>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/timing"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand All @@ -293,8 +288,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName()

connection.Received().Get<WorkflowUsage>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/timing"),
null,
"application/vnd.github.v3+json");
null);
}

[Fact]
Expand Down Expand Up @@ -339,7 +333,6 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<WorkflowsResponse>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows"),
null,
"application/vnd.github.v3+json",
Args.ApiOptions);
}

Expand All @@ -356,7 +349,6 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions()
connection.Received().GetAll<WorkflowsResponse>(
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows"),
null,
"application/vnd.github.v3+json",
options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ public async Task CallsGetPendingDeploymentsOnClient()
client.GetPendingDeployments("fake", "repo", 123);

connection.Connection.Received().Get<List<PendingDeployment>>(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/pending_deployments"),
null,
null);
}

Expand Down Expand Up @@ -419,7 +418,6 @@ public async Task CallsGetReviewHistoryOnClient()
client.GetReviewHistory("fake", "repo", 123);

connection.Connection.Received().Get<List<EnvironmentApprovals>>(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals"),
null,
null);
}

Expand Down
18 changes: 9 additions & 9 deletions Octokit/Clients/ActionsWorkflowRunsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<WorkflowRunsResponse> List(string owner, string name, Workflow
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
Ensure.ArgumentNotNull(options, nameof(options));

var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsWorkflowRuns(owner, name), workflowRunsRequest.ToParametersDictionary(), AcceptHeaders.StableVersionJson, options).ConfigureAwait(false);
var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsWorkflowRuns(owner, name), workflowRunsRequest.ToParametersDictionary(), options).ConfigureAwait(false);

return new WorkflowRunsResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
Expand All @@ -90,7 +90,7 @@ public Task<WorkflowRun> Get(string owner, string name, long runId)
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.Get<WorkflowRun>(ApiUrls.ActionsWorkflowRun(owner, name, runId), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<WorkflowRun>(ApiUrls.ActionsWorkflowRun(owner, name, runId), null);
}

/// <summary>
Expand Down Expand Up @@ -126,7 +126,7 @@ public Task<IReadOnlyList<EnvironmentApprovals>> GetReviewHistory(string owner,
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.GetAll<EnvironmentApprovals>(ApiUrls.ActionsWorkflowRunApprovals(owner, name, runId), null, AcceptHeaders.StableVersionJson, null);
return ApiConnection.GetAll<EnvironmentApprovals>(ApiUrls.ActionsWorkflowRunApprovals(owner, name, runId));
}

/// <summary>
Expand Down Expand Up @@ -163,7 +163,7 @@ public Task<WorkflowRun> GetAttempt(string owner, string name, long runId, long
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.Get<WorkflowRun>(ApiUrls.ActionsWorkflowRunAttempt(owner, name, runId, attemptNumber), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<WorkflowRun>(ApiUrls.ActionsWorkflowRunAttempt(owner, name, runId, attemptNumber), null);
}

/// <summary>
Expand Down Expand Up @@ -278,7 +278,7 @@ public Task<IReadOnlyList<PendingDeployment>> GetPendingDeployments(string owner
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.GetAll<PendingDeployment>(ApiUrls.ActionsWorkflowRunPendingDeployments(owner, name, runId), null, AcceptHeaders.StableVersionJson, null);
return ApiConnection.GetAll<PendingDeployment>(ApiUrls.ActionsWorkflowRunPendingDeployments(owner, name, runId));
}

/// <summary>
Expand All @@ -298,7 +298,7 @@ public Task<Deployment> ReviewPendingDeployments(string owner, string name, long
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(review, nameof(review));

return ApiConnection.Post<Deployment>(ApiUrls.ActionsWorkflowRunPendingDeployments(owner, name, runId), review, AcceptHeaders.StableVersionJson);
return ApiConnection.Post<Deployment>(ApiUrls.ActionsWorkflowRunPendingDeployments(owner, name, runId), review);
}

/// <summary>
Expand Down Expand Up @@ -352,7 +352,7 @@ public Task<WorkflowRunUsage> GetUsage(string owner, string name, long runId)
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.Get<WorkflowRunUsage>(ApiUrls.ActionsGetWorkflowRunUsage(owner, name, runId), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<WorkflowRunUsage>(ApiUrls.ActionsGetWorkflowRunUsage(owner, name, runId), null);
}

/// <summary>
Expand Down Expand Up @@ -405,7 +405,7 @@ public async Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
Ensure.ArgumentNotNull(options, nameof(options));

var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsListWorkflowRuns(owner, name, workflowId), workflowRunsRequest.ToParametersDictionary(), AcceptHeaders.StableVersionJson, options).ConfigureAwait(false);
var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsListWorkflowRuns(owner, name, workflowId), workflowRunsRequest.ToParametersDictionary(), options).ConfigureAwait(false);

return new WorkflowRunsResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
Expand Down Expand Up @@ -463,7 +463,7 @@ public async Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
Ensure.ArgumentNotNull(options, nameof(options));

var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsListWorkflowRuns(owner, name, workflowFileName), workflowRunsRequest.ToParametersDictionary(), AcceptHeaders.StableVersionJson, options).ConfigureAwait(false);
var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsListWorkflowRuns(owner, name, workflowFileName), workflowRunsRequest.ToParametersDictionary(), options).ConfigureAwait(false);

return new WorkflowRunsResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
Expand Down
14 changes: 7 additions & 7 deletions Octokit/Clients/ActionsWorkflowsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Task CreateDispatch(string owner, string name, string workflowFileName, C
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));

return ApiConnection.Post<object>(ApiUrls.ActionsDispatchWorkflow(owner, name, workflowFileName), createDispatch, AcceptHeaders.StableVersionJson);
return ApiConnection.Post<object>(ApiUrls.ActionsDispatchWorkflow(owner, name, workflowFileName), createDispatch);
}

/// <summary>
Expand All @@ -59,7 +59,7 @@ public Task CreateDispatch(string owner, string name, long workflowId, CreateWor
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));

return ApiConnection.Post<object>(ApiUrls.ActionsDispatchWorkflow(owner, name, workflowId), createDispatch, AcceptHeaders.StableVersionJson);
return ApiConnection.Post<object>(ApiUrls.ActionsDispatchWorkflow(owner, name, workflowId), createDispatch);
}

/// <summary>
Expand Down Expand Up @@ -152,7 +152,7 @@ public Task<Workflow> Get(string owner, string name, string workflowFileName)
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));

return ApiConnection.Get<Workflow>(ApiUrls.ActionsGetWorkflow(owner, name, workflowFileName), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<Workflow>(ApiUrls.ActionsGetWorkflow(owner, name, workflowFileName), null);
}

/// <summary>
Expand All @@ -170,7 +170,7 @@ public Task<Workflow> Get(string owner, string name, long workflowId)
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.Get<Workflow>(ApiUrls.ActionsGetWorkflow(owner, name, workflowId), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<Workflow>(ApiUrls.ActionsGetWorkflow(owner, name, workflowId), null);
}

/// <summary>
Expand All @@ -189,7 +189,7 @@ public Task<WorkflowUsage> GetUsage(string owner, string name, string workflowFi
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));

return ApiConnection.Get<WorkflowUsage>(ApiUrls.ActionsGetWorkflowUsage(owner, name, workflowFileName), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<WorkflowUsage>(ApiUrls.ActionsGetWorkflowUsage(owner, name, workflowFileName), null);
}

/// <summary>
Expand All @@ -207,7 +207,7 @@ public Task<WorkflowUsage> GetUsage(string owner, string name, long workflowId)
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.Get<WorkflowUsage>(ApiUrls.ActionsGetWorkflowUsage(owner, name, workflowId), null, AcceptHeaders.StableVersionJson);
return ApiConnection.Get<WorkflowUsage>(ApiUrls.ActionsGetWorkflowUsage(owner, name, workflowId), null);
}

/// <summary>
Expand Down Expand Up @@ -243,7 +243,7 @@ public async Task<WorkflowsResponse> List(string owner, string name, ApiOptions
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

var results = await ApiConnection.GetAll<WorkflowsResponse>(ApiUrls.ActionsListWorkflows(owner, name), null, AcceptHeaders.StableVersionJson, options).ConfigureAwait(false);
var results = await ApiConnection.GetAll<WorkflowsResponse>(ApiUrls.ActionsListWorkflows(owner, name), null, options).ConfigureAwait(false);

return new WorkflowsResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
Expand Down

0 comments on commit 8fff9d6

Please sign in to comment.