Skip to content

Commit 2ed4900

Browse files
fix(api v1alpha): Use pipeline_file as param name in Run wf API (#420)
In the recent changes to how the Run workflow API works in the backend, we changed by mistake the expected name for the parameter that holds the name of the pipeline file. This PR fixes that issue and adds a test to verify that the request is properly formed based on the input parameters.
1 parent 0299b04 commit 2ed4900

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

public-api/v1alpha/lib/pipelines_api/workflow_client/wf_request_formatter.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule PipelinesAPI.WorkflowClient.WFRequestFormatter do
2121
request_token: UUID.uuid4(),
2222
project_id: params["project_id"],
2323
requester_id: Map.get(params, "requester_id", ""),
24-
definition_file: Map.get(params, "definition_file", ".semaphore/semaphore.yml"),
24+
definition_file: Map.get(params, "pipeline_file", ".semaphore/semaphore.yml"),
2525
organization_id: Map.get(params, "organization_id", ""),
2626
git_reference: params |> Map.get("reference", "") |> ref(),
2727
start_in_conceived_state: true,

public-api/v1alpha/test/workflow_client_test.exs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,37 @@ defmodule PipelinesAPI.WorkflowClient.Test do
4646
assert message == "Project was deleted."
4747
end
4848

49+
test "workflow client request formatter schedule - creates valid gRPC request when given valid params" do
50+
alias InternalApi.PlumberWF.TriggeredBy
51+
alias PipelinesAPI.WorkflowClient.WFRequestFormatter
52+
alias InternalApi.PlumberWF.ScheduleRequest.{ServiceType, EnvVar}
53+
54+
params = schedule_params()
55+
56+
assert {:ok, request} = WFRequestFormatter.form_schedule_request(params)
57+
assert request.service == ServiceType.value(:GIT_HUB)
58+
assert request.repo.branch_name == "main"
59+
assert request.repo.commit_sha == "773d5c953bd68cc97efa81d2e014449336265fb4"
60+
assert {:ok, _} = UUID.info(request.request_token)
61+
assert request.requester_id == params["requester_id"]
62+
assert request.definition_file == "semaphore.yml"
63+
assert request.organization_id == params["organization_id"]
64+
assert request.git_reference == "refs/heads/main"
65+
assert request.start_in_conceived_state == true
66+
assert request.triggered_by == TriggeredBy.value(:API)
67+
assert request.env_vars == [%EnvVar{name: "MY_PARAM", value: "my_value"}]
68+
end
69+
4970
defp schedule_params() do
5071
%{
5172
"reference" => "refs/heads/main",
5273
"commit_sha" => "773d5c953bd68cc97efa81d2e014449336265fb4",
53-
"definition_file" => "semaphore.yml",
74+
"pipeline_file" => "semaphore.yml",
5475
"project_id" => UUID.uuid4(),
5576
"organization_id" => UUID.uuid4(),
5677
"requester_id" => UUID.uuid4(),
57-
"repository" => %{integration_type: :GITHUB_APP}
78+
"repository" => %{integration_type: :GITHUB_APP},
79+
"parameters" => %{"MY_PARAM" => "my_value"}
5880
}
5981
end
6082
end

0 commit comments

Comments
 (0)