Skip to content

Commit

Permalink
Merge branch 'main' of github.com:sushant12/handin into genserver-ref…
Browse files Browse the repository at this point in the history
…ator
  • Loading branch information
padmaJS committed Oct 20, 2024
2 parents 946a428 + ae239ec commit 4e8261d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/handin/assignment_submission_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Handin.AssignmentSubmissionServer do
{:noreply, state, {:continue, :process_build}}

{:error, reason} ->
Assignments.update_build(state.build, %{status: :failed})
handle_build_error(state, reason)
{:stop, reason, state}
end
end
Expand Down Expand Up @@ -158,7 +158,8 @@ defmodule Handin.AssignmentSubmissionServer do
{:ok, true} <- machine_started?(machine) do
{:ok, machine["id"], build}
else
{:error, reason} -> {:error, reason}
{:error, reason} ->
{:error, reason}
end
end

Expand Down Expand Up @@ -294,6 +295,7 @@ defmodule Handin.AssignmentSubmissionServer do
defp handle_build_error(state, reason) do
Assignments.update_build(state.build, %{status: :failed})
log_and_broadcast(state.build, %{command: "Build failed", output: inspect(reason)}, state)
@machine_api.stop(state.machine_id)
end

defp log_and_broadcast(build, log_map, state) do
Expand Down
1 change: 1 addition & 0 deletions lib/handin/build_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ defmodule Handin.BuildServer do
log_map = %{output: inspect(reason), type: :runtime, build_id: state.build.id}
Assignments.log(log_map)
log_and_broadcast(state, "log")
@machine_api.stop(state.machine_id)
end

defp handle_build_error(state, reason) do
Expand Down
4 changes: 2 additions & 2 deletions lib/handin/machine_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ defmodule Handin.MachineApi do
{:ok, %Finch.Response{status: 200, body: body}} ->
{:ok, Jason.decode!(body)}

{:ok, %Finch.Response{status: _, body: body}} ->
{:error, Jason.decode!(body) |> Map.get("error")}
{:ok, %Finch.Response{status: status, body: body}} ->
{:error, %{status: status, body: body} |> Jason.encode!(body)}
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Handin.Repo.Migrations.UpdateRunScriptToText do
use Ecto.Migration

def change do
alter table(:assignments) do
modify :run_script, :text
end
end
end

0 comments on commit 4e8261d

Please sign in to comment.